From patchwork Fri Nov 15 19:27:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 3189531 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 F2AEFC045B for ; Fri, 15 Nov 2013 19:27:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E377C2074E for ; Fri, 15 Nov 2013 19:27:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0ED5206FB for ; Fri, 15 Nov 2013 19:27:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751318Ab3KOT1X (ORCPT ); Fri, 15 Nov 2013 14:27:23 -0500 Received: from dkim1.fusionio.com ([66.114.96.53]:43940 "EHLO dkim1.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751144Ab3KOT1V (ORCPT ); Fri, 15 Nov 2013 14:27:21 -0500 Received: from mx2.fusionio.com (unknown [10.101.1.160]) by dkim1.fusionio.com (Postfix) with ESMTP id D5F307C0688 for ; Fri, 15 Nov 2013 12:27:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1384543640; bh=IBbvPsbter1amzGy4KyvdwnD1T8thoN1F4e0G7ihOJk=; h=From:To:Subject:Date; b=QFFvNh9EHgd01Y7YZjyXfQ6AKpsXt+D2eRNE46okNqmybbaMToNcKks7cMX71fb4U J8h86ob/9iaQEcJYyZDKBOMcejohZiGbOjE0ExgqrPjR/ErmremS+t/4jVXSKGtGdY Q3S9Ie+25gY3H0zbL1vj5haSpks9n6mXpEhSrbGQ= X-ASG-Debug-ID: 1384543640-0421b57ae6f1760001-6jHSXT Received: from CAS2.int.fusionio.com ([10.101.1.41]) by mx2.fusionio.com with ESMTP id i7tNB1dvNe36ohIJ (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Fri, 15 Nov 2013 12:27:20 -0700 (MST) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (10.101.1.160) by mail.fusionio.com (10.101.1.41) with Microsoft SMTP Server (TLS) id 14.3.158.1; Fri, 15 Nov 2013 12:27:19 -0700 From: Josef Bacik To: , Subject: [PATCH] xfstests: add basic qgroup testing Date: Fri, 15 Nov 2013 14:27:18 -0500 X-ASG-Orig-Subj: [PATCH] xfstests: add basic qgroup testing Message-ID: <1384543638-19686-1-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.101.1.160] X-Barracuda-Connect: UNKNOWN[10.101.1.41] X-Barracuda-Start-Time: 1384543640 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.181:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.142343 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 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_SIGNED, 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 We have no tests for testing qgroups, so we have no way of knowing if our changes are breaking qgroups at all. Get the ball rolling with some basic functionality tests, these just make sure we can enable quotas and do rescan and get sane values back, as well as make sure the limiting stuff works properly. Thanks, Signed-off-by: Josef Bacik --- tests/btrfs/022 | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/022.out | 2 + tests/btrfs/group | 1 + 3 files changed, 132 insertions(+) create mode 100644 tests/btrfs/022 create mode 100644 tests/btrfs/022.out diff --git a/tests/btrfs/022 b/tests/btrfs/022 new file mode 100644 index 0000000..5b18643 --- /dev/null +++ b/tests/btrfs/022 @@ -0,0 +1,129 @@ +#! /bin/bash +# FS QA Test No. 022 +# +# Test the basic functionality of qgroups +# +#----------------------------------------------------------------------- +# Copyright (c) 2013 Fusion IO. 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 + +_supported_fs btrfs +_supported_os Linux +_require_scratch + +rm -f $seqres.full + +# Test to make sure we can actually turn it on and it makes sense +_basic_test() +{ + run_check $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a + run_check $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT/a + subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a) + $BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid >> \ + $seqres.full 2>&1 + [ $? -eq 0 ] || _fail "couldn't find our subvols quota group" + run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \ + $FSSTRESS_AVOID + run_check $BTRFS_UTIL_PROG subvolume snapshot $SCRATCH_MNT/a \ + $SCRATCH_MNT/b + + # the shared values of both the original subvol and snapshot should + # match + a_shared=$($BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid) + a_shared=$(echo $a_shared | awk '{ print $2 }') + subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT b) + b_shared=$($BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid) + b_shared=$(echo $b_shared | awk '{ print $2 }') + [ $b_shared -eq $a_shared ] || _fail "shared values don't match" +} + +#enable quotas, do some work, check our values and then rescan and make sure we +#come up with the same answer +_rescan_test() +{ + # first with a blank subvol + run_check $BTRFS_UTIL_PROG subvol create $SCRATCH_MNT/a + run_check $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT/a + subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a) + run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \ + $FSSTRESS_AVOID + sync + output=$($BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid) + echo $output >> $seqres.full + refer=$(echo $output | awk '{ print $2 }') + excl=$(echo $output | awk '{ print $3 }') + run_check $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT + output=$($BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid) + echo $output >> $seqres.full + [ $refer -eq $(echo $output | awk '{ print $2 }') ] || \ + _fail "reference values don't match after rescan" + [ $excl -eq $(echo $output | awk '{ print $3 }') ] || \ + _fail "exclusive values don't match after rescan" +} + +#basic limit testing +_limit_test() +{ + run_check $BTRFS_UTIL_PROG subvol create $SCRATCH_MNT/a + run_check $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT + subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a) + run_check $BTRFS_UTIL_PROG qgroup limit 5M 0/$subvolid $SCRATCH_MNT + dd if=/dev/urandom of=$SCRATCH_MNT/a/file bs=10M count=1 >> \ + $seqres.full 2>&1 + [ $? -ne 0 ] || _fail "quota should have limited us" + dd if=/dev/urandom of=$SCRATCH_MNT/a/file bs=4M count=1 >> \ + $seqres.full 2>&1 + [ $? -eq 0 ] || _fail "should have been allowed to write" +} + +_scratch_mkfs > /dev/null 2>&1 +_scratch_mount +_basic_test +_scratch_unmount + +_scratch_mkfs > /dev/null 2>&1 +_scratch_mount +_rescan_test +_scratch_unmount + +_scratch_mkfs > /dev/null 2>&1 +_scratch_mount +_limit_test + +# success, all done +echo "Silence is golden" +status=0 +exit diff --git a/tests/btrfs/022.out b/tests/btrfs/022.out new file mode 100644 index 0000000..394c6a7 --- /dev/null +++ b/tests/btrfs/022.out @@ -0,0 +1,2 @@ +QA output created by 022 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index 410f8ed..ac92d31 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -24,3 +24,4 @@ 019 auto quick 020 auto quick 021 auto quick +022 auto