From: Filipe David Borba Manana Date: Mon, 14 Oct 2013 21:49:11 +0000 (+0100) Subject: Btrfs: optimize tree-log.c:count_inode_refs() X-Git-Tag: v4.14-rc1~8407^2~71 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e93ae26fe1123e9077e79cc7af8a0d42adf4812f;p=platform%2Fkernel%2Flinux-rpi.git 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: Filipe David Borba Manana Signed-off-by: Josef Bacik Signed-off-by: Chris Mason --- diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index d12696d..d45c04b 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -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 || @@ -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); }