2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
7 # Test the basic functionality of qgroups
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
31 _require_btrfs_qgroup_report
35 # Test to make sure we can actually turn it on and it makes sense
38 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
39 _run_btrfs_util_prog quota enable $SCRATCH_MNT/a
40 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
41 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
42 $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid >> \
44 [ $? -eq 0 ] || _fail "couldn't find our subvols quota group"
45 run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \
47 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT/a \
50 # the shared values of both the original subvol and snapshot should
52 a_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
53 a_shared=$(echo $a_shared | awk '{ print $2 }')
54 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT b)
55 b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
56 b_shared=$(echo $b_shared | awk '{ print $2 }')
57 [ $b_shared -eq $a_shared ] || _fail "shared values don't match"
60 #enable quotas, do some work, check our values and then rescan and make sure we
61 #come up with the same answer
64 # first with a blank subvol
65 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
66 _run_btrfs_util_prog quota enable $SCRATCH_MNT/a
67 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
68 run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \
71 output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
72 echo $output >> $seqres.full
73 refer=$(echo $output | awk '{ print $2 }')
74 excl=$(echo $output | awk '{ print $3 }')
75 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
76 output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
77 echo $output >> $seqres.full
78 [ $refer -eq $(echo $output | awk '{ print $2 }') ] || \
79 _fail "reference values don't match after rescan"
80 [ $excl -eq $(echo $output | awk '{ print $3 }') ] || \
81 _fail "exclusive values don't match after rescan"
84 #basic exceed limit testing
87 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
88 _run_btrfs_util_prog quota enable $SCRATCH_MNT
89 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
90 _run_btrfs_util_prog qgroup limit 5M 0/$subvolid $SCRATCH_MNT
91 _ddt of=$SCRATCH_MNT/a/file bs=10M count=1 >> $seqres.full 2>&1
92 [ $? -ne 0 ] || _fail "quota should have limited us"
95 #basic noexceed limit testing
96 _limit_test_noexceed()
98 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
99 _run_btrfs_util_prog quota enable $SCRATCH_MNT
100 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
101 _run_btrfs_util_prog qgroup limit 5M 0/$subvolid $SCRATCH_MNT
102 _ddt of=$SCRATCH_MNT/a/file bs=4M count=1 >> $seqres.full 2>&1
103 [ $? -eq 0 ] || _fail "should have been allowed to write"
106 units=`_btrfs_qgroup_units`
108 _scratch_mkfs > /dev/null 2>&1
114 _scratch_mkfs > /dev/null 2>&1
120 _scratch_mkfs > /dev/null 2>&1
126 _scratch_mkfs > /dev/null 2>&1
131 echo "Silence is golden"