2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # Exercises basic XFS quota functionality
8 # uquota, gquota, uqnoenforce, gqnoenforce, pquota, pqnoenforce
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
18 # get standard environment, filters and checks
26 _scratch_unmount 2>/dev/null
29 trap "_cleanup; exit \$status" 0 1 2 3 15
31 # real QA test starts here
34 cp /dev/null $seqres.full
35 chmod a+rwx $seqres.full # arbitrary users will write here
40 _scratch_mkfs >/dev/null 2>&1
42 bsize=$(_get_file_block_size $SCRATCH_MNT)
45 bsoft=$(( 200 * $bsize ))
46 bhard=$(( 1000 * $bsize ))
54 s/^\#'$id' /[NAME] /g;
55 s/^\#0 \d+ /[ROOT] 0 /g;
59 if ($ENV{'LARGE_SCRATCH_DEV'}) {
60 $val = $ENV{'NUM_SPACE_FILES'};
62 s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g' |
63 sed -e 's/ 65535 \[--------\]/ 00 \[--------\]/g' |
65 s|^(.*?) (\d+) (\d+) (\d+)|$1 @{[$2 * 1024 /'$bsize']} @{[$3 * 1024 /'$bsize']} @{[$4 * 1024 /'$bsize']}|'
68 # The actual point at which limit enforcement takes place for the
69 # hard block limit is variable depending on filesystem blocksize,
70 # and iosize. What we want to test is that the limit is enforced
71 # (ie. blksize less than limit but not unduly less - ~85% is kind)
72 # nowadays we actually get much closer to the limit before EDQUOT.
74 _filter_and_check_blks()
77 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
79 $minimum = '$bhard' * 85/100;
81 if (($used < $minimum || $used > $maximum) && '$noextsz') {
82 printf(" URK %d: %d is out of range! [%d,%d]\n",
83 '$id', $used, $minimum, $maximum);
85 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
94 if [ $opt = "u" -o $opt = "uno" ]; then
97 elif [ $opt = "g" -o $opt = "gno" ]; then
100 elif [ $opt = "p" -o $opt = "pno" ]; then
104 [ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
106 echo "Using type=$type id=$id" >> $seqres.full
111 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
112 cat $tmp.mkfs >>$seqres.full
114 # keep the blocksize and data size for dd later
119 # Figure out whether we're doing large allocations
120 # (bail out if they're so large they stuff the test up)
121 _test_inode_flag extsz-inherit $SCRATCH_MNT
123 extsize=`_test_inode_extsz $SCRATCH_MNT`
124 [ $extsize -ge 512000 ] && \
125 _notrun "Extent size hint is too large ($extsize bytes)"
129 echo "Using type=$type id=$id" >>$seqres.full
131 $XFS_QUOTA_PROG -x -c "warn -$type 65535 -d" $SCRATCH_DEV
134 echo "*** report no quota settings" | tee -a $seqres.full
135 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
136 -c "repquota -birnN -$type" $SCRATCH_DEV |
137 _filter_report | LC_COLLATE=POSIX sort -ru
140 echo "*** report initial settings" | tee -a $seqres.full
141 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
142 echo "ls -l $SCRATCH_MNT" >>$seqres.full
143 ls -l $SCRATCH_MNT >>$seqres.full
144 $XFS_QUOTA_PROG -D $tmp.projects -P $temp.projid -x \
145 -c "limit -$type bsoft=${bsoft} bhard=${bhard} $id" \
146 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
148 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
149 -c "repquota -birnN -$type" $SCRATCH_DEV |
150 _filter_report | LC_COLLATE=POSIX sort -ru
153 echo "*** push past the soft inode limit" | tee -a $seqres.full
154 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
155 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
156 _file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
157 _file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
159 $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
160 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
161 -c "repquota -birnN -$type" $SCRATCH_DEV |
162 _filter_report | LC_COLLATE=POSIX sort -ru
165 echo "*** push past the soft block limit" | tee -a $seqres.full
166 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 300
168 $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" \
169 -c "warn -b -$type 0 $id" $SCRATCH_DEV
170 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
171 -c "repquota -birnN -$type" $SCRATCH_DEV |
172 _filter_report | LC_COLLATE=POSIX sort -ru
175 # Note: for quota accounting (not enforcement), EDQUOT is not expected
176 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
177 for i in 1 2 3 4 5 6 7 8 9 10 11 12
179 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
182 $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" \
183 -c "warn -i -$type 0 $id" $SCRATCH_DEV
184 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
185 -c "repquota -birnN -$type" $SCRATCH_DEV |
186 _filter_report | LC_COLLATE=POSIX sort -ru
189 # Note: for quota accounting (not enforcement), EDQUOT is not expected
190 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
191 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 1200
192 echo "ls -l $SCRATCH_MNT" >>$seqres.full
193 ls -l $SCRATCH_MNT >>$seqres.full
195 $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" $SCRATCH_DEV
196 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
197 -c "repquota -birnN -$type" $SCRATCH_DEV |
198 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
206 cat >$tmp.projects <<EOF
210 cat >$tmp.projid <<EOF
215 projid_file="$tmp.projid"
218 _qmount_option "uquota"
222 _qmount_option "gquota"
225 echo "*** uqnoenforce"
226 _qmount_option "uqnoenforce"
229 echo "*** gqnoenforce"
230 _qmount_option "gqnoenforce"
234 _qmount_option "pquota"
237 echo "*** pqnoenforce"
238 _qmount_option "pqnoenforce"