From patchwork Fri Dec 19 08:31:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 5518041 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 215889F30B for ; Fri, 19 Dec 2014 08:32:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3714620131 for ; Fri, 19 Dec 2014 08:32:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 351502012D for ; Fri, 19 Dec 2014 08:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752129AbaLSIb5 (ORCPT ); Fri, 19 Dec 2014 03:31:57 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:28787 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751821AbaLSIbz (ORCPT ); Fri, 19 Dec 2014 03:31:55 -0500 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id sBJ8VsVe031145 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 19 Dec 2014 08:31:55 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id sBJ8Vrn6015368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 19 Dec 2014 08:31:54 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id sBJ8Vrqt007587; Fri, 19 Dec 2014 08:31:53 GMT Received: from localhost.localdomain.com (/10.182.228.124) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 19 Dec 2014 00:31:52 -0800 From: Liu Bo To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH v4] xfstests: btrfs: add test case for qgroup account on shared extents Date: Fri, 19 Dec 2014 16:31:42 +0800 Message-Id: <1418977902-25174-1-git-send-email-bo.li.liu@oracle.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1418723004-30543-1-git-send-email-bo.li.liu@oracle.com> References: <1418723004-30543-1-git-send-email-bo.li.liu@oracle.com> 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, T_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 a regression test of 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")', it's used to verify that removing shared extents can end up incorrect qgroup accounting. It can produce qgroup related warnings. The fix is https://patchwork.kernel.org/patch/5499981/ "Btrfs: fix a warning of qgroup account on shared extents" Signed-off-by: Liu Bo Tested-by: Satoru Takeuchi Reviewed-by: Satoru Takeuchi Reviewed-by: Eryu Guan --- v4: - remove inproper run_check macro and add filter macro for xfs_io - use awk's regexp directly - add test case description v3: - remove trailing whilespace. - add the fix link for more details of the problem. v2: - use new seq number 017 instead 080 - use 'cloner' to get shared extents - use XFS_IO_PROG instead tests/btrfs/017 | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/017.out | 5 ++++ tests/btrfs/group | 1 + 3 files changed, 88 insertions(+) create mode 100755 tests/btrfs/017 create mode 100644 tests/btrfs/017.out diff --git a/tests/btrfs/017 b/tests/btrfs/017 new file mode 100755 index 0000000..7937607 --- /dev/null +++ b/tests/btrfs/017 @@ -0,0 +1,82 @@ +#! /bin/bash +# FS QA Test No. 017 +# +# Verify that removing shared extents can end up incorrect qgroup accounting. +# +# Regression of 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")', +# this will throw a warning into dmesg. +# +# The issue is fixed by https://patchwork.kernel.org/patch/5499981/ +# "Btrfs: fix a warning of qgroup account on shared extents" +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 Liu Bo. 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 + +_need_to_be_root +_supported_fs btrfs +_supported_os Linux +_require_scratch +_require_cloner + +rm -f $seqres.full + +_scratch_mkfs "--nodesize 4096" +_scratch_mount + +$XFS_IO_PROG -f -d -c "pwrite 0 8K" $SCRATCH_MNT/foo | _filter_xfs_io + +_run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap + +$CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/foo-reflink +$CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/snap/foo-reflink +$CLONER_PROG -s 0 -d 0 -l 8192 $SCRATCH_MNT/foo $SCRATCH_MNT/snap/foo-reflink2 + +_run_btrfs_util_prog quota enable $SCRATCH_MNT +_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT + +rm -fr $SCRATCH_MNT/foo* +rm -fr $SCRATCH_MNT/snap/foo* + +sync + +$BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | $AWK_PROG '/[0-9]/ {print $2" "$3}' + +# success, all done +status=0 +exit diff --git a/tests/btrfs/017.out b/tests/btrfs/017.out new file mode 100644 index 0000000..7658e2e --- /dev/null +++ b/tests/btrfs/017.out @@ -0,0 +1,5 @@ +QA output created by 017 +wrote 8192/8192 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +4096 4096 +4096 4096 diff --git a/tests/btrfs/group b/tests/btrfs/group index abb2fe4..e29999b 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -19,6 +19,7 @@ 014 auto balance 015 auto quick snapshot 016 auto quick send +017 auto quick qgroup 018 auto quick subvol 019 auto quick send 020 auto quick replace