From patchwork Wed Jul 3 09:46:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 2815831 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 4213F9F755 for ; Wed, 3 Jul 2013 09:46:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CD752010C for ; Wed, 3 Jul 2013 09:46:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA5662010A for ; Wed, 3 Jul 2013 09:46:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754891Ab3GCJqe (ORCPT ); Wed, 3 Jul 2013 05:46:34 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:41173 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754240Ab3GCJqd (ORCPT ); Wed, 3 Jul 2013 05:46:33 -0400 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r639eA31004584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 3 Jul 2013 09:40:11 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r639kU7W004050 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 3 Jul 2013 09:46:30 GMT Received: from abhmt104.oracle.com (abhmt104.oracle.com [141.146.116.56]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r639kU3p020685; Wed, 3 Jul 2013 09:46:30 GMT Received: from localhost.localdomain.com (/10.182.228.124) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 03 Jul 2013 02:46:29 -0700 From: Liu Bo To: linux-btrfs@vger.kernel.org Cc: xfs@oss.sgi.com Subject: [PATCH] Xfstests/btrfs/308: add snapshot-aware defrag for partial extents testcases Date: Wed, 3 Jul 2013 17:46:20 +0800 Message-Id: <1372844780-31845-1-git-send-email-bo.li.liu@oracle.com> X-Mailer: git-send-email 1.8.1.4 X-Source-IP: acsinet22.oracle.com [141.146.126.238] 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 This is to test whether snapshot-aware defrag can work well on partial extents. Signed-off-by: Liu Bo Reviewed-by: Ben Myers --- tests/btrfs/308 | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/308.out | 2 + tests/btrfs/group | 1 + 3 files changed, 96 insertions(+), 0 deletions(-) create mode 100755 tests/btrfs/308 create mode 100644 tests/btrfs/308.out diff --git a/tests/btrfs/308 b/tests/btrfs/308 new file mode 100755 index 0000000..b3dd39c --- /dev/null +++ b/tests/btrfs/308 @@ -0,0 +1,93 @@ +#! /bin/bash +# BTRFS QA Test No. 308 +# +# Test if snapshot-aware defrag can work well on partial extents, ie. +# extent_offset is not zero. +# +#----------------------------------------------------------------------- +# Copyright (c) 2013 Oracle. 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 + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_scratch +_require_command "/usr/sbin/filefrag" + +rm -f $seqres.full + +_scratch_mkfs > /dev/null 2>&1 +_scratch_mount + +subvol=$SCRATCH_MNT/subvol + +$BTRFS_UTIL_PROG subvolume create $subvol >> $seqres.full + +for i in `seq 5 -1 1` +do + dd if=/dev/zero of=$subvol/foobar bs=6k count=1 seek=$i conv=notrunc oflag=dsync 2>> $seqres.full +done + +sync +for i in `seq 2 -1 1` +do + $BTRFS_UTIL_PROG subvolume snapshot $subvol $SCRATCH_MNT/snap-$i >> $seqres.full +done + +$BTRFS_UTIL_PROG filesystem defrag $subvol/foobar && sync + +num_extent_orig=`filefrag $subvol/foobar | awk -F ' ' '{print $2}'` +num_extent_snap1=`filefrag $SCRATCH_MNT/snap-1/foobar | awk -F ' ' '{print $2}'` +num_extent_snap2=`filefrag $SCRATCH_MNT/snap-2/foobar | awk -F ' ' '{print $2}'` + +echo "$num_extent_orig $num_extent_snap1 $num_extent_snap2" >> $seqres.full + +# if error +if [ "x$num_extent_snap1" != "x$num_extent_orig" -o "x$num_extent_snap2" != "x$num_extent_orig" ]; then + echo "number of extents mis-match!" + exit +fi + +# optional stuff if your test has verbose output to help resolve problems +#echo +#echo "If failure, check $seqres.full (this) and $seqres.full.ok (reference)" + +# success, all done +echo "done" +status=0 +exit diff --git a/tests/btrfs/308.out b/tests/btrfs/308.out new file mode 100644 index 0000000..1f3de82 --- /dev/null +++ b/tests/btrfs/308.out @@ -0,0 +1,2 @@ +QA output created by 308 +done diff --git a/tests/btrfs/group b/tests/btrfs/group index bc6c256..666054b 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -9,3 +9,4 @@ 276 auto rw metadata 284 auto 307 auto quick +308 auto quick