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>
This commit is contained in:
Filipe David Borba Manana 2013-10-01 17:06:53 +01:00 committed by Chris Mason
parent 6174d3cb43
commit 3d41d70252

View File

@ -3764,14 +3764,14 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
}
btrfs_release_path(path);
if (min_key.offset < (u64)-1)
if (min_key.offset < (u64)-1) {
min_key.offset++;
else if (min_key.type < (u8)-1)
} else if (min_key.type < max_key.type) {
min_key.type++;
else if (min_key.objectid < (u64)-1)
min_key.objectid++;
else
min_key.offset = 0;
} else {
break;
}
}
if (ins_nr) {
ret = copy_items(trans, inode, dst_path, src, ins_start_slot,