]> git.neil.brown.name Git - LaFS.git/commitdiff
Allow empty index blocks to be loaded.
authorNeilBrown <neilb@suse.de>
Tue, 22 Jun 2010 05:36:37 +0000 (15:36 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 23 Jun 2010 01:57:20 +0000 (11:57 +1000)
If physaddr is 0, then just create a clean index block.

Signed-off-by: NeilBrown <neilb@suse.de>
io.c

diff --git a/io.c b/io.c
index d15bec8c254fa2fd97a0a7a52b4a1d48e1bb241f..b1615a4d80a844cc629478bbdd38807d9e97591f 100644 (file)
--- a/io.c
+++ b/io.c
@@ -409,7 +409,19 @@ lafs_load_block(struct block *b)
        LAFS_BUG(test_bit(B_InoIdx, &b->flags), b);
        if (test_bit(B_Index, &b->flags)) {
                struct indexblock *ib = iblk(b);
-               LAFS_BUG(b->physaddr == 0, b);
+
+               if (b->physaddr == 0) {
+                       /* An empty index block.  One doesn't
+                        * see many of these as it means we trimmed
+                        * out some blocks, but not all following
+                        * block, and block in the hole is being
+                        * looked for.  Just Create a valid clear
+                        * index block.
+                        */
+                       lafs_clear_index(ib);
+                       lafs_iounlock_block(b);
+                       return 0;
+               }
 
                page = virt_to_page(ib->data);
                offset = offset_in_page(ib->data);