]> git.neil.brown.name Git - LaFS.git/commitdiff
Delay hashing of index blocks until they are incorporated.
authorNeilBrown <neilb@suse.de>
Tue, 22 Jun 2010 02:13:45 +0000 (12:13 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 22 Jun 2010 20:59:46 +0000 (06:59 +1000)
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 <neilb@suse.de>
index.c
modify.c

diff --git a/index.c b/index.c
index 84e51ff5b8b5cbae42cfe71e3bf333acbf08a7b8..02241ee15194abbaed7969d45cb663d4e1d65276 100644 (file)
--- 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)];
index 8652030e394fd9c767c1ca2aa357450b71e05834..a306313d6f7d9d6e8e490f73deb1e5b774c99316 100644 (file)
--- 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));