]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
btrfs: test normal qgroup operations in a compress friendly way
authorJosef Bacik <josef@toxicpanda.com>
Tue, 5 Mar 2024 18:52:24 +0000 (19:52 +0100)
committerZorro Lang <zlang@kernel.org>
Mon, 11 Mar 2024 04:50:09 +0000 (12:50 +0800)
btrfs/022 currently fails if you are testing with -o compress because it
does a limit exceed test which will pass with compression on.

However the other functionality this test tests is completely acceptable
with compression enabled.  Handle this by breaking the test into two
tests, one that simply tests the qgroup exceed limits test that requires
no compression, and the rest of the tests that do not have the no
compression restriction.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
tests/btrfs/022
tests/btrfs/320 [new file with mode: 0755]
tests/btrfs/320.out [new file with mode: 0644]

index b1ef2fdf78764027bf959bd52c3c6075a9ddd132..32ad80bf9c64e8c5f6819f2c01c4b153d1f7b62e 100755 (executable)
@@ -4,7 +4,7 @@
 #
 # FS QA Test No. 022
 #
-# Test the basic functionality of qgroups
+# Test the basic qgroup exceed case
 #
 . ./common/preamble
 _begin_fstest auto qgroup limit
@@ -17,59 +17,8 @@ _require_scratch
 _require_qgroup_rescan
 _require_btrfs_qgroup_report
 
-# Test to make sure we can actually turn it on and it makes sense
-_basic_test()
-{
-       echo "=== basic test ===" >> $seqres.full
-       _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
-       _run_btrfs_util_prog quota enable $SCRATCH_MNT/a
-       _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
-       subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
-       $BTRFS_UTIL_PROG qgroup show $units $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_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 $units $SCRATCH_MNT | grep "0/$subvolid")
-       a_shared=$(echo $a_shared | $AWK_PROG '{ print $2 }')
-       echo "subvol a id=$subvolid" >> $seqres.full
-       subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT b)
-       echo "subvol b id=$subvolid" >> $seqres.full
-       b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
-       b_shared=$(echo $b_shared | $AWK_PROG '{ print $2 }')
-       $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT >> $seqres.full
-       [ $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()
-{
-       echo "=== rescan test ===" >> $seqres.full
-       # first with a blank subvol
-       _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
-       _run_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 $units $SCRATCH_MNT | grep "0/$subvolid")
-       echo "qgroup values before rescan: $output" >> $seqres.full
-       refer=$(echo $output | $AWK_PROG '{ print $2 }')
-       excl=$(echo $output | $AWK_PROG '{ print $3 }')
-       _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
-       output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
-       echo "qgroup values after rescan: $output" >> $seqres.full
-       [ $refer -eq $(echo $output | $AWK_PROG '{ print $2 }') ] || \
-               _fail "reference values don't match after rescan"
-       [ $excl -eq $(echo $output | $AWK_PROG '{ print $3 }') ] || \
-               _fail "exclusive values don't match after rescan"
-}
+# This test requires specific data usage, skip if we have compression enabled
+_require_no_compress
 
 #basic exceed limit testing
 _limit_test_exceed()
@@ -82,43 +31,14 @@ _limit_test_exceed()
        _ddt of=$SCRATCH_MNT/a/file bs=10M count=1 >> $seqres.full 2>&1
        [ $? -ne 0 ] || _fail "quota should have limited us"
 }
-
-#basic noexceed limit testing
-_limit_test_noexceed()
-{
-       echo "=== limit not exceed test ===" >> $seqres.full
-       _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
-       _run_btrfs_util_prog quota enable $SCRATCH_MNT
-       subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
-       _run_btrfs_util_prog qgroup limit 5M 0/$subvolid $SCRATCH_MNT
-       _ddt of=$SCRATCH_MNT/a/file bs=4M count=1 >> $seqres.full 2>&1
-       [ $? -eq 0 ] || _fail "should have been allowed to write"
-}
-
 units=`_btrfs_qgroup_units`
 
