From patchwork Tue Feb 25 18:26:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 3718361 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0BD439F2F7 for ; Tue, 25 Feb 2014 18:27:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC570201ED for ; Tue, 25 Feb 2014 18:27:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7ADB2017E for ; Tue, 25 Feb 2014 18:27:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753376AbaBYS1J (ORCPT ); Tue, 25 Feb 2014 13:27:09 -0500 Received: from mail-wg0-f42.google.com ([74.125.82.42]:43713 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752660AbaBYS1H (ORCPT ); Tue, 25 Feb 2014 13:27:07 -0500 Received: by mail-wg0-f42.google.com with SMTP id x13so746089wgg.1 for ; Tue, 25 Feb 2014 10:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=OgM+CMYU45WaYch7WEDINNITGD6nrSQKIFbRc+S/igk=; b=rIj3C04YcUjXkhP5TzArLnp9mCcpfcpZ/jA42u+wVTq/ZIupClqU5TDwMDfOQBzdkw 5m6wc5EAHSiUTU0ZubKOtPNWKdGHxuj6L20lyS3V8kberFXDqAH7X/Kn8KGJkpkzPqDR crwqgmXjyUHsvlIzm/Nxbm1Rn9E7Nnk2zYecL2kP9b43UUKZIvSBVYSoaVx8ctGtWf2N G0T8srZd5EQxYq2vLMV5FqZ2vAEgC7tbKdTb+a8Q+8bpTiLyfDwDj7t5PsDJAhQiexre /Ww9Sz2s/b8loREsM3vvnT3SYaxGqcG0PNgl9SzWfLFqsa9lwch/gWAjqZRWTl3E8h58 oesA== X-Received: by 10.194.219.132 with SMTP id po4mr26163525wjc.7.1393352826041; Tue, 25 Feb 2014 10:27:06 -0800 (PST) Received: from storm-desktop.lan (bl9-170-181.dsl.telepac.pt. [85.242.170.181]) by mx.google.com with ESMTPSA id s12sm42295450wju.13.2014.02.25.10.27.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Feb 2014 10:27:05 -0800 (PST) From: Filipe David Borba Manana To: xfs@oss.sgi.com Cc: linux-btrfs@vger.kernel.org, Filipe David Borba Manana Subject: [PATCH] xfstests: add test for btrfs-progs restore feature Date: Tue, 25 Feb 2014 18:26:56 +0000 Message-Id: <1393352816-26065-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.7.9.5 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.8 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 This is a regression test to verify that the restore feature of btrfs-progs is able to correctly recover files that have compressed extents, specially when the respective file extent items have a non-zero data offset field. This issue is fixed by the following btrfs-progs patch: Btrfs-progs: fix restore dealing with compressed extents Signed-off-by: Filipe David Borba Manana --- tests/btrfs/043 | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/043.out | 40 ++++++++++++++++++++ tests/btrfs/group | 1 + 3 files changed, 146 insertions(+) create mode 100755 tests/btrfs/043 create mode 100644 tests/btrfs/043.out diff --git a/tests/btrfs/043 b/tests/btrfs/043 new file mode 100755 index 0000000..7a15aeb --- /dev/null +++ b/tests/btrfs/043 @@ -0,0 +1,105 @@ +#! /bin/bash +# FS QA Test No. btrfs/043 +# +# Test that btrfs-progs' restore command is able to correctly recover files +# that have compressed extents, specially when the respective file extent +# items have a non-zero data offset field. +# +# This issue is fixed by the following btrfs-progs patch: +# +# Btrfs-progs: fix restore dealing with compressed extents +# +#----------------------------------------------------------------------- +# 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 +_need_to_be_root + +rm -f $seqres.full + +test_btrfs_restore() +{ + if [ -z $1 ] + then + OPTIONS="" + else + OPTIONS="-o compress-force=$1" + fi + _scratch_mkfs >/dev/null 2>&1 + _scratch_mount $OPTIONS + + $XFS_IO_PROG -f -c "pwrite -S 0xff -b 100000 0 100000" \ + $SCRATCH_MNT/foo | _filter_xfs_io + + # Ensure a single file extent item is persisted. + _run_btrfs_util_prog filesystem sync $SCRATCH_MNT + + $XFS_IO_PROG -c "pwrite -S 0xaa -b 100000 100000 100000" \ + $SCRATCH_MNT/foo | _filter_xfs_io + + # Now ensure a second one is created (and not merged with previous one). + _run_btrfs_util_prog filesystem sync $SCRATCH_MNT + + # Make the extent item be split into several ones, each with a data + # offset field != 0 + $XFS_IO_PROG -c "pwrite -S 0x1e -b 2 10000 2" $SCRATCH_MNT/foo \ + | _filter_xfs_io + $XFS_IO_PROG -c "pwrite -S 0xd0 -b 11 33000 11" $SCRATCH_MNT/foo \ + | _filter_xfs_io + $XFS_IO_PROG -c "pwrite -S 0xbc -b 100 99000 100" $SCRATCH_MNT/foo \ + | _filter_xfs_io + + md5sum $SCRATCH_MNT/foo | _filter_scratch + + _scratch_unmount + _check_scratch_fs + + _run_btrfs_util_prog restore $SCRATCH_DEV $tmp + md5sum $tmp/foo | cut -d ' ' -f 1 +} + +mkdir $tmp +echo "Testing restore of file compressed with lzo" +test_btrfs_restore "lzo" +echo "Testing restore of file compressed with zlib" +test_btrfs_restore "zlib" +echo "Testing restore of file without any compression" +test_btrfs_restore + +status=0 +exit diff --git a/tests/btrfs/043.out b/tests/btrfs/043.out new file mode 100644 index 0000000..d22e4ce --- /dev/null +++ b/tests/btrfs/043.out @@ -0,0 +1,40 @@ +QA output created by 043 +Testing restore of file compressed with lzo +wrote 100000/100000 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 100000/100000 bytes at offset 100000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 2/2 bytes at offset 10000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 11/11 bytes at offset 33000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 100/100 bytes at offset 99000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +67edd038aaa42adb5a1aa78f2eb1d2b6 SCRATCH_MNT/foo +67edd038aaa42adb5a1aa78f2eb1d2b6 +Testing restore of file compressed with zlib +wrote 100000/100000 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 100000/100000 bytes at offset 100000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 2/2 bytes at offset 10000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 11/11 bytes at offset 33000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 100/100 bytes at offset 99000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +67edd038aaa42adb5a1aa78f2eb1d2b6 SCRATCH_MNT/foo +67edd038aaa42adb5a1aa78f2eb1d2b6 +Testing restore of file without any compression +wrote 100000/100000 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 100000/100000 bytes at offset 100000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 2/2 bytes at offset 10000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 11/11 bytes at offset 33000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 100/100 bytes at offset 99000 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +67edd038aaa42adb5a1aa78f2eb1d2b6 SCRATCH_MNT/foo +67edd038aaa42adb5a1aa78f2eb1d2b6 diff --git a/tests/btrfs/group b/tests/btrfs/group index 1037761..fabe3b5 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -45,3 +45,4 @@ 040 auto quick 041 auto quick 042 auto quick +043 auto quick