From: NeilBrown Date: Mon, 7 Jun 2010 01:30:48 +0000 (+1000) Subject: Make sure find_block loads data from inode. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=91f65e5fba56b16c4b1124f058a1d0870eaba6a6;p=LaFS.git Make sure find_block loads data from inode. lafs_load_block expects not to need to read block 0 of a depth==0 inode as lafs_find_block is expected to load that. However there is a case where find_block (called from lafs_find_block) skips the load. So remove that case. Signed-off-by: NeilBrown --- diff --git a/index.c b/index.c index 7512092..5d113ec 100644 --- a/index.c +++ b/index.c @@ -1692,28 +1692,27 @@ find_block(struct datablock *b, int adopt, int async) LAFS_BUG(test_bit(B_Pinned, &b->b.flags) && b->b.parent == NULL, &b->b); - - if (test_bit(B_PhysValid, &b->b.flags) - && (!adopt || b->b.parent || test_bit(B_Root, &b->b.flags))) { - return 0; - } if (b->b.inode == NULL) return 0; lai = LAFSI(b->b.inode); if (lai->depth == 0) { /* Data is in the inode if anywhere */ - b->b.physaddr = 0; - set_bit(B_PhysValid, &b->b.flags); + if (!test_bit(B_PhysValid, &b->b.flags)) { + b->b.physaddr = 0; + set_bit(B_PhysValid, &b->b.flags); + } db = lafs_inode_dblock(b->b.inode, async, MKREF(findblock)); if (IS_ERR(db)) return PTR_ERR(db); - if (!test_bit(B_Valid, &b->b.flags) && b->b.fileaddr == 0) + if (!test_bit(B_Valid, &b->b.flags) && b->b.fileaddr == 0) { /* Now is the best time to copy data from inode into * datablock, as we know we have a valid inode block * now. */ + LAFS_BUG(b->b.physaddr != 0, &b->b); fill_block_zero(b, db); + } if (adopt) { ib = lafs_make_iblock(b->b.inode, adopt, async, MKREF(findblock)); @@ -1726,6 +1725,12 @@ find_block(struct datablock *b, int adopt, int async) putdref(db, MKREF(findblock)); return 0; } + + if (test_bit(B_PhysValid, &b->b.flags) + && (!adopt || b->b.parent || test_bit(B_Root, &b->b.flags))) { + return 0; + } + db = lafs_inode_dblock(b->b.inode, async, MKREF(findblock)); if (IS_ERR(db)) return PTR_ERR(db);