Skip to content

Commit

Permalink
Btrfs: optimize tree-log.c:count_inode_refs()
Browse files Browse the repository at this point in the history
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: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
  • Loading branch information
Filipe David Borba Manana authored and Chris Mason committed Nov 12, 2013
1 parent 229eed4 commit e93ae26
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/btrfs/tree-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,7 @@ static int count_inode_refs(struct btrfs_root *root,
break;
path->slots[0]--;
}
process_slot:
btrfs_item_key_to_cpu(path->nodes[0], &key,
path->slots[0]);
if (key.objectid != ino ||
Expand All @@ -1332,6 +1333,10 @@ static int count_inode_refs(struct btrfs_root *root,

if (key.offset == 0)
break;
if (path->slots[0] > 0) {
path->slots[0]--;
goto process_slot;
}
key.offset--;
btrfs_release_path(path);
}
Expand Down

0 comments on commit e93ae26

Please sign in to comment.