[PATCH] Btrfs: copy the certain type of item if min_type equals to max_type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux