All of lore.kernel.org
 help / color / mirror / Atom feed
From: Filipe David Borba Manana <fdmanana@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Filipe David Borba Manana <fdmanana@gmail.com>
Subject: [PATCH] Btrfs-progs: optimize function btrfs_read_chunk_tree
Date: Fri,  5 Jul 2013 23:23:04 +0100	[thread overview]
Message-ID: <1373062984-12641-1-git-send-email-fdmanana@gmail.com> (raw)

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.

This is a port of the corresponding kernel patch to keep both
kernel and btrfs-progs identical:

https://patchwork.kernel.org/patch/2816401/

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

diff --git a/volumes.c b/volumes.c
index 0ff2283..22d0f31 100644
--- a/volumes.c
+++ b/volumes.c
@@ -1740,8 +1740,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,
@@ -1758,7 +1763,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(root, path);
 		goto again;
 	}
-- 
1.7.9.5


             reply	other threads:[~2013-07-05 22:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-05 22:23 Filipe David Borba Manana [this message]
2013-07-29 18:35 ` [PATCH v2] Btrfs-progs: optimize function btrfs_read_chunk_tree Filipe David Borba Manana
2013-07-30  3:21   ` Miao Xie
2013-07-30 11:08 ` [PATCH v3] " Filipe David Borba Manana
2013-07-31  1:13   ` Miao Xie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1373062984-12641-1-git-send-email-fdmanana@gmail.com \
    --to=fdmanana@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.