-_scratch_mkfs > /dev/null 2>&1
-_scratch_mount
-_basic_test
-_scratch_unmount
-_check_scratch_fs
-
-_scratch_mkfs > /dev/null 2>&1
-_scratch_mount
-_rescan_test
-_scratch_unmount
-_check_scratch_fs
-
 _scratch_mkfs > /dev/null 2>&1
 _scratch_mount
 _limit_test_exceed
 _scratch_unmount
 _check_scratch_fs
 
-_scratch_mkfs > /dev/null 2>&1
-_scratch_mount
-_limit_test_noexceed
-
 # success, all done
 echo "Silence is golden"
 status=0
diff --git a/tests/btrfs/320 b/tests/btrfs/320
new file mode 100755 (executable)
index 0000000..4080534
--- /dev/null
@@ -0,0 +1,107 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021 Facebook.  All Rights Reserved.
+#
+# FS QA Test No. 320
+#
+# Test qgroups to validate the creation works, the counters are sane, rescan
+# works, and we do not get failures when we write less than the limit amount.
+#
+. ./common/preamble
+_begin_fstest auto qgroup limit
+
+# Import common functions.
+. ./common/filter
+
+_supported_fs btrfs
+_require_scratch
+_require_btrfs_qgroup_report
+
+# Test to make sure we can actually turn it on and it makes sense
+_basic_test()
+{
+       echo "=== basic test ===" >> $seqres.full
+       _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
+       _run_btrfs_util_prog quota enable $SCRATCH_MNT/a
+       _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
+       subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
+       $BTRFS_UTIL_PROG qgroup show $units $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_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 $units $SCRATCH_MNT | grep "0/$subvolid")
+       a_shared=$(echo $a_shared | $AWK_PROG '{ print $2 }')
+       echo "subvol a id=$subvolid" >> $seqres.full
+       subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT b)
+       echo "subvol b id=$subvolid" >> $seqres.full
+       b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
+       b_shared=$(echo $b_shared | $AWK_PROG '{ print $2 }')
+       $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT >> $seqres.full
+       [ $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()
+{
+       echo "=== rescan test ===" >> $seqres.full
+       # first with a blank subvol
+       _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
+       _run_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 $units $SCRATCH_MNT | grep "0/$subvolid")
+       echo "qgroup values before rescan: $output" >> $seqres.full
+       refer=$(echo $output | $AWK_PROG '{ print $2 }')
+       excl=$(echo $output | $AWK_PROG '{ print $3 }')
+       _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
+       output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
+       echo "qgroup values after rescan: $output" >> $seqres.full
+       [ $refer -eq $(echo $output | $AWK_PROG '{ print $2 }') ] || \
+               _fail "reference values don't match after rescan"
+       [ $excl -eq $(echo $output | $AWK_PROG '{ print $3 }') ] || \
+               _fail "exclusive values don't match after rescan"
+}
+
+#basic noexceed limit testing
+_limit_test_noexceed()
+{
+       echo "=== limit not exceed test ===" >> $seqres.full
+       _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
+       _run_btrfs_util_prog quota enable $SCRATCH_MNT
+       subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
+       _run_btrfs_util_prog qgroup limit 5M 0/$subvolid $SCRATCH_MNT
+       _ddt of=$SCRATCH_MNT/a/file bs=4M count=1 >> $seqres.full 2>&1
+       [ $? -eq 0 ] || _fail "should have been allowed to write"
+}
+
+units=`_btrfs_qgroup_units`
+
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+_basic_test
+_scratch_unmount
+_check_scratch_fs
+
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+_rescan_test
+_scratch_unmount
+_check_scratch_fs
+
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+_limit_test_noexceed
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/320.out b/tests/btrfs/320.out
new file mode 100644 (file)
index 0000000..1c4165d
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 320
+Silence is golden