From patchwork Sun Aug 4 20:12:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2838486 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 29A5E9F485 for ; Sun, 4 Aug 2013 20:12:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30ADF20170 for ; Sun, 4 Aug 2013 20:12:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2B5720163 for ; Sun, 4 Aug 2013 20:12:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753786Ab3HDUMf (ORCPT ); Sun, 4 Aug 2013 16:12:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11468 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753628Ab3HDUMe (ORCPT ); Sun, 4 Aug 2013 16:12:34 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r74KCXoq004556 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 4 Aug 2013 16:12:33 -0400 Received: from Liberator.local (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r74KCVDP015741 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 4 Aug 2013 16:12:32 -0400 Message-ID: <51FEB5AF.7060806@redhat.com> Date: Sun, 04 Aug 2013 15:12:31 -0500 From: Eric Sandeen User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: linux-btrfs CC: "'linux-xfs@oss.sgi.com'" Subject: [PATCH] xfstests btrfs/309: test btrfs-convert X-Enigmail-Version: 1.5.2 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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 Turns out btrfs-convert broke on July 3, and lo! we do not have a regression test, and now we have one, and there was much rejoicing. Signed-off-by: Eric Sandeen Reviewed-by: Josef Bacik --- -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" 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/btrfs/309 b/tests/btrfs/309 new file mode 100755 index 0000000..acb2d6d --- /dev/null +++ b/tests/btrfs/309 @@ -0,0 +1,118 @@ +#! /bin/bash +# FS QA Test No. 309 +# +# Test btrfs-convert +# +# 1) create ext4 filesystem & populate it +# 2) convert it to btrfs, mount it, verify contents +# 3) verify archived ext4 image integriy & contents +# 4) populate btrfs fs with new data +# 5) roll back conversion to original ext4 +# 6) verify rolled-back fs integrity & contents +# +#----------------------------------------------------------------------- +# Copyright (c) 2013 Red Hat, Inc. 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" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter.btrfs + +# real QA test starts here + +# Modify as appropriate. +_supported_fs btrfs +_supported_os Linux +_require_scratch + +BTRFS_CONVERT_PROG="`set_prog_path btrfs-convert`" +MKFS_EXT4_PROG="`set_prog_path mkfs.ext4`" +E2FSCK_PROG="`set_prog_path e2fsck`" + +_require_command $BTRFS_CONVERT_PROG btrfs-convert +_require_command $MKFS_EXT4_PROG mkfs.ext4 +_require_command $E2FSCK_PROG e2fsck + +rm -f $seqres.full + +# Create & populate an ext4 filesystem +$MKFS_EXT4_PROG -b 4096 $SCRATCH_DEV > $seqres.full 2>&1 || \ + _notrun "Could not create ext4 filesystem" +# Manual mount so we don't use -t btrfs or selinux context +mount -t ext4 $SCRATCH_DEV $SCRATCH_MNT + +cp -aR /lib/modules/`uname -r`/ $SCRATCH_MNT +_scratch_unmount + +# Convert it to btrfs, mount it, verify the data +$BTRFS_CONVERT_PROG $SCRATCH_DEV >> $seqres.full 2>&1 || \ + _fail "btrfs-convert failed" +_scratch_mount || _fail "Could not mount new btrfs fs" +# (Ignore the symlinks which may be broken/nonexistent) +diff -r /lib/modules/`uname -r`/ $SCRATCH_MNT/`uname -r`/ 2>&1 | grep -vw "source\|build" + +# Old ext4 image file should exist & be consistent +$E2FSCK_PROG -fn $SCRATCH_MNT/ext2_saved/image >> $seqres.full 2>&1 || \ + _fail "archived ext4 image is corrupt" + +# And the files in that image should match +mkdir -p $SCRATCH_MNT/mnt +mount -o loop $SCRATCH_MNT/ext2_saved/image $SCRATCH_MNT/mnt || \ + _fail "could not loop mount saved ext4 image" +# Ignore the symlinks which may be broken/nonexistent +diff -r /lib/modules/`uname -r`/ $SCRATCH_MNT/mnt/`uname -r`/ 2>&1 | grep -vw "source\|build" +umount $SCRATCH_MNT/mnt + +# Now put some fresh data on the btrfs fs +mkdir -p $SCRATCH_MNT/new +cp -aR /lib/modules/`uname -r`/ $SCRATCH_MNT/new + +_scratch_unmount + +# Now restore the ext4 device +$BTRFS_CONVERT_PROG -r $SCRATCH_DEV >> $seqres.full 2>&1 || \ + _fail "btrfs-convert rollback failed" + +# Check it again +$E2FSCK_PROG -fn $SCRATCH_DEV >> $seqres.full 2>&1 || \ + _fail "restored ext4 image is corrupt" + +# Mount the un-converted ext4 device & check the contents +mount -t ext4 $SCRATCH_DEV $SCRATCH_MNT +# (Ignore the symlinks which may be broken/nonexistent) +diff -r /lib/modules/`uname -r`/ $SCRATCH_MNT/`uname -r`/ 2>&1 | grep -vw "source\|build" + +_scratch_unmount + +# success, all done +status=0 +exit diff --git a/tests/btrfs/309.out b/tests/btrfs/309.out new file mode 100644 index 0000000..2f5d4a9 --- /dev/null +++ b/tests/btrfs/309.out @@ -0,0 +1 @@ +== QA output created by 309 diff --git a/tests/btrfs/group b/tests/btrfs/group index bc6c256..7907abc 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -9,3 +9,4 @@ 276 auto rw metadata 284 auto 307 auto quick +309 auto