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
35 cp /dev/null $seqres.full
36 chmod a+rwx $seqres.full # arbitrary users will write here
41 _scratch_mkfs >/dev/null 2>&1
43 bsize=$(_get_file_block_size $SCRATCH_MNT)
46 bsoft=$(( 200 * $bsize ))
47 bhard=$(( 1000 * $bsize ))
55 s/^\#'$id' /[NAME] /g;
56 s/^\#0 \d+ /[ROOT] 0 /g;
60 if ($ENV{'LARGE_SCRATCH_DEV'}) {
61 $val = $ENV{'NUM_SPACE_FILES'};
63 s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/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
132 echo "*** report no quota settings" | tee -a $seqres.full
133 xfs_quota -D $tmp.projects -P $tmp.projid -x \
134 -c "repquota -birnN -$type" $SCRATCH_DEV |
135 _filter_report | LC_COLLATE=POSIX sort -ru
138 echo "*** report initial settings" | tee -a $seqres.full
139 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
140 echo "ls -l $SCRATCH_MNT" >>$seqres.full
141 ls -l $SCRATCH_MNT >>$seqres.full
142 xfs_quota -D $tmp.projects -P $temp.projid -x \
143 -c "limit -$type bsoft=${bsoft} bhard=${bhard} $id" \
144 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
146 xfs_quota -D $tmp.projects -P $tmp.projid -x \
147 -c "repquota -birnN -$type" $SCRATCH_DEV |
148 _filter_report | LC_COLLATE=POSIX sort -ru
151 echo "*** push past the soft inode limit" | tee -a $seqres.full
152 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
153 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
154 _file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
155 _file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
157 xfs_quota -D $tmp.projects -P $tmp.projid -x \
158 -c "repquota -birnN -$type" $SCRATCH_DEV |
159 _filter_report | LC_COLLATE=POSIX sort -ru
162 echo "*** push past the soft block limit" | tee -a $seqres.full
163 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 300
165 xfs_quota -D $tmp.projects -P $tmp.projid -x \
166 -c "repquota -birnN -$type" $SCRATCH_DEV |
167 _filter_report | LC_COLLATE=POSIX sort -ru
170 # Note: for quota accounting (not enforcement), EDQUOT is not expected
171 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
172 for i in 1 2 3 4 5 6 7 8 9 10 11 12
174 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
177 xfs_quota -D $tmp.projects -P $tmp.projid -x \
178 -c "repquota -birnN -$type" $SCRATCH_DEV |
179 _filter_report | LC_COLLATE=POSIX sort -ru
182 # Note: for quota accounting (not enforcement), EDQUOT is not expected
183 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
184 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 1200
185 echo "ls -l $SCRATCH_MNT" >>$seqres.full
186 ls -l $SCRATCH_MNT >>$seqres.full
188 xfs_quota -D $tmp.projects -P $tmp.projid -x \
189 -c "repquota -birnN -$type" $SCRATCH_DEV |
190 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
198 cat >$tmp.projects <<EOF
202 cat >$tmp.projid <<EOF
207 projid_file="$tmp.projid"
210 _qmount_option "uquota"
214 _qmount_option "gquota"
217 echo "*** uqnoenforce"
218 _qmount_option "uqnoenforce"
221 echo "*** gqnoenforce"
222 _qmount_option "gqnoenforce"
226 _qmount_option "pquota"
229 echo "*** pqnoenforce"
230 _qmount_option "pqnoenforce"