Skip to contentSkip to conversation

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

PATCH New Filipe David Borba Manana 1 participant 1 message Oct 14, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/btrfs/tree-log.c |    5 +++++
 1 file changed, 5 insertions(+)
fs/btrfs/tree-log.c +5 -0
index 849b729..7b077a8 100644
@@ -1307,6 +1307,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 ||
@@ -1327,6 +1328,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);
 	}
Signature · 1 line
1.7.9.5