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 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
31 # remove previous $seqres.full before test
34 # real QA test starts here
42 _scratch_mkfs_xfs >>$seqres.full 2>&1
47 cat >$tmp.projects <<EOF
51 cat >$tmp.projid <<EOF
61 echo "Using type=$type id=$id" >> $seqres.full
63 for ((i=0; i<$((inum-1)); i++)); do
64 _file_as_id $SCRATCH_MNT/inode$i $id $type 1024 0
67 _file_as_id $SCRATCH_MNT/block $id $type $bs 1
72 rm -rf $SCRATCH_MNT/* 2>/dev/null
73 rm -rf $tmp.quot 2>/dev/null
74 rm -rf $tmp.quota 2>/dev/null
79 _filter_quota | grep -v "root \|\#0 " \
80 | sed -e '/#[0-9]*/s/#[0-9]*/#ID/g'
85 _filter_quota | grep -v "^root \|^\#0 " \
86 | sed -e '/^#[0-9]*/s/^#[0-9]*/#ID/g'
91 _filter_quota | sed -e "/Disk quotas for/s/([0-9]*)/(ID)/g" \
92 -e "/Disk quotas for/s/#[0-9]*/#ID/g"
97 _filter_quota | sed -e "s/Inode: #[0-9]* (0 blocks, 0 extents)/Inode: #[INO] (0 blocks, 0 extents)/g" \
98 -e "s/Inode: #[0-9]* ([0-9]* blocks, [0-9]* extents)/Inode: #[INO] (X blocks, Y extents)/g" \
99 -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" \
100 -e '/max warnings:/d'
107 echo "checking quot command (type=$type)"
108 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
109 -c "quot -$type $opt -bi" $SCRATCH_MNT | filter_quot
116 echo "checking report command (type=$type)"
117 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
118 -c "report -$type $opt -bi" \
119 $SCRATCH_MNT | filter_report
126 echo "checking quota command (type=$type)"
127 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
128 -c "quota -$type $opt -bi $id" \
129 $SCRATCH_MNT | filter_quota
139 echo "checking limit command (type=$type, bsoft=$bs, bhard=$bh, isoft=$is, ihard=$ih)"
140 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
141 -c "limit -$type bsoft=$bs bhard=$bh fsgqa" \
142 -c "limit -$type isoft=$is ihard=$ih fsgqa" \
145 # let the timer day transition happen
151 echo "checking timer command (type=$type)"
152 # set 3days+1h for time won't become 2days soon
153 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
154 -c "timer -$type -bi 73h" \
155 $SCRATCH_MNT | _filter_scratch
160 echo "checking disable command (type=$type)"
161 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
162 -c "disable -$type -v" \
163 $SCRATCH_MNT | filter_state
168 echo "checking enable command (type=$type)"
169 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
170 -c "enable -$type -v" $SCRATCH_MNT | filter_state
175 echo "checking off command (type=$type)"
176 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
177 -c "off -$type -v" $SCRATCH_MNT | _filter_scratch
182 echo "checking remove command (type=$type)"
183 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
184 -c "remove -$type -v" \
185 $SCRATCH_MNT | _filter_scratch
190 echo "checking state command (type=$type)"
191 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
192 -c "state -$type" $SCRATCH_MNT | filter_state
197 echo "checking dump command (type=$type)"
198 rm -f $tmp.backup 2>>/dev/null
199 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
200 -c "dump -$type -f $tmp.backup" \
201 $SCRATCH_MNT | _filter_scratch
206 echo "checking restore command (type=$type)"
207 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
208 -c "restore -$type -f $tmp.backup" \
209 $SCRATCH_MNT | _filter_scratch
215 echo "init quota limit and timer, and dump it"
216 echo "create_files 1024k 15"; create_files 1024k 15
217 echo "quota remount"; _qmount
220 echo ; test_limit 512k 2048k 10 20
223 # report options test
224 echo "report options test"
226 echo "-N option"; test_report -N
227 echo "-L -U options"; test_report -L $id -U $id
228 echo "-t option"; test_report -t
229 echo "-n option"; test_report -n
230 echo "-h option"; test_report -h
233 echo "quot options test"
235 echo "-f option"; test_quot -f $tmp.quot
236 cat $tmp.quot | filter_quot
237 echo "-n option"; test_quot -n
241 echo "-f option"; test_quota -f $tmp.quota
242 cat $tmp.quota | filter_quota
243 echo "-N option"; test_quota -N
244 echo "-n option"; test_quota -n
245 echo "-h option"; test_quota -h
247 # disable/enable test
250 echo ; test_report -N
251 echo "expect a remove error at here"; test_remove
253 echo ; test_report -N
255 # off and remove test
256 echo "off and remove test"
257 echo ; test_limit 100m 100m 100 100
262 echo ; test_report -N
263 echo "quota remount"; _qmount
264 echo ; test_report -N
269 echo ; test_report -N
271 echo "cleanup files"; clean_files
274 echo "----------------------- uquota,sync ---------------------------"
275 _qmount_option "uquota,sync"
281 echo "----------------------- gquota,sync ---------------------------"
282 _qmount_option "gquota,sync"
288 echo "----------------------- pquota,sync ---------------------------"
289 # Need to clean the group quota before test project quota, because
290 # V4 xfs doesn't support separate project inode. So mkfs at here.
292 _scratch_mkfs_xfs >>$seqres.full 2>&1
293 _qmount_option "pquota,sync"
297 _require_prjquota $SCRATCH_DEV
298 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
299 -c "project -s $id" \
300 $SCRATCH_MNT > /dev/null