2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
7 # Exercise basic xfs_quota functionality (user/group/project quota)
8 # Use of "sync" mount option here is an attempt to get deterministic
12 _begin_fstest auto quick quota
14 # Import common functions.
18 # real QA test starts here
25 _scratch_mkfs_xfs >>$seqres.full 2>&1
30 cat >$tmp.projects <<EOF
34 cat >$tmp.projid <<EOF
44 echo "Using type=$type id=$id" >> $seqres.full
46 for ((i=0; i<$((inum-1)); i++)); do
47 _file_as_id $SCRATCH_MNT/inode$i $id $type 1024 0
50 _file_as_id $SCRATCH_MNT/block $id $type $bs 1
55 rm -rf $SCRATCH_MNT/* 2>/dev/null
56 rm -rf $tmp.quot 2>/dev/null
57 rm -rf $tmp.quota 2>/dev/null
62 _filter_quota | grep -v "root \|\#0 " \
63 | sed -e '/#[0-9]*/s/#[0-9]*/#ID/g'
68 _filter_quota | grep -v "^root \|^\#0 " \
69 | sed -e '/^#[0-9]*/s/^#[0-9]*/#ID/g'
74 _filter_quota | sed -e "/Disk quotas for/s/([0-9]*)/(ID)/g" \
75 -e "/Disk quotas for/s/#[0-9]*/#ID/g"
80 _filter_quota | sed -e "s/Inode: #[0-9]* (0 blocks, 0 extents)/Inode: #[INO] (0 blocks, 0 extents)/g" \
81 -e "s/Inode: #[0-9]* ([0-9]* blocks, [0-9]* extents)/Inode: #[INO] (X blocks, Y extents)/g" \
82 -e "/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/s/ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]//g" \
90 echo "checking quot command (type=$type)"
91 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
92 -c "quot -$type $opt -bi" $SCRATCH_MNT | filter_quot
99 echo "checking report command (type=$type)"
100 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
101 -c "report -$type $opt -bi" \
102 $SCRATCH_MNT | filter_report
109 echo "checking quota command (type=$type)"
110 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
111 -c "quota -$type $opt -bi $id" \
112 $SCRATCH_MNT | filter_quota
122 echo "checking limit command (type=$type, bsoft=$bs, bhard=$bh, isoft=$is, ihard=$ih)"
123 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
124 -c "limit -$type bsoft=$bs bhard=$bh fsgqa" \
125 -c "limit -$type isoft=$is ihard=$ih fsgqa" \
128 # let the timer day transition happen
134 echo "checking timer command (type=$type)"
135 # set 3days+1h for time won't become 2days soon
136 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
137 -c "timer -$type -bi 73h" \
138 $SCRATCH_MNT | _filter_scratch
143 echo "checking disable command (type=$type)"
144 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
145 -c "disable -$type -v" \
146 $SCRATCH_MNT | filter_state
151 echo "checking enable command (type=$type)"
152 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
153 -c "enable -$type -v" $SCRATCH_MNT | filter_state
165 echo "checking remove command (type=$type)"
166 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
167 -c "remove -$type -v" \
168 $SCRATCH_MNT | _filter_scratch
173 echo "checking state command (type=$type)"
174 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
175 -c "state -$type" $SCRATCH_MNT | filter_state
180 echo "checking dump command (type=$type)"
181 rm -f $tmp.backup 2>>/dev/null
182 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
183 -c "dump -$type -f $tmp.backup" \
184 $SCRATCH_MNT | _filter_scratch
189 echo "checking restore command (type=$type)"
190 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
191 -c "restore -$type -f $tmp.backup" \
192 $SCRATCH_MNT | _filter_scratch
200 if [ $type == "p" ]; then
201 _require_prjquota $SCRATCH_DEV
202 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
203 -c "project -s $id" $SCRATCH_MNT > /dev/null
207 echo "init quota limit and timer, and dump it"
208 echo "create_files 1024k 15"; create_files 1024k 15
209 echo "quota remount"; _qmount
212 echo ; test_limit 512k 2048k 10 20
215 # report options test
216 echo "report options test"
218 echo "-N option"; test_report -N
219 echo "-L -U options"; test_report -L $id -U $id
220 echo "-t option"; test_report -t
221 echo "-n option"; test_report -n
222 echo "-h option"; test_report -h
225 echo "quot options test"
227 echo "-f option"; test_quot -f $tmp.quot
228 cat $tmp.quot | filter_quot
229 echo "-n option"; test_quot -n
233 echo "-f option"; test_quota -f $tmp.quota
234 cat $tmp.quota | filter_quota
235 echo "-N option"; test_quota -N
236 echo "-n option"; test_quota -n
237 echo "-h option"; test_quota -h
239 # disable/enable test
242 echo ; test_report -N
243 echo "expect a remove error at here"; test_remove
245 echo ; test_report -N
247 # off and remove test
248 echo "disable and remove test"
249 echo ; test_limit 100m 100m 100 100
255 echo ; test_report -N
258 echo "quota remount";
261 echo ; test_report -N
266 echo ; test_report -N
268 echo "cleanup files"; clean_files
271 echo "----------------------- uquota,sync ---------------------------"
274 test_xfs_quota "uquota,sync"
276 echo "----------------------- gquota,sync ---------------------------"
279 test_xfs_quota "gquota,sync"
281 echo "----------------------- pquota,sync ---------------------------"
282 # Need to clean the group quota before test project quota, because
283 # V4 xfs doesn't support separate project inode. So mkfs at here.
285 _scratch_mkfs_xfs >>$seqres.full 2>&1
288 test_xfs_quota "pquota,sync"