linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: dsterba@suse.cz, Omar Sandoval <osandov@osandov.com>,
	linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: FIDEDUPERANGE with src_length == 0
Date: Thu, 14 Jul 2016 11:06:25 -0700	[thread overview]
Message-ID: <20160714180625.GB23888@birch.djwong.org> (raw)
In-Reply-To: <20160713131938.GK10595@twin.jikos.cz>

On Wed, Jul 13, 2016 at 03:19:38PM +0200, David Sterba wrote:
> On Tue, Jul 12, 2016 at 10:26:43PM -0700, Darrick J. Wong wrote:
> > On Mon, Jul 11, 2016 at 05:35:37PM -0700, Omar Sandoval wrote:
> > > Hey, Darrick,
> > > 
> > > generic/182 is failing on Btrfs for me with the following output:
> > > 
> > > --- tests/generic/182.out       2016-07-07 19:51:54.000000000 -0700
> > > +++ /tmp/fixxfstests/xfstests/results//generic/182.out.bad      2016-07-11 17:28:28.230039216 -0700
> > > @@ -1,12 +1,10 @@
> > >  QA output created by 182
> > >  Create the original files
> > > -dedupe: Extents did not match.
> > >  f4820540fc0ac02750739896fe028d56  TEST_DIR/test-182/file1
> > >  69ad53078a16243d98e21d9f8704a071  TEST_DIR/test-182/file2
> > >  69ad53078a16243d98e21d9f8704a071  TEST_DIR/test-182/file2.chk
> > >  Compare against check files
> > >  Make the original file almost dedup-able
> > > -dedupe: Extents did not match.
> > >  f4820540fc0ac02750739896fe028d56  TEST_DIR/test-182/file1
> > >  158d4e3578b94b89cbb44493a2110fb9  TEST_DIR/test-182/file2
> > >  158d4e3578b94b89cbb44493a2110fb9  TEST_DIR/test-182/file2.chk
> > > 
> > > It looks like that test is checking that a dedupe with length == 0 is
> > > treated as a dedupe to EOF, but Btrfs doesn't do that [1]. As far as I
> > > can tell, it never did, but maybe I'm just confused. What was the
> > > behavior when you introduced that test? That seems like a reasonable
> > > thing to do, but I wanted to clear this up before changing/fixing Btrfs.
> > 
> > It's a shortcut that we're introducing in the upcoming XFS implementation,
> > since it shares the same back end as clone/clonerange, which both have
> > this behavior.
> 
> The support for zero length does not seem to be mentioned anywhere with
> the dedupe range ioctl [1], so the current implemetnation is "up to
> spec". That it should be valid is hidden in clone_verify_area where a
> zero length is substituted with OFFSET_MAX
> 
> http://lxr.free-electrons.com/source/fs/read_write.c#L1607
> 
> So it looks like it's up to the implementation in the filesystem to
> handle that. As the btrfs ioctl was extent-based, a zero length extent
> does not make sense, so this case was not handled. But in your patch
> 
> 2b3909f8a7fe94e0234850aa9d120cca15b6e1f7
> btrfs: use new dedupe data function pointer
> 
> it was suddenly expected to work. So the missing bits are either 'not
> supported' for zero length or actually implement iteration over the
> whole file.
> 
> [1] https://www.mankier.com/2/ioctl_fideduperange

Well, we can't change the semantics now because there could be programs that
aren't expecting a nonzero return from a length == 0 dedupe, so like Christoph
said, I'll just change generic/182 and make the VFS wrapper emulate the btrfs
behavior so that any subsequent implementation won't hit this.

I'll update the clone/clonerange manpages to mention the 0 -> EOF behavior.
Would've been awesome if anyone had bothered to document the damn ioctls
and write tests to call out these subtleties rather than leave the next
implementer to clean up all the technical debt.  I dunno, maybe there /is/
a secret cache of btrfs regression tests somewhere that I haven't found.
<grumble>

--D

  reply	other threads:[~2016-07-14 18:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-12  0:35 FIDEDUPERANGE with src_length == 0 Omar Sandoval
2016-07-13  5:26 ` Darrick J. Wong
2016-07-13 13:19   ` David Sterba
2016-07-14 18:06     ` Darrick J. Wong [this message]
2016-07-14 18:12       ` Chris Mason
2016-07-14 18:16         ` Omar Sandoval
2016-07-15 16:54           ` Darrick J. Wong
2016-08-01 19:32           ` Darrick J. Wong
2016-07-14  2:47   ` Christoph Hellwig

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=20160714180625.GB23888@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=osandov@osandov.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).