aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@gmail.com>2013-10-01 12:06:53 -0400
committerChris Mason <chris.mason@fusionio.com>2013-11-11 21:55:11 -0500
commit3d41d70252234db153ea1b037052278ff5786ad5 (patch)
tree7bd2c8d5c7a6fcb2e25a25204c525bf18d0535aa /fs/btrfs/tree-log.c
parent6174d3cb43aa974d0c8590a3e628ac35ab0bbc13 (diff)
Btrfs: remove unnecessary tree search when logging inode
In tree-log.c:btrfs_log_inode(), we keep calling btrfs_search_forward() until it returns a key whose objectid is higher than our inode or until the key's type is higher than our maximum allowed type. At the end of the loop, we increment our mininum search key's objectid and type regardless of our desired target objectid and maximum desired type, which causes another loop iteration that will call again btrfs_search_forward() just to figure out we've gone beyond our maximum key and exit the loop. Therefore while incrementing our minimum key, don't do it blindly and exit the loop immiediately if the next search key's objectid or type is beyond what we seek. Also after incrementing the type, set the key's offset to 0, which was missing and could make us loose some of the inode's items. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 8ac96c261a11..964c583ea900 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3764,14 +3764,14 @@ next_slot:
3764 } 3764 }
3765 btrfs_release_path(path); 3765 btrfs_release_path(path);
3766 3766
3767 if (min_key.offset < (u64)-1) 3767 if (min_key.offset < (u64)-1) {
3768 min_key.offset++; 3768 min_key.offset++;
3769 else if (min_key.type < (u8)-1) 3769 } else if (min_key.type < max_key.type) {
3770 min_key.type++; 3770 min_key.type++;
3771 else if (min_key.objectid < (u64)-1) 3771 min_key.offset = 0;
3772 min_key.objectid++; 3772 } else {
3773 else
3774 break; 3773 break;
3774 }
3775 } 3775 }
3776 if (ins_nr) { 3776 if (ins_nr) {
3777 ret = copy_items(trans, inode, dst_path, src, ins_start_slot, 3777 ret = copy_items(trans, inode, dst_path, src, ins_start_slot,