4 # Test the basic functionality of qgroups
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
49 # Test to make sure we can actually turn it on and it makes sense
52 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
53 _run_btrfs_util_prog quota enable $SCRATCH_MNT/a
54 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
55 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
56 $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid >> \
58 [ $? -eq 0 ] || _fail "couldn't find our subvols quota group"
59 run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \
61 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT/a \
64 # the shared values of both the original subvol and snapshot should
66 a_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
67 a_shared=$(echo $a_shared | awk '{ print $2 }')
68 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT b)
69 b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
70 b_shared=$(echo $b_shared | awk '{ print $2 }')
71 [ $b_shared -eq $a_shared ] || _fail "shared values don't match"
74 #enable quotas, do some work, check our values and then rescan and make sure we
75 #come up with the same answer
78 # first with a blank subvol
79 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
80 _run_btrfs_util_prog quota enable $SCRATCH_MNT/a
81 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
82 run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \
85 output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
86 echo $output >> $seqres.full
87 refer=$(echo $output | awk '{ print $2 }')
88 excl=$(echo $output | awk '{ print $3 }')
89 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
90 output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid)
91 echo $output >> $seqres.full
92 [ $refer -eq $(echo $output | awk '{ print $2 }') ] || \
93 _fail "reference values don't match after rescan"
94 [ $excl -eq $(echo $output | awk '{ print $3 }') ] || \
95 _fail "exclusive values don't match after rescan"
98 #basic exceed limit testing
101 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
102 _run_btrfs_util_prog quota enable $SCRATCH_MNT
103 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
104 _run_btrfs_util_prog qgroup limit 5M 0/$subvolid $SCRATCH_MNT
105 dd if=/dev/urandom of=$SCRATCH_MNT/a/file bs=10M count=1 >> \
107 [ $? -ne 0 ] || _fail "quota should have limited us"
110 #basic noexceed limit testing
111 _limit_test_noexceed()
113 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a
114 _run_btrfs_util_prog quota enable $SCRATCH_MNT
115 subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
116 _run_btrfs_util_prog qgroup limit 5M 0/$subvolid $SCRATCH_MNT
117 dd if=/dev/urandom of=$SCRATCH_MNT/a/file bs=4M count=1 >> \
119 [ $? -eq 0 ] || _fail "should have been allowed to write"
122 units=`_btrfs_qgroup_units`
124 _scratch_mkfs > /dev/null 2>&1
129 _scratch_mkfs > /dev/null 2>&1
134 _scratch_mkfs > /dev/null 2>&1
139 _scratch_mkfs > /dev/null 2>&1
144 echo "Silence is golden"