/* Test basic low level functions */ static void test01(struct sb *sb) { char attrs[1000] = { }; struct xattr *xattr; int err; change_begin_atomic(sb); /* Test positive and negative refcount carry */ atom_t atom; err = make_atom(sb->atable, "foo", 3, &atom); test_assert(!err); err = atomref(sb->atable, atom, 1 << 15); test_assert(!err); err = atomref(sb->atable, atom, 1 << 15); test_assert(!err); err = atomref(sb->atable, atom, -(1 << 15)); test_assert(!err); err = atomref(sb->atable, atom, -(1 << 15)); test_assert(!err); atom_t atom1, atom2, atom3; /* Test atom table */ err = make_atom(sb->atable, "foo", 3, &atom1); test_assert(!err); err = make_atom(sb->atable, "foo", 3, &atom2); test_assert(!err); test_assert(atom1 == atom2); err = make_atom(sb->atable, "bar", 3, &atom1); test_assert(!err); err = make_atom(sb->atable, "foo", 3, &atom2); test_assert(!err); test_assert(atom1 != atom2); err = make_atom(sb->atable, "bar", 3, &atom3); test_assert(!err); test_assert(atom1 == atom3); change_end_atomic(sb); struct inode *inode; struct tux3_inode *tuxnode; struct tux_iattr iattr = { .mode = S_IFREG, }; inode = tuxcreate(sb->rootdir, "foo", 3, &iattr); test_assert(inode); tuxnode = tux_inode(inode); struct xcache_data data[] = { { .buf = "hello ", .len = strlen("hello "), .atom = 0x666, }, { .buf = "world!", .len = strlen("world!"), .atom = 0x777, },
/* * Mark inode dirty to delete. (called from ->drop_inode()). * Caller must hold inode->i_lock. */ void tux3_mark_inode_to_delete(struct inode *inode) { struct sb *sb = tux_sb(inode->i_sb); struct tux3_inode *tuxnode = tux_inode(inode); unsigned delta; /* inode has dead mark already */ if (tux3_inode_is_dead(tuxnode)) return; change_begin_atomic(sb); delta = tux3_inode_delta(inode); __tux3_mark_inode_to_delete(inode, delta); /* * Hack: this is called under inode->i_lock. So, we have to * release inode->i_lock to call mark_inode_dirty_sync(). * * FIXME: we want to set I_DIRTY_SYNC (I_DIRTY_SYNC will * prevent the indo is freed) and wakeup flusher if need, * while preventing inode is freed. Need better way to do. */ if (!(tux3_dirty_flags(inode, delta) & I_DIRTY_SYNC)) { /* FIXME: I_REFERENCED can't prevent completely */ //inode->i_state |= I_REFERENCED; /* FIXME: I_WILL_FREE will bother igrab() grabs reference */ inode->i_state |= I_WILL_FREE; spin_unlock(&inode->i_lock); /* Tell dead inode to backend by marking as dirty. */ tux3_mark_inode_dirty_sync(inode); spin_lock(&inode->i_lock); inode->i_state &= ~I_WILL_FREE; #ifdef __KERNEL__ wake_up_bit(&inode->i_state, __I_NEW); #endif } change_end_atomic(sb); }
int make_tux3(struct sb *sb) { int err; err = clear_other_magic(sb); if (err) return err; change_begin_atomic(sb); trace("create bitmap"); sb->bitmap = create_internal_inode(sb, TUX_BITMAP_INO, NULL); if (IS_ERR(sb->bitmap)) { err = PTR_ERR(sb->bitmap); goto error_change_end; } change_end_atomic(sb); /* Set fake backend mark to modify backend objects. */ tux3_start_backend(sb); err = reserve_superblock(sb); tux3_end_backend(); if (err) goto error; change_begin_atomic(sb); #if 0 trace("create version table"); sb->vtable = create_internal_inode(sb, TUX_VTABLE_INO, NULL); if (IS_ERR(sb->vtable)) { err = PTR_ERR(sb->vtable); goto error_change_end; } #endif trace("create atom dictionary"); sb->atable = create_internal_inode(sb, TUX_ATABLE_INO, NULL); if (IS_ERR(sb->atable)) { err = PTR_ERR(sb->atable); goto error_change_end; } trace("create root directory"); struct tux_iattr root_iattr = { .mode = S_IFDIR | 0755, }; sb->rootdir = create_internal_inode(sb, TUX_ROOTDIR_INO, &root_iattr); if (IS_ERR(sb->rootdir)) { err = PTR_ERR(sb->rootdir); goto error_change_end; } change_end_atomic(sb); err = sync_super(sb); if (err) goto error; show_buffers(mapping(sb->bitmap)); show_buffers(mapping(sb->rootdir)); show_buffers(sb->volmap->map); return 0; error_change_end: change_end_atomic(sb); error: tux3_err(sb, "eek, %s", strerror(-err)); iput(sb->bitmap); sb->bitmap = NULL; return err; } int tux3_init_mem(void) { return tux3_init_hole_cache(); } void tux3_exit_mem(void) { tux3_destroy_hole_cache(); }