All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: guaneryu@gmail.com, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org,
	Dave Chinner <dchinner@redhat.com>
Subject: [PATCH 5/6] fsx: clean up copy/dedupe file range support.
Date: Tue, 13 Nov 2018 15:40:11 -0800	[thread overview]
Message-ID: <154215241163.21151.5676816385137982668.stgit@magnolia> (raw)
In-Reply-To: <154215237717.21151.11976488103599724788.stgit@magnolia>

From: Dave Chinner <dchinner@redhat.com>

copy_file_range() needs to obey read/write constraints otherwise is
blows up when direct IO is used.

FIDEDUPERANGE has a completely screwed up API for error reporting.
The ioctl succeeds even if dedupe fails, so you have to check
every individual dedupe operations for failure. Without this, dedupe
"succeeds" on kernels filesystems that don't even support dedupe...

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 ltp/fsx.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)


diff --git a/ltp/fsx.c b/ltp/fsx.c
index 3161ba12..f6cc6e95 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -1383,7 +1383,11 @@ do_dedupe_range(unsigned offset, unsigned length, unsigned dest)
 	fdr->info[0].dest_fd = fd;
 	fdr->info[0].dest_offset = dest;
 
-	if (ioctl(fd, FIDEDUPERANGE, fdr) == -1) {
+	if (ioctl(fd, FIDEDUPERANGE, fdr) == -1 ||
+	    fdr->info[0].status < 0) {
+		if (fdr->info[0].status < 0)
+			errno = -fdr->info[0].status;
+
 		if (errno == EOPNOTSUPP || errno == ENOTTY) {
 			if (!quiet && testcalls > simulatedopcount)
 				prt("skipping unsupported dedupe range\n");
@@ -1417,6 +1421,11 @@ do_copy_range(unsigned offset, unsigned length, unsigned dest)
 	loff_t o1, o2;
 	ssize_t nr;
 
+	offset -= offset % readbdy;
+	dest -= dest % writebdy;
+	if (o_direct)
+		length -= length % readbdy;
+
 	if (length == 0) {
 		if (!quiet && testcalls > simulatedopcount)
 			prt("skipping zero length copy range\n");

  parent reply	other threads:[~2018-11-14  9:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-13 23:39 [PATCH 0/6] xfstests: add copy/dedupe/clone to fsx/fsstress Darrick J. Wong
2018-11-13 23:39 ` [PATCH 1/6] fsx: add clone range Darrick J. Wong
2018-11-16 19:26   ` Darrick J. Wong
2018-11-18 13:51     ` Eryu Guan
2018-11-20  2:27       ` Darrick J. Wong
2018-11-20  2:57         ` Eryu Guan
2018-11-13 23:39 ` [PATCH 2/6] fsx: add FIDEDUPERANGE support Darrick J. Wong
2018-11-13 23:39 ` [PATCH 3/6] fsstress: add copy_file_range support Darrick J. Wong
2018-11-13 23:40 ` [PATCH 4/6] fsx: " Darrick J. Wong
2018-11-13 23:40 ` Darrick J. Wong [this message]
2018-11-13 23:40 ` [PATCH 6/6] common/dump: disable copyrange Darrick J. Wong
2018-11-19  5:22 ` [PATCH 0/6] xfstests: add copy/dedupe/clone to fsx/fsstress Zorro Lang
2018-11-19 10:45   ` Zorro Lang
2018-11-19 16:38     ` Darrick J. Wong
2018-11-19 21:29       ` Dave Chinner
2018-11-23  7:33       ` Zorro Lang
2018-11-24 16:59         ` Darrick J. Wong
2018-11-25 16:19           ` Eryu Guan
2018-11-26 20:38             ` Darrick J. Wong
2018-11-28  2:57               ` Eryu Guan
2018-11-28  5:54                 ` Darrick J. Wong
2018-11-29  1:52                 ` Dave Chinner

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=154215241163.21151.5676816385137982668.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=dchinner@redhat.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-xfs@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.