linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: optimize function btrfs_read_chunk_tree
@ 2013-07-03 12:19 Filipe David Borba Manana
  2013-07-29 18:22 ` [PATCH v2] " Filipe David Borba Manana
  2013-07-30 11:03 ` [PATCH v3] " Filipe David Borba Manana
  0 siblings, 2 replies; 5+ messages in thread
From: Filipe David Borba Manana @ 2013-07-03 12:19 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe David Borba Manana

After reading all device items from the chunk tree, don't
exit the loop and then navigate down the tree again to find
the chunk items. Instead, if while reading the device items
we find a chunk item in the leaf keep iterating over the leaf
and process the chunk items - at the moment chunk items always
follow immediately the device items in the chunk tree, and if
this fact changes in the future, revert back to previous
behaviour of exiting the loop and navigate down the tree again
to search for chunk items, but use BTRFS_FIRST_CHUNK_TREE_OBJECTID
as the object id for the search key, as any chunk item has a
key that has this object id.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---
 fs/btrfs/volumes.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index b2d1eac..4e969db 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5668,8 +5668,13 @@ again:
 		}
 		btrfs_item_key_to_cpu(leaf, &found_key, slot);
 		if (key.objectid == BTRFS_DEV_ITEMS_OBJECTID) {
-			if (found_key.objectid != BTRFS_DEV_ITEMS_OBJECTID)
+			if (found_key.objectid != BTRFS_DEV_ITEMS_OBJECTID) {
+				if (found_key.type == BTRFS_CHUNK_ITEM_KEY) {
+					key.objectid = found_key.objectid;
+					continue;
+				}
 				break;
+			}
 			if (found_key.type == BTRFS_DEV_ITEM_KEY) {
 				struct btrfs_dev_item *dev_item;
 				dev_item = btrfs_item_ptr(leaf, slot,
@@ -5688,7 +5693,7 @@ again:
 		path->slots[0]++;
 	}
 	if (key.objectid == BTRFS_DEV_ITEMS_OBJECTID) {
-		key.objectid = 0;
+		key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
 		btrfs_release_path(path);
 		goto again;
 	}
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-31  1:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-03 12:19 [PATCH] Btrfs: optimize function btrfs_read_chunk_tree Filipe David Borba Manana
2013-07-29 18:22 ` [PATCH v2] " Filipe David Borba Manana
2013-07-30  3:09   ` Miao Xie
2013-07-30 11:03 ` [PATCH v3] " Filipe David Borba Manana
2013-07-31  1:12   ` Miao Xie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).