From patchwork Fri Feb 12 18:32:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 8295231 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AB3FD9F372 for ; Fri, 12 Feb 2016 18:32:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BFEDF20437 for ; Fri, 12 Feb 2016 18:32:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADBDB20439 for ; Fri, 12 Feb 2016 18:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752671AbcBLScU (ORCPT ); Fri, 12 Feb 2016 13:32:20 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:46477 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752567AbcBLScT (ORCPT ); Fri, 12 Feb 2016 13:32:19 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u1CIWEQv025263 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Feb 2016 18:32:14 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u1CIWDHh031011 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 12 Feb 2016 18:32:13 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u1CIWDbY005931; Fri, 12 Feb 2016 18:32:13 GMT Received: from localhost (/24.21.154.84) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Feb 2016 10:32:12 -0800 Date: Fri, 12 Feb 2016 10:32:11 -0800 From: "Darrick J. Wong" To: Dave Chinner Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org, Filipe Manana , fdmanana@kernel.org Subject: [PATCH v2] fstests: generic/158, test dedupe with destination offset past EOF Message-ID: <20160212183211.GH6346@birch.djwong.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Filipe Manana We were testing when the source file offset starts at EOF or beyond, but not when the destination offset is beyond EOF or when the destination offset is smaller than EOF but destination offset plus dedup length is greater than EOF. This is motivated by a bug in btrfs' extent_same (dedup) ioctl where we allowed the destination offset to start at EOF and beyond (and destination offset + length beyond EOF) for the case where the source and destination files are the same (was not allowed for different files used as source and destination). This also made the file's metadata inconsistent when the dedup operation succeeded, which happened when the source range corresponded to a file hole, prealloc extent or a data extent filled with zeroes. The btrfs issue is fixed by the following patch for the linux kernel: "Btrfs: fix extent_same allowing destination offset beyond i_size" Signed-off-by: Filipe Manana [darrick.wong@oracle.com: fix merge conflicts with latest reflink patchbomb] Signed-off-by: Darrick J. Wong --- tests/generic/158 | 10 +++++++++- tests/generic/158.out | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tests/generic/158 b/tests/generic/158 index 0da5daa..dd64562 100755 --- a/tests/generic/158 +++ b/tests/generic/158 @@ -97,9 +97,17 @@ _dedupe_range $testdir1/file1 37 $testdir1/file1 59 23 echo "Try overlapping dedupe" _dedupe_range $testdir1/file1 0 $testdir1/file1 1 $((blksz * 2)) -echo "Try dedupe past EOF" +echo "Try dedupe from past EOF" _dedupe_range $testdir1/file1 $(( (blks + 10) * blksz)) $testdir1/file1 0 $blksz +echo "Try dedupe to past EOF, destination offset beyond EOF" +_dedupe_range $testdir1/file1 0 $testdir1/file1 $(( (blks + 10) * blksz)) \ + $blksz + +echo "Try dedupe to past EOF, destination offset behind EOF" +_dedupe_range $testdir1/file1 0 $testdir1/file1 $(( (blks - 1) * blksz)) \ + $((blksz * 2)) + echo "Try to dedupe a dir" _dedupe_range $testdir1/dir1 0 $testdir1/file2 0 $blksz diff --git a/tests/generic/158.out b/tests/generic/158.out index 7f88403..9b82ddf 100644 --- a/tests/generic/158.out +++ b/tests/generic/158.out @@ -7,7 +7,11 @@ Try unaligned dedupe dedupe: Invalid argument Try overlapping dedupe dedupe: Invalid argument -Try dedupe past EOF +Try dedupe from past EOF +dedupe: Invalid argument +Try dedupe to past EOF, destination offset beyond EOF +dedupe: Invalid argument +Try dedupe to past EOF, destination offset behind EOF dedupe: Invalid argument Try to dedupe a dir XFS_IOC_FILE_EXTENT_SAME: Is a directory