Commit e93ae26f authored by Filipe David Borba Manana's avatar Filipe David Borba Manana Committed by Chris Mason

Btrfs: optimize tree-log.c:count_inode_refs()

Avoid repeated tree searches by processing all inode ref items in
a leaf at once instead of processing one at a time, followed by a
path release and a tree search for a key with a decremented offset.
Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 229eed43
...@@ -1312,6 +1312,7 @@ static int count_inode_refs(struct btrfs_root *root, ...@@ -1312,6 +1312,7 @@ static int count_inode_refs(struct btrfs_root *root,
break; break;
path->slots[0]--; path->slots[0]--;
} }
process_slot:
btrfs_item_key_to_cpu(path->nodes[0], &key, btrfs_item_key_to_cpu(path->nodes[0], &key,
path->slots[0]); path->slots[0]);
if (key.objectid != ino || if (key.objectid != ino ||
...@@ -1332,6 +1333,10 @@ static int count_inode_refs(struct btrfs_root *root, ...@@ -1332,6 +1333,10 @@ static int count_inode_refs(struct btrfs_root *root,
if (key.offset == 0) if (key.offset == 0)
break; break;
if (path->slots[0] > 0) {
path->slots[0]--;
goto process_slot;
}
key.offset--; key.offset--;
btrfs_release_path(path); btrfs_release_path(path);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment