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
41 _scratch_mkfs_xfs >>$seqres.full 2>&1
46 cat >$tmp.projects <<EOF
50 cat >$tmp.projid <<EOF
60 echo "Using type=$type id=$id" >> $seqres.full
62 for ((i=0; i<$((inum-1)); i++)); do
63 _file_as_id $SCRATCH_MNT/inode$i $id $type 1024 0
66 _file_as_id $SCRATCH_MNT/block $id $type $bs 1
71 rm -rf $SCRATCH_MNT/* 2>/dev/null
72 rm -rf $tmp.quot 2>/dev/null
73 rm -rf $tmp.quota 2>/dev/null
78 _filter_quota | grep -v "root \|\#0 " \
79 | sed -e '/#[0-9]*/s/#[0-9]*/#ID/g'
84 _filter_quota | grep -v "^root \|^\#0 " \
85 | sed -e '/^#[0-9]*/s/^#[0-9]*/#ID/g'
90 _filter_quota | sed -e "/Disk quotas for/s/([0-9]*)/(ID)/g" \
91 -e "/Disk quotas for/s/#[0-9]*/#ID/g"
96 _filter_quota | sed -e "s/Inode: #[0-9]* (0 blocks, 0 extents)/Inode: #[INO] (0 blocks, 0 extents)/g" \
97 -e "s/Inode: #[0-9]* ([0-9]* blocks, [0-9]* extents)/Inode: #[INO] (X blocks, Y extents)/g" \
98 -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" \
106 echo "checking quot command (type=$type)"
107 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
108 -c "quot -$type $opt -bi" $SCRATCH_MNT | filter_quot
115 echo "checking report command (type=$type)"
116 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
117 -c "report -$type $opt -bi" \
118 $SCRATCH_MNT | filter_report
125 echo "checking quota command (type=$type)"
126 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
127 -c "quota -$type $opt -bi $id" \
128 $SCRATCH_MNT | filter_quota
138 echo "checking limit command (type=$type, bsoft=$bs, bhard=$bh, isoft=$is, ihard=$ih)"
139 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
140 -c "limit -$type bsoft=$bs bhard=$bh fsgqa" \
141 -c "limit -$type isoft=$is ihard=$ih fsgqa" \
144 # let the timer day transition happen
150 echo "checking timer command (type=$type)"
151 # set 3days+1h for time won't become 2days soon
152 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
153 -c "timer -$type -bi 73h" \
154 $SCRATCH_MNT | _filter_scratch
159 echo "checking disable command (type=$type)"
160 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
161 -c "disable -$type -v" \
162 $SCRATCH_MNT | filter_state
167 echo "checking enable command (type=$type)"
168 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
169 -c "enable -$type -v" $SCRATCH_MNT | filter_state
174 echo "checking off command (type=$type)"
175 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
176 -c "off -$type -v" $SCRATCH_MNT | _filter_scratch
181 echo "checking remove command (type=$type)"
182 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
183 -c "remove -$type -v" \
184 $SCRATCH_MNT | _filter_scratch
189 echo "checking state command (type=$type)"
190 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
191 -c "state -$type" $SCRATCH_MNT | filter_state
196 echo "checking dump command (type=$type)"
197 rm -f $tmp.backup 2>>/dev/null
198 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
199 -c "dump -$type -f $tmp.backup" \
200 $SCRATCH_MNT | _filter_scratch
205 echo "checking restore command (type=$type)"
206 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
207 -c "restore -$type -f $tmp.backup" \
208 $SCRATCH_MNT | _filter_scratch
214 echo "init quota limit and timer, and dump it"
215 echo "create_files 1024k 15"; create_files 1024k 15
216 echo "quota remount"; _qmount
219 echo ; test_limit 512k 2048k 10 20
222 # report options test
223 echo "report options test"
225 echo "-N option"; test_report -N
226 echo "-L -U options"; test_report -L $id -U $id
227 echo "-t option"; test_report -t
228 echo "-n option"; test_report -n
229 echo "-h option"; test_report -h
232 echo "quot options test"
234 echo "-f option"; test_quot -f $tmp.quot
235 cat $tmp.quot | filter_quot
236 echo "-n option"; test_quot -n
240 echo "-f option"; test_quota -f $tmp.quota
241 cat $tmp.quota | filter_quota
242 echo "-N option"; test_quota -N
243 echo "-n option"; test_quota -n
244 echo "-h option"; test_quota -h
246 # disable/enable test
249 echo ; test_report -N
250 echo "expect a remove error at here"; test_remove
252 echo ; test_report -N
254 # off and remove test
255 echo "off and remove test"
256 echo ; test_limit 100m 100m 100 100
261 echo ; test_report -N
262 echo "quota remount"; _qmount
263 echo ; test_report -N
268 echo ; test_report -N
270 echo "cleanup files"; clean_files
273 echo "----------------------- uquota,sync ---------------------------"
274 _qmount_option "uquota,sync"
280 echo "----------------------- gquota,sync ---------------------------"
281 _qmount_option "gquota,sync"
287 echo "----------------------- pquota,sync ---------------------------"
288 # Need to clean the group quota before test project quota, because
289 # V4 xfs doesn't support separate project inode. So mkfs at here.
291 _scratch_mkfs_xfs >>$seqres.full 2>&1
292 _qmount_option "pquota,sync"
296 _require_prjquota $SCRATCH_DEV
297 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
298 -c "project -s $id" \
299 $SCRATCH_MNT > /dev/null