From: Li Zefan <lizf@cn.fujitsu.com>
To: kreijack@libero.it
Cc: linux-btrfs@vger.kernel.org
Subject: Re: Bug in the design of the tree search ioctl API ? [was Re: [PATCH 1/3] Btrfs: Really return keys within specified range]
Date: Wed, 15 Dec 2010 15:13:04 +0800 [thread overview]
Message-ID: <4D086A80.6020904@cn.fujitsu.com> (raw)
In-Reply-To: <201012150753.37204.kreijack@libero.it>
Goffredo Baroncelli wrote:
> On Wednesday, 15 December, 2010, Li Zefan wrote:
>> h4) objectid asis, type asis, offset++ -> we should get the correct result.
>
> This fix the problem of the "missing subvolume". But for the other case
> (searching for more than one type) the problem still here.
>
I don't think so. And the above "h4" has showed how we search for more
than one type.
The generic userland code for next search is:
/* this is in essence the same as how we advance key in kernel code */
if (sk->min_offset < (u64)-1 && sk->min_offset < sk->max_offset)
sk->min_offset++;
else if (sk->min_type < (u8)-1 && sk->min_type < sk->max_type) {
sk->min_offset = 0;
sk->min_type++;
} else if (sk->min_objectid < (u64)-1 && sk->min_objectid < sk->max_objectid){
sk->min_offset = 0;
sk->min_type = 0;
sk->min_objectid++;
} else
break;
ioctl(...);
for (i = 0; i < nr_items; i++) {
if (!filter(items[i]))
continue;
/* process this item */
...
}
>> because the current ioctl uses min_{x,y,z} and max_{x,y,z} as start_key and
>> end_key, and it returns all keys that falls in [start_key, end_key].
>>
>> So this btrfs-progs patch should fix missing subvolumes in the output of
>> "subvolume list":
>>
>> diff --git a/btrfs-list.c b/btrfs-list.c
>> index 93766a8..1b9ea45 100644
>> --- a/btrfs-list.c
>> +++ b/btrfs-list.c
>> @@ -620,7 +620,10 @@ int list_subvols(int fd)
>> /* this iteration is done, step forward one root for the
> next
>> * ioctl
>> */
>> - if (sk->min_objectid < (u64)-1) {
>> + if (sk->min_type < BTRFS_ROOT_BACKREF_KEY) {
>> + sk->min_type = BTRFS_ROOT_BACKREF_KEY;
>> + sk->min_offset = 0;
>> + } else if (sk->min_objectid < (u64)-1) {
>> sk->min_objectid++;
>> sk->min_type = BTRFS_ROOT_BACKREF_KEY;
>> sk->min_offset = 0;
>>
>
>
next prev parent reply other threads:[~2010-12-15 7:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=4D086A80.6020904@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=kreijack@libero.it \
--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.