diff options
author | Filipe David Borba Manana <fdmanana@gmail.com> | 2013-10-14 17:49:11 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-11-11 22:02:19 -0500 |
commit | e93ae26fe1123e9077e79cc7af8a0d42adf4812f (patch) | |
tree | b74a3a9da256a0b624d2339ec5835b1756892b55 /fs | |
parent | 229eed4348a482c11cf8d494392305a85ed478f9 (diff) |
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 <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/tree-log.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index d12696db9ada..d45c04b30690 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, | |||
1312 | break; | 1312 | break; |
1313 | path->slots[0]--; | 1313 | path->slots[0]--; |
1314 | } | 1314 | } |
1315 | process_slot: | ||
1315 | btrfs_item_key_to_cpu(path->nodes[0], &key, | 1316 | btrfs_item_key_to_cpu(path->nodes[0], &key, |
1316 | path->slots[0]); | 1317 | path->slots[0]); |
1317 | if (key.objectid != ino || | 1318 | if (key.objectid != ino || |
@@ -1332,6 +1333,10 @@ static int count_inode_refs(struct btrfs_root *root, | |||
1332 | 1333 | ||
1333 | if (key.offset == 0) | 1334 | if (key.offset == 0) |
1334 | break; | 1335 | break; |
1336 | if (path->slots[0] > 0) { | ||
1337 | path->slots[0]--; | ||
1338 | goto process_slot; | ||
1339 | } | ||
1335 | key.offset--; | 1340 | key.offset--; |
1336 | btrfs_release_path(path); | 1341 | btrfs_release_path(path); |
1337 | } | 1342 | } |