From patchwork Sat May 31 01:17:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4274581 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 10D6BBEEA7 for ; Sat, 31 May 2014 00:17:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C31EE20382 for ; Sat, 31 May 2014 00:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C165A20379 for ; Sat, 31 May 2014 00:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934856AbaEaARw (ORCPT ); Fri, 30 May 2014 20:17:52 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:47934 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934625AbaEaARv (ORCPT ); Fri, 30 May 2014 20:17:51 -0400 Received: by mail-wg0-f43.google.com with SMTP id l18so2723068wgh.14 for ; Fri, 30 May 2014 17:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=KV7qLaVtF7DAYc85Pb2wzoG1eBSq1UBfkyIjycWCdJs=; b=xskqX3AYFGQbxaSBtm4SCEin4+Nl32K2T8gv/3qSN7lvbKUxbURaApxlethDp+aMe6 TUhp9uOOkhO4Sn2sFRDD9pDXOuSB72AJODaa0DHFq8qxrhyTkFEjRy1Hmh3HRmYVkh06 UVM3+USLVcNIqWBQbpI6OEzy1KOZ2nVxu58UBmLqmdH8KurZMVmJ9E4lwwYjbYnFaL/O IGvY5TtEeGKvnPQD8tOK8k7M1EoGCdkFUS+vsQSOSmKWHA2jYq+RIEJOYdRmeeczg3af /IYyZg/hZNKw3W/kNN+vfz53n/vohJ7m30qvswb9iU+U3LP4qfOHYUnfqIS1Nrgf+v+a Q/0g== X-Received: by 10.194.24.36 with SMTP id r4mr27424058wjf.39.1401495470128; Fri, 30 May 2014 17:17:50 -0700 (PDT) Received: from debian-vm3.lan (bl13-158-17.dsl.telepac.pt. [85.246.158.17]) by mx.google.com with ESMTPSA id m1sm10020116wib.20.2014.05.30.17.17.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 May 2014 17:17:49 -0700 (PDT) From: Filipe David Borba Manana To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe David Borba Manana Subject: [PATCH] xfstests: add test for btrfs cloning with file holes Date: Sat, 31 May 2014 02:17:33 +0100 Message-Id: <1401499053-11162-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 Regression test for the btrfs ioctl clone operation when the source range contains hole(s) and the FS has the NO_HOLES feature enabled (file holes don't need file extent items in the btree to represent them). This issue is fixed by the following linux kernel btrfs patch: Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled Signed-off-by: Filipe David Borba Manana --- tests/btrfs/055 | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/055.out | 43 ++++++++++++++++++++++ tests/btrfs/group | 1 + 3 files changed, 144 insertions(+) create mode 100755 tests/btrfs/055 create mode 100644 tests/btrfs/055.out diff --git a/tests/btrfs/055 b/tests/btrfs/055 new file mode 100755 index 0000000..7241b66 --- /dev/null +++ b/tests/btrfs/055 @@ -0,0 +1,100 @@ +#! /bin/bash +# FS QA Test No. btrfs/055 +# +# Regression test for the btrfs ioctl clone operation when the source range +# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes +# don't need file extent items in the btree to represent them). +# +# This issue is fixed by the following linux kernel btrfs patch: +# +# Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 Filipe Manana. 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` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + rm -fr $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_btrfs_cloner +_need_to_be_root + +rm -f $seqres.full + +test_btrfs_clone_with_holes() +{ + _scratch_mkfs "$1" >/dev/null 2>&1 + _scratch_mount $MOUNT_OPTIONS + + # Create a file with 4 extents and 1 hole, all with a size of 8Kb each. + $XFS_IO_PROG -f -c "pwrite -S 0x01 -b 8192 0 8192" $SCRATCH_MNT/foo \ + | _filter_xfs_io + sync + $XFS_IO_PROG -c "pwrite -S 0x02 -b 8192 8192 8192" $SCRATCH_MNT/foo \ + | _filter_xfs_io + sync + # After the following write we get a hole in the range [16384, 24576[ + $XFS_IO_PROG -c "pwrite -S 0x04 -b 8192 24576 8192" $SCRATCH_MNT/foo \ + | _filter_xfs_io + sync + $XFS_IO_PROG -c "pwrite -S 0x05 -b 8192 32768 8192" $SCRATCH_MNT/foo \ + | _filter_xfs_io + sync + + # Clone destination file, 1 extent of 64kb. + $XFS_IO_PROG -f -c "pwrite -S 0xff -b 64536 0 64536" $SCRATCH_MNT/bar \ + | _filter_xfs_io + sync + + # Clone 2nd extent, 8Kb hole and 3rd extent of foo into bar. + $CLONER_PROG -s 8192 -d 0 -l 24576 $SCRATCH_MNT/foo $SCRATCH_MNT/bar + + # Verify both extents and the hole were cloned. + od -t x1 $SCRATCH_MNT/bar + + # Verify that there are no consistency errors. + _check_scratch_fs +} + +echo "Testing without the NO_HOLES feature" +test_btrfs_clone_with_holes + +_scratch_unmount + +echo "Testing with the NO_HOLES feature enabled" +test_btrfs_clone_with_holes "-O no-holes" + +status=0 +exit diff --git a/tests/btrfs/055.out b/tests/btrfs/055.out new file mode 100644 index 0000000..faa0477 --- /dev/null +++ b/tests/btrfs/055.out @@ -0,0 +1,43 @@ +QA output created by 055 +Testing without the NO_HOLES feature +wrote 8192/8192 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 8192/8192 bytes at offset 8192 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 8192/8192 bytes at offset 24576 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 8192/8192 bytes at offset 32768 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 64536/64536 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 +* +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +* +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 +* +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff +* +0176020 ff ff ff ff ff ff ff ff +0176030 +Testing with the NO_HOLES feature enabled +wrote 8192/8192 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 8192/8192 bytes at offset 8192 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 8192/8192 bytes at offset 24576 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 8192/8192 bytes at offset 32768 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 64536/64536 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 +* +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +* +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 +* +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff +* +0176020 ff ff ff ff ff ff ff ff +0176030 diff --git a/tests/btrfs/group b/tests/btrfs/group index b668485..2c10c5b 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -57,3 +57,4 @@ 052 auto quick 053 auto quick 054 auto quick +055 auto quick