linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Mason <chris.mason@oracle.com>
To: kreijack <kreijack@libero.it>
Cc: Li Zefan <lizf@cn.fujitsu.com>,
	linux-btrfs <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 13:51:07 -0500	[thread overview]
Message-ID: <1292438562-sup-7107@think> (raw)
In-Reply-To: <201012151942.23924.kreijack@libero.it>

Excerpts from Goffredo Baroncelli's message of 2010-12-15 13:42:23 -0500:
> On Wednesday, 15 December, 2010, Chris Mason wrote:
> > Excerpts from Li Zefan's message of 2010-12-14 22:33:33 -0500:
> > > > Suppose to have the following sequence keys  [objectid, type, offset]:
> > > > 
> > > > [...]
> > > > 1)    [300, BTRFS_EXTENT_DATA_KEY, xx]
> > > > 2)    [300, BTRFS_INODE_ITEM_KEY, xx]
> > > > 3)    [300, BTRFS_XATTR_ITEM_KEY, xx]
> > > > 4)    [301, BTRFS_EXTENT_DATA_KEY, xx]
> > > > 5)    [301, BTRFS_INODE_ITEM_KEY, xx]
> > > > 7)    [30200, BTRFS_EXTENT_DATA_KEY, xx]
> > > > 8)    [30200, BTRFS_INODE_ITEM_KEY, xx]
> > > > 9)    [30200, BTRFS_XATTR_ITEM_KEY, xx]
> > > > [...]
> > > > 
> > > > 
> > > > Suppose that the buffer is filled between the item 2 and 3. We should 
> restart 
> > > > the search, but how set the min_* key ? Try the following hypothesis
> > > > 
> > > > h1) objectid++, type = 0 -> In the next search the key 3 would be 
> skipped
> > > > h2) objectid asis, type ++, -> in the next search the key 4 would be 
> skipped
> > > > h3) objectid asis, type = 0 -> in the next search the key 1,2,3 would be 
> > > 
> > > h4) objectid asis, type asis, offset++ -> we should get the correct 
> result.
> > 
> > This is the right answer ;).  The problem is that even though our key has
> > 3 distinct parts, and the API makes it look like you have very fine
> > grained control over those three parts, you have to remember to reset
> > them as you iterate between objectids.  It isn't a obvious as it should
> > be.
> > 
> > The current API is a very raw export of how we do the searches in the
> > kernel too.  You can do pretty much anything with it, but we pay with
> > complexity.
> 
> Hi Chris,
> 
> I am a bit confused about your answer.
> 
> The actual API is a bit confused (or almost not "obvious"). An application in 
> order to work properly has to make some adjustment to the min_* fields AND 
> filter the results (because if we tweak with the min_* field, not useful data 
> is returned). Moreover this  means that we move between user-space<->kernel-
> space a lot of unused data (un-necessary context switch).
> 
> On the basis of your answer, it seems that this is ok (please don't consider 
> only the case of listing the subvolumes which is a very simple cases). And 
> nothing have to do.

Well, it's ok in that I wanted the API to be very close to the way
searches are done in the kernel.  I'll definitely agree it isn't
perfect, especially as we hop between objectids or types.

But I don't want to extend it just yet, mostly because we don't have new
applications making use of it.  I'd rather couple any new apis with new
applications that we haven't yet thought of.

Thanks a lot for the time you're spending on review and looking at this.
If you have killer apps that can really make use of new APIs, I'm happy
to start reworking things.

-chris

  reply	other threads:[~2010-12-15 18:51 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
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 [this message]
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=1292438562-sup-7107@think \
    --to=chris.mason@oracle.com \
    --cc=kreijack@libero.it \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    /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).