From: NeilBrown Date: Tue, 22 Jun 2010 02:13:45 +0000 (+1000) Subject: Delay hashing of index blocks until they are incorporated. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=9457dc1c51b17c9ef8651b681845f2ba88010e46;p=LaFS.git Delay hashing of index blocks until they are incorporated. We don't need an index block in the hash table until its address is in the parent, as until then we will never try a lookup. And it is good to delay it as it is possible for there to be two blocks with the same address, one that is empty and thus ignored mostly, and one that has since split of an earlier child. While this is unlikely, we don't want that split-off block to appear in the hash table until both have been incorporated. Signed-off-by: NeilBrown --- diff --git a/index.c b/index.c index 84e51ff..02241ee 100644 --- a/index.c +++ b/index.c @@ -301,6 +301,9 @@ void lafs_hash_iblock(struct indexblock *ib) /* This block was an InoIdx block but has just become a real * index block, so hash it. There cannot be a block with this * address already as we haven't increased the inode depth yet. + * Alternately this block was recently split off another, + * and has now been incorporated, so a lookup might need + * to find it. So it better be in the hash table. */ struct hlist_head *head = &hash_table[ihash(ib->b.inode, ib->b.fileaddr, ib->depth)]; diff --git a/modify.c b/modify.c index 8652030..a306313 100644 --- a/modify.c +++ b/modify.c @@ -117,6 +117,7 @@ static int incorp_index(struct block *b) struct block, siblings); LAFS_BUG(b->siblings.prev == &b->parent->children, b); putref(pb, MKREF(primary)); + lafs_hash_iblock(iblk(b)); } putref(b, MKREF(uninc)); return cr; @@ -1382,7 +1383,6 @@ static int do_incorporate_leaf(struct fs *fs, struct indexblock *ib, new->b.parent = ib->b.parent; (void)getiref(new->b.parent, MKREF(child)); new->b.inode = ib->b.inode; - lafs_hash_iblock(new); LAFS_BUG(!test_bit(B_Pinned, &ib->b.flags), &ib->b); set_phase(&new->b, test_bit(B_Phase1, &ib->b.flags)); return 2; @@ -1527,7 +1527,6 @@ static int do_incorporate_internal(struct fs *fs, struct indexblock *ib, new->b.parent = ib->b.parent; (void)getiref(new->b.parent, MKREF(child)); new->b.inode = ib->b.inode; - lafs_hash_iblock(new); LAFS_BUG(!test_bit(B_Pinned, &ib->b.flags), &ib->b); set_phase(&new->b, test_bit(B_Phase1, &ib->b.flags));