From patchwork Tue Nov 20 21:57:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10691335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B7B41709 for ; Tue, 20 Nov 2018 21:57:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B41B28723 for ; Tue, 20 Nov 2018 21:57:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FC022ACBC; Tue, 20 Nov 2018 21:57:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB89828801 for ; Tue, 20 Nov 2018 21:57:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725940AbeKUI3J (ORCPT ); Wed, 21 Nov 2018 03:29:09 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:49298 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbeKUI3I (ORCPT ); Wed, 21 Nov 2018 03:29:08 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAKLrxaq153741; Tue, 20 Nov 2018 21:57:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=1Ze1LB78qP6LeL8S6UIqFhZzLvSPDPRUIit5Fg3YneM=; b=k5CPhBLTrmzXmKklQoOdtcjZuCkHtwpveqGT3S+8xmEaPoqLykNbb5FgOp+UQpD4ejhr iyp6HHO1jDYh3s61UzcPzLmpdPinr96SMf7YzwXZviBvR9rnthBhRTDKbBf8BQLi86dl 4N5iiUmNd2F0zKX0JYQvttsvMUZOJqYMyx8u5enOLo1aD+GJeaKUKYySh7dz8Ev2B3mG lz2UH4Z33DeE58t1BLUnrbdXKMRDdUOtj0DWv+td7yLfviMWaCEszkxED6c33rgr4c7E BLJDaNyZwgFvQRdTmSkeaLaxF01ot6lyJLAWias1olaPmon7UpmaeO15rLe+lf1gte7s pQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2ntadtxdg0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Nov 2018 21:57:47 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wAKLvkgS018916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Nov 2018 21:57:46 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wAKLvjat020856; Tue, 20 Nov 2018 21:57:45 GMT Received: from localhost (/10.145.178.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Nov 2018 13:57:45 -0800 Subject: [PATCH 09/10] fsx: clean up copy/dedupe file range support. From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, Dave Chinner Date: Tue, 20 Nov 2018 13:57:45 -0800 Message-ID: <154275106538.8611.5991693163854449275.stgit@magnolia> In-Reply-To: <154275100143.8611.10235098565750994724.stgit@magnolia> References: <154275100143.8611.10235098565750994724.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9083 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811200192 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dave Chinner 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 Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- ltp/fsx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index ec3defad..cea765d8 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -1452,7 +1452,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"); @@ -1486,6 +1490,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");