]> git.neil.brown.name Git - LaFS.git/commitdiff
Don't clear B_Valid when index block is empty
authorNeilBrown <neilb@suse.de>
Mon, 28 Sep 2009 02:32:48 +0000 (12:32 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 7 Jun 2010 03:23:30 +0000 (13:23 +1000)
This overloading just caused problem. Invent a new flag instead.

cluster.c
index.c
inode.c
io.c
lafs.h
modify.c

index 9388f4e849f8073af1eeb8259bc8811d2373a0e9..dbf4de5c50404a00f0f8bcee4587e387fd0ee45f 100644 (file)
--- a/cluster.c
+++ b/cluster.c
@@ -530,18 +530,7 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
        LAFS_BUG(!test_bit(B_IOLock, &b->flags), b);
        lai = LAFSI(b->inode);
 
-       if (!test_bit(B_Valid, &b->flags)) {
-               if (test_bit(B_PhysValid, &b->flags) &&
-                   !test_bit(B_InoIdx, &b->flags) &&
-                   b->physaddr != 0)
-                       lafs_allocated_block(fs, b, 0);
-               if (test_and_clear_bit(B_Dirty, &b->flags))
-                       lafs_space_return(fs, 1);
-               if (test_and_clear_bit(B_Realloc, &b->flags))
-                       lafs_space_return(fs, 1);
-               lafs_iounlock_block(b);
-               return wc->cluster_seq;
-       }
+       LAFS_BUG(!test_bit(B_Valid, &b->flags), b);
        LAFS_BUG(!fs->rolled, b);
        LAFS_BUG(lai->flags & File_nonlogged &&
               !test_bit(B_Index, &b->flags), b);
diff --git a/index.c b/index.c
index 9faae6c20ef3208af5326018c57ae85442b11cd7..75120924f8e6e1b322d210467e14a384d9b42389 100644 (file)
--- a/index.c
+++ b/index.c
@@ -2027,8 +2027,7 @@ int lafs_allocated_block(struct fs *fs, struct block *blk, u64 phys)
                        printk("Not valid in lafs_allocated_block: %s\n",
                               strblk(&p->b));
                        printk("blk is %s\n", strblk(blk));
-                       lafs_clear_index(p);
-                       set_bit(B_Valid, &p->b.flags);
+                       BUG();
                }
                LAFS_BUG(!test_bit(B_Valid, &p->b.flags), &p->b);
                if (!test_bit(B_Realloc, &p->b.flags)) {
diff --git a/inode.c b/inode.c
index 74e71832975339093aa4a2b2acc44af31e2f2364..5e60cfad6adb942a2c24b3654878735e0c5d5bef 100644 (file)
--- a/inode.c
+++ b/inode.c
@@ -684,6 +684,7 @@ void lafs_inode_handle_orphan(struct datablock *b)
                        putiref(ib2, MKREF(inode_handle_orphan2));
                        goto out2;
                }
+               if (test_bit(B_Valid, &ib2->b.flags))
                do
                        lafs_incorporate(fs, ib2);
                while (ib2->uninc_table.pending_cnt || ib2->uninc);
@@ -794,15 +795,12 @@ void lafs_inode_handle_orphan(struct datablock *b)
 
        while (ib->uninc_table.pending_cnt || ib->uninc)
                lafs_incorporate(fs, ib);
-       if (test_bit(B_Valid, &ib->b.flags)) {
+       if (!test_bit(B_PhysValid, &ib->b.flags) ||
+           ib->b.physaddr != 0) {
                lafs_dirty_iblock(ib);
                lafs_walk_leaf_index(ib, prune, ib);
-       } else {
-               /* This had better be already clear. */
-               LAFS_BUG(!test_bit(B_PhysValid, &ib->b.flags), &ib->b);
-               LAFS_BUG(ib->b.physaddr != 0, &ib->b);
        }
-       clear_bit(B_Valid, &ib->b.flags);
+       lafs_incorporate(fs, ib);
        LAFS_BUG(!list_empty(&ib->children), &ib->b);
 
  out:
diff --git a/io.c b/io.c
index 6534e03b61e4d758badc7b87b05469719704dd99..7c8310ad9759a5bbb02d1974bf5bb21e7e1f0514 100644 (file)
--- a/io.c
+++ b/io.c
@@ -409,12 +409,8 @@ 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);
-               if (b->physaddr == 0) {
-                       lafs_clear_index(ib);
-                       set_bit(B_Valid, &ib->b.flags);
-                       lafs_iounlock_block(b);
-                       return 0;
-               }
+               LAFS_BUG(b->physaddr == 0, b);
+
                page = virt_to_page(ib->data);
                offset = offset_in_page(ib->data);
        } else {
diff --git a/lafs.h b/lafs.h
index ce210bd70df90a87315f7df2455718648274ea78..5b6040ad837c751d6156e174f23c34197eeb1918 100644 (file)
--- a/lafs.h
+++ b/lafs.h
@@ -539,7 +539,6 @@ int lafs_pin_dblock(struct datablock *b, int alloc_type);
 int lafs_reserve_block(struct block *b, int alloc_type);
 void lafs_dirty_dblock(struct datablock *b);
 void lafs_erase_dblock(struct datablock *b);
-void lafs_erase_iblock(struct indexblock *b);
 void lafs_dirty_iblock(struct indexblock *b);
 void block_drop_addr(struct fs *fs, struct inode *ino, u32 addr);
 void lafs_flush(struct datablock *b);
index cfd0d0f15bc601b38f84791d54ea32b3195781b9..c89c3ac7aedd17c7070c79d4f8d2adcc1e4a4250 100644 (file)
--- a/modify.c
+++ b/modify.c
@@ -1619,10 +1619,7 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib)
 
        LAFS_BUG(!test_bit(B_IOLock, &ib->b.flags), &ib->b);
 
-       if (!test_bit(B_Valid, &ib->b.flags)) {
-               lafs_clear_index(ib);
-               set_bit(B_Valid, &ib->b.flags);
-       }
+       LAFS_BUG(!test_bit(B_Valid, &ib->b.flags) && ib->depth > 0, &ib->b);
 
        if (ib->depth <= 1) {
                /* take a copy of the uninc_table so we can work while
@@ -1660,6 +1657,7 @@ void lafs_incorporate(struct fs *fs, struct indexblock *ib)
                                LAFSI(ib->b.inode)->depth = 1;
                                ((struct la_inode*)(buf-offset))->depth = 1;
                                ib->depth = 1;
+                               set_bit(B_Valid, &ib->b.flags);
                        }
                } else
                        offset = 0;