From: Goffredo Baroncelli <kreijack@libero.it>
To: Hugo Mills <hugo@carfax.org.uk>, linux-btrfs@vger.kernel.org
Subject: Re: subvolumes missing from "btrfs subvolume list" output
Date: Wed, 29 Jun 2011 22:41:18 +0200 [thread overview]
Message-ID: <4E0B8DEE.9010202@libero.it> (raw)
In-Reply-To: <20110629164741.GA11170@carfax.org.uk>
Hi Hugo
On 06/29/2011 06:47 PM, Hugo Mills wrote:
> On Wed, Jun 29, 2011 at 12:16:06PM -0400, Josef Bacik wrote:
>> On 06/29/2011 11:00 AM, Stephane Chazelas wrote:
>>> 2011-06-29 15:37:47 +0100, Stephane Chazelas:
>>> [...]
>>>> I found
>>>> http://thread.gmane.org/gmane.comp.file-systems.btrfs/8123/focus=8208
>>>>
>>>> which looks like the same issue, with Li Zefan saying he had a
>>>> fix, but I couldn't find any mention that it was actually fixed.
>>>>
>>>> Has anybody got any update on that?
>>> [...]
>>>
>>> I've found
>>> http://thread.gmane.org/gmane.comp.file-systems.btrfs/8232
>>>
>>> but no corresponding fix or ioctl.c
>>> http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-unstable.git;a=history;f=fs/btrfs/ioctl.c
>>>
>>> I'm under the impression that the issue has been forgotten
>>> about.
>>>
>>> From what I managed to gather though, it seems that what's on
>>> disk is correct, it's just the ioctl and/or "btrfs sub list"
>>> that's wrong. Am I right?
>>
>> Yeah, did you apply the patch from that thread and verify that it fixes
>> your problem? Thanks,
>
> Note that changing this API will probably break btrfs-gui's listing
> of subvolumes...
>
> The issue with that patch is that there are two distinct behaviours
> that people want or expect with the tree-search ioctl:
>
> (A) Return all items with keys which collate linearly between
> (min_objectid, min_type, min_offset) and
> (max_objectid, max_type, max_offset)
>
> i.e. treating keys as indivisible objects and sorting lexically,
> as the trees do.
>
> (B) Return all items with keys (i, t, o) which fulfil the criteria
> (min_objectid <= i <= max_objectid,
> min_type <= t <= max_type,
> min_offset <= o <= max_offset)
>
> i.e. treating keys as 3-tuples, and selecting from a rectilinear
> subsset of the tuple space, which is natural for some
> applications.
>
> Clearly, we can't do both with the same call (except for some
> limited cases (*)). However, different users expect different
> behaviours. The current behaviour is (A), which is the "natural"
> behaviour for tree searches within the btrfs code, and is (IMO) the
> right thing to be doing for an API like this.
looking at the function copy_to_sk() it seems that the key advance is
made on the following logic:
if (key->offset < (u64)-1 && key->offset < sk->max_offset)
key->offset++;
else if (key->type < (u8)-1 && key->type < sk->max_type) {
key->offset = 0;
key->type++;
} else if (key->objectid < (u64)-1 &&
key->objectid < sk->max_objectid) {
key->offset = 0;
key->type = 0;
key->objectid++;
which to me it seems a bit different from the case A. In fact (if I read
the code correctly) *both* the following condition are always true
(min_objectid, min_type, min_offset) <= key and
key < (max_objectid, max_type, max_offset) and
(key_objectid <= max_objectid and
key_type <= max_type and
key_offset <= max_offset)
In conclusion the code is an hybrid between A and B.
>
> It sounds to me like the user of the API needs to be fixed, not the
> ioctl itself -- possibly the author of the subvol scanning code
> assumed (B) when they were getting (A). Note that there is at least
> one other user of the ioctl outside btrfs-progs: btrfs-gui, which uses
> the ioctl for several things, one of which is enumerating subvolumes
> as btrfs-progs does.
>
> It should be possible to write an additional ioctl for behaviour
> (B) which contains both min and max limits on each element of the key
> 3-tuple, *and* the current search state. That would reduce developer
> confusion (given appropriate comments or documentation to explain what
> the difference between the two is). However, I'm not sufficiently
> convinced that it's actually necessary right now. I may change my tune
> after I've started doing some of the more complex bits I'd thought of
> doing with btrfs-gui, but for now, it's perfectly possible to use the
> existing API without too much hassle.
>
> Hugo.
>
> (*) The limited cases where both behaviours return the same set of
> keys are:
>
> (i_0, 0, 0) to (i_1, -1UL, -1UL)
> (i, t_0, 0) to (i, t_1, -1UL)
> (i, t, o_0) to (i, t, o_1)
>
next prev parent reply other threads:[~2011-06-29 20:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-29 14:37 subvolumes missing from "btrfs subvolume list" output Stephane Chazelas
2011-06-29 15:00 ` Stephane Chazelas
2011-06-29 16:16 ` Josef Bacik
2011-06-29 16:47 ` Hugo Mills
2011-06-29 16:50 ` Hugo Mills
2011-06-29 20:41 ` Goffredo Baroncelli [this message]
2011-06-30 0:47 ` Li Zefan
2011-06-30 8:40 ` Stephane Chazelas
2011-06-30 9:18 ` Andreas Philipp
2011-06-30 10:43 ` Stephane Chazelas
2011-06-30 10:52 ` Andreas Philipp
2011-06-30 10:54 ` Hugo Mills
2011-06-30 10:58 ` Hugo Mills
2011-06-30 12:34 ` [PATCH] [btrfs-progs integration] incorrect argument checking for "btrfs sub snap -r" Stephane Chazelas
2011-06-30 13:07 ` Hugo Mills
2011-06-30 20:55 ` Andreas Philipp
2011-06-30 21:09 ` Hugo Mills
2011-07-01 8:26 ` [PATCH] " Stephane Chazelas
2011-07-01 10:13 ` Andreas Philipp
2011-07-01 10:42 ` Hugo Mills
2011-07-01 12:55 ` Stephane Chazelas
2011-08-11 4:30 ` Tsutomu Itoh
2011-08-11 6:45 ` Andreas Philipp
2011-08-11 12:40 ` Hugo Mills
2011-07-01 1:08 ` subvolumes missing from "btrfs subvolume list" output Li Zefan
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=4E0B8DEE.9010202@libero.it \
--to=kreijack@libero.it \
--cc=hugo@carfax.org.uk \
--cc=kreijack@inwind.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 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).