]> git.neil.brown.name Git - LaFS.git/commitdiff
truncate: make sure index block is pinned and dirty when we prune it.
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)
inode.c

diff --git a/inode.c b/inode.c
index c09db2950a99127e8000aa3b33a76532c48fd197..da418373cf26ba1a684889fd264d361620dda0be 100644 (file)
--- a/inode.c
+++ b/inode.c
@@ -749,6 +749,8 @@ static int lafs_inode_handle_orphan(struct datablock *b)
                lafs_cluster_allocate(&ib->b, 0);
                goto out_unlocked;
        }
+
+       lafs_pin_block(&ib->b);
        
        /* It might be that this can happen, in which case
         * we simply update trunc_next and loop.  But I'd like
@@ -772,8 +774,10 @@ static int lafs_inode_handle_orphan(struct datablock *b)
                 * cannot trust next_trunc
                 */
                if (ib->uninc_table.pending_cnt == 0 &&
-                   ib->uninc == NULL)
+                   ib->uninc == NULL) {
+                       lafs_dirty_iblock(ib);
                        lafs_walk_leaf_index(ib, prune_some, ib);
+               }
                lafs_incorporate(fs, ib);
                goto out;
        }
@@ -781,9 +785,10 @@ static int 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_Valid, &ib->b.flags)) {
+               lafs_dirty_iblock(ib);
                lafs_walk_leaf_index(ib, prune, ib);
-       else {
+       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);