Daniel Phillips <[email protected]> writes:

>> This is incremental patch of this patch.
>> 
>> This adds init_btree() to initialize btree. And it calls new
>> ->btree_init() method to initialize per btree fields (it is only
>> ->entries_per_leaf currently).
>> 
>> Then, this uses it except btree in main(). So, with this, new_btree()
>> allocates new btree, and init_btree initialize ->btree with existing
>> btree.
>
> I applied both our patches, then took advantage of the opportunity to
> simplify things a little.  Thinking ahead to when inodes do not always
> have btrees, inode initialization does not do any btree initialization,
> except set the entire embedded btree to zero.  The semaphore init that
> started this whole chase is now done in your new init_btree, and btrees
> are initialized only when the persistent object is created or loaded
> from disk.  Now, ops is never NULL: the initialization is always done
> at a point where we know what the ops should be.

It makes the uninitialized inode->btree. kmem_cache_alloc() doesn't
initialize inode at all. I.e. it has old btree.  It may hide bug (in my
thought, to hide bug makes hard to debug much), and it is what I want to
prevent. Because uninitialized btree on memory can still be valid some
times.

For the delayed btree allocation, it was going to define the delayed
btree state explicitly, and I thought we may want to use one of btree
fields to load/create btree (E.g. lock to create btree). We can add it
to delayed btree state.

Anyway, please apply this patch instead.

Thanks.
-- 
OGAWA Hirofumi <[email protected]>

diff -puN user/kernel/super.c~inode_init-fix user/kernel/super.c
--- tux3/user/kernel/super.c~inode_init-fix     2008-12-25 09:54:19.000000000 
+0900
+++ tux3-hirofumi/user/kernel/super.c   2008-12-25 09:54:19.000000000 +0900
@@ -88,6 +88,7 @@ static struct inode *tux3_alloc_inode(st
        tuxnode_t *tuxi = kmem_cache_alloc(tux_inode_cachep, GFP_KERNEL);
        if (!tuxi)
                return NULL;
+       tuxi->btree = (struct btree){};
        tuxi->present = 0;
        tuxi->xcache = NULL;
 
_

_______________________________________________
Tux3 mailing list
[email protected]
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3

Reply via email to