linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Liu Bo <bo.li.liu@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] Btrfs: copy the certain type of item if min_type equals to max_type
Date: Fri, 15 Jan 2016 12:52:28 -0800	[thread overview]
Message-ID: <1452891148-7738-1-git-send-email-bo.li.liu@oracle.com> (raw)

Some tools in btrfs-progs utilize ioctl 'BTRFS_IOC_TREE_SEARCH' and
ioctl 'BTRFS_IOC_TREE_SEARCH_V2' to look up metadata btree for what
they want, and several tools in fact only look for one certain type,
where they set a certain value for both 'sk->min_type' and 'sk->max_type'.

For example,
if we want to get the information of block groups, the current btrfs
searches extent_tree and returns not only block groups's items, but also
EXTENT_ITEM's items which could cost a large amount of user's buffer,
and tools then needs to read the buffer and spends several loops to
pick up what they want.

This lets the above two ioctl only return the certain type of items
that tools wants.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 fs/btrfs/ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index da94138..f795423 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1911,6 +1911,10 @@ static noinline int key_in_sk(struct btrfs_key *key,
 	struct btrfs_key test;
 	int ret;
 
+	/* All we want is this type of key. */
+	if (sk->min_type == sk->max_type && key->type != sk->min_type)
+		return 0;
+
 	test.objectid = sk->min_objectid;
 	test.type = sk->min_type;
 	test.offset = sk->min_offset;
-- 
2.5.0


             reply	other threads:[~2016-01-15 20:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-15 20:52 Liu Bo [this message]
2016-01-15 21:18 ` [PATCH] Btrfs: copy the certain type of item if min_type equals to max_type Hugo Mills
2016-01-16  0:54   ` Liu Bo

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=1452891148-7738-1-git-send-email-bo.li.liu@oracle.com \
    --to=bo.li.liu@oracle.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 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).