]> git.neil.brown.name Git - LaFS.git/commitdiff
Improve prune_some call sequence.
authorNeilBrown <neilb@suse.de>
Sun, 13 Jun 2010 08:02:21 +0000 (18:02 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 13 Jun 2010 08:02:21 +0000 (18:02 +1000)
We only need to use prune_some rather than prune if there
are addresses that will remain untouched, and we can easily
check for that.

Also, only dirty the block if prune_some actually makes a change.

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

diff --git a/inode.c b/inode.c
index 62259824d740104d24a30888d506b8ea7ac30932..a85e9bae6b104f37083c19239f2be4355ad43efc 100644 (file)
--- a/inode.c
+++ b/inode.c
@@ -559,8 +559,6 @@ static int prune_some(void *data, u32 addr, u64 paddr, int len)
                        a->fileaddr = addr + i;
                        a->physaddr = 0;
                        a->cnt = 1;
-               LAFS_BUG(!test_bit(B_Dirty, &ib->b.flags) &&
-                      !test_bit(B_Realloc, &ib->b.flags), &ib->b);
                        ib->uninc_table.pending_cnt++;
                } else {
                        spin_unlock(&fs->lock);
@@ -786,7 +784,8 @@ void lafs_inode_handle_orphan(struct datablock *b)
                goto out;
        }
 
-       if (ib->b.fileaddr < trunc_next) {
+       if (ib->b.fileaddr < trunc_next &&
+           lafs_leaf_next(ib, 0) < trunc_next) {
                /* We only want to truncate part of this index block.
                 * So we copy addresses into uninc_table and then
                 * call lafs_incorporate.
@@ -795,8 +794,9 @@ void lafs_inode_handle_orphan(struct datablock *b)
                 */
                if (ib->uninc_table.pending_cnt == 0 &&
                    ib->uninc == NULL) {
-                       lafs_dirty_iblock(ib);
                        lafs_walk_leaf_index(ib, prune_some, ib);
+                       if (ib->uninc_table.pending_cnt)
+                               lafs_dirty_iblock(ib);
                }
                if (test_bit(B_Dirty, &ib->b.flags))
                        lafs_incorporate(fs, ib);