From patchwork Tue Jul 2 09:33:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koen De Wit X-Patchwork-Id: 2811511 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 02413BF4A1 for ; Tue, 2 Jul 2013 09:34:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1CE120153 for ; Tue, 2 Jul 2013 09:34:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 85E0C20152 for ; Tue, 2 Jul 2013 09:34:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932332Ab3GBJes (ORCPT ); Tue, 2 Jul 2013 05:34:48 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:16993 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750851Ab3GBJer (ORCPT ); Tue, 2 Jul 2013 05:34:47 -0400 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r629YhXI002218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 2 Jul 2013 09:34:44 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r629YgLi014910 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 2 Jul 2013 09:34:43 GMT Received: from abhmt115.oracle.com (abhmt115.oracle.com [141.146.116.67]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r629YguE028048; Tue, 2 Jul 2013 09:34:42 GMT Received: from [192.168.0.247] (/178.116.134.76) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 02 Jul 2013 02:34:41 -0700 Message-ID: <51D29E67.5020204@oracle.com> Date: Tue, 02 Jul 2013 11:33:27 +0200 From: Koen De Wit User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11 MIME-Version: 1.0 To: Eric Sandeen , xfs@oss.sgi.com, linux-btrfs@vger.kernel.org Subject: [PATCH v3] xfstests: btrfs/311: sparse copy between different filesystems/mountpoints X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 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 Thanks Eric for reviewing and improving testcases btrfs/306, 309, 310 and 311 ! I had just one comment: on line 70 the output was redirected to $seqres.fll instead of $seqres.full. Corrected patch below. # Check if creating a sparse copy ("reflink") of a file on btrfs # expectedly fails when it's done between different filesystems or # different mount points of the same filesystem. # # For both situations, these actions are executed: # - Copy a file with the reflink=auto option. # A normal copy should be created. # - Copy a file with the reflink=always option. Should result in error, # no file should be created. [sandeen: mostly cosmetic changes] Originally submitted as: xfstests: 301: sparse copy between different filesystems/mountpoints on btrfs Version 3: fixing wrapped patch. Signed-off-by: Koen De Wit Signed-off-by: Eric Sandeen --- tests/btrfs/311 | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/311.out | 15 +++++++ tests/btrfs/group | 4 ++ 3 files changed, 126 insertions(+), 0 deletions(-) create mode 100755 tests/btrfs/311 create mode 100644 tests/btrfs/311.out diff --git a/tests/btrfs/311 b/tests/btrfs/311 new file mode 100755 index 0000000..56ebd58 --- /dev/null +++ b/tests/btrfs/311 @@ -0,0 +1,107 @@ +#! /bin/bash +# FS QA Test No. 311 +# +# Check if creating a sparse copy ("reflink") of a file on btrfs +# expectedly fails when it's done between different filesystems or +# different mount points of the same filesystem. +# +# For both situations, these actions are executed: +# - Copy a file with the reflink=auto option. +# A normal copy should be created. +# - Copy a file with the reflink=always option. Should result in error, +# no file should be created. +# +#----------------------------------------------------------------------- +# Copyright (c) 2013, Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + umount $SCRATCH_MNT &>/dev/null + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs btrfs +_supported_os Linux + +_require_scratch +_require_cp_reflink + +SOURCE_DIR=$TEST_DIR/test-$seq +CROSS_DEV_DIR=$SCRATCH_MNT/test-$seq +# mount point & target for twice-mounted device +TEST_DIR2=$TEST_DIR/mount2 +DUAL_MOUNT_DIR=$SCRATCH_MNT/test-bis-$seq + +rm -rf $SOURCE_DIR +mkdir $SOURCE_DIR + +rm -f $seqres.full + +_scratch_mkfs +$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $SOURCE_DIR/original \ + >> $seqres.full + +_filter_testdirs() +{ + _filter_test_dir | _filter_scratch +} + +_create_reflinks_to() +{ + # auto reflink, should fall back to non-reflink + rm -rf $1; mkdir $1 + echo "reflink=auto:" + cp --reflink=auto $SOURCE_DIR/original $1/copy + md5sum $SOURCE_DIR/original | _filter_testdirs + md5sum $1/copy | _filter_testdirs + + # always reflink, should fail outright + rm -rf $1; mkdir $1 + echo "reflink=always:" + cp --reflink=always $SOURCE_DIR/original $1/copyfail 2>&1 | _filter_testdirs + + # The failed target actually gets created by cp: + ls $1/copyfail | _filter_testdirs +} + +echo "test reflinks across different devices" +_scratch_mount +_create_reflinks_to $CROSS_DEV_DIR +_scratch_unmount + +echo "test reflinks across different mountpoints of same device" +mount $TEST_DEV $SCRATCH_MNT || _fail "Couldn't double-mount $TEST_DEV" +_create_reflinks_to $DUAL_MOUNT_DIR +umount $SCRATCH_MNT + +# success, all done +status=0 +exit diff --git a/tests/btrfs/311.out b/tests/btrfs/311.out new file mode 100644 index 0000000..210727b --- /dev/null +++ b/tests/btrfs/311.out @@ -0,0 +1,15 @@ +QA output created by 311 +test reflinks across different devices +reflink=auto: +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-311/original +42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/test-311/copy +reflink=always: +cp: failed to clone `SCRATCH_MNT/test-311/copyfail': Invalid cross-device link +SCRATCH_MNT/test-311/copyfail +test reflinks across different mountpoints of same device +reflink=auto: +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-311/original +42d69d1a6d333a7ebdf64792a555e392 SCRATCH_MNT/test-bis-311/copy +reflink=always: +cp: failed to clone `SCRATCH_MNT/test-bis-311/copyfail': Invalid cross-device link +SCRATCH_MNT/test-bis-311/copyfail diff --git a/tests/btrfs/group b/tests/btrfs/group index bc6c256..c897118 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -12,3 +12,4 @@ 308 auto quick reflink 309 auto quick reflink 310 auto quick reflink +311 auto quick reflink