linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Btrfs: Really return keys within specified range
@ 2010-12-13  9:47 Li Zefan
  2010-12-13  9:50 ` [PATCH 2/3] Btrfs: Don't return items more than user specified Li Zefan
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Li Zefan @ 2010-12-13  9:47 UTC (permalink / raw)
  To: linux-btrfs@vger.kernel.org; +Cc: Ian! D. Allen

The keys returned by tree search ioctl should be restricted to:

	key.objectid = [min_objectid, max_objectid] &&
	key.offset   = [min_offset, max_offset] &&
	key.type     = [min_type, max_type]

But actually it returns those keys:

	[(min_objectid, min_type, min_offset),
		(max_objectid, max_type, max_offset)].

And the bug can result in missing subvolumes in the output of
"btrfs subvolume list"

Reported-by: Ian! D. Allen <idallen@idallen.ca>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 fs/btrfs/ioctl.c |   20 ++++----------------
 1 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f1c9bb4..785f713 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1028,23 +1028,11 @@ out:
 static noinline int key_in_sk(struct btrfs_key *key,
 			      struct btrfs_ioctl_search_key *sk)
 {
-	struct btrfs_key test;
-	int ret;
-
-	test.objectid = sk->min_objectid;
-	test.type = sk->min_type;
-	test.offset = sk->min_offset;
-
-	ret = btrfs_comp_cpu_keys(key, &test);
-	if (ret < 0)
+	if (key->type < sk->min_type || key->type > sk->max_type)
 		return 0;
-
-	test.objectid = sk->max_objectid;
-	test.type = sk->max_type;
-	test.offset = sk->max_offset;
-
-	ret = btrfs_comp_cpu_keys(key, &test);
-	if (ret > 0)
+	if (key->offset < sk->min_offset || key->offset > sk->max_offset)
+		return 0;
+	if (key->objectid < sk->min_objectid || key->objectid > sk->max_objectid)
 		return 0;
 	return 1;
 }
-- 
1.6.3


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

end of thread, other threads:[~2010-12-16  1:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-13  9:47 [PATCH 1/3] Btrfs: Really return keys within specified range Li Zefan
2010-12-13  9:50 ` [PATCH 2/3] Btrfs: Don't return items more than user specified Li Zefan
2010-12-13  9:50 ` [PATCH 3/3] Btrfs: Clean up tree search ioctl code Li Zefan
2010-12-13 18:13 ` Bug in the design of the tree search ioctl API ? [was Re: [PATCH 1/3] Btrfs: Really return keys within specified range] Goffredo Baroncelli
2010-12-14  5:37   ` Li Zefan
2010-12-14 18:16     ` Goffredo Baroncelli
2010-12-15  3:33       ` Li Zefan
2010-12-15  6:53         ` Goffredo Baroncelli
2010-12-15  7:13           ` Li Zefan
2010-12-15 18:48             ` Goffredo Baroncelli
2010-12-16  1:03               ` Li Zefan
2010-12-15 16:14         ` Chris Mason
2010-12-15 18:42           ` Goffredo Baroncelli
2010-12-15 18:51             ` Chris Mason
2010-12-15 19:13               ` Goffredo Baroncelli

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).