From d1c6e4df108e7329cf08e5cc0370a3bd0a0ce9a4 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 13 Jun 2010 18:02:21 +1000 Subject: [PATCH] Improve prune_some call sequence. 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 --- inode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inode.c b/inode.c index 6225982..a85e9ba 100644 --- 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); -- 2.39.5