]> git.neil.brown.name Git - LaFS.git/commitdiff
IO: support loading of an index block from addr 0.
authorNeilBrown <neilb@suse.de>
Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 25 Aug 2009 07:09:54 +0000 (17:09 +1000)
This can happen when adding blocks to a prevously truncated
file, or even when continuing with a slow truncate.

phys==0 just means the index block is empty, so honour that.

io.c

diff --git a/io.c b/io.c
index dcf106adc00b2926c5112e209f8209c4982ecbbb..994c2ab94f20fc33dffb00366f230aaa83bda812 100644 (file)
--- a/io.c
+++ b/io.c
@@ -406,11 +406,10 @@ lafs_load_block(struct block *b)
        if (test_bit(B_Index, &b->flags)) {
                struct indexblock *ib = iblk(b);
                if (b->physaddr == 0) {
-                       LAFS_BUG(1, b);
-                       /* I think this is really an error FIXME */
-                       memset(ib->data, 0, b->inode->i_sb->s_blocksize);
+                       lafs_clear_index(ib);
+                       set_bit(B_Valid, &ib->b.flags);
                        lafs_iounlock_block(b);
-                       return -EIO;
+                       return 0;
                }
                page = virt_to_page(ib->data);
                offset = offset_in_page(ib->data);