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
50 s/^\#'$id' /[NAME] /g;
51 s/^\#0 \d+ /[ROOT] 0 /g;
55 if ($ENV{'LARGE_SCRATCH_DEV'}) {
56 $val = $ENV{'NUM_SPACE_FILES'};
58 s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g'
61 # The actual point at which limit enforcement takes place for the
62 # hard block limit is variable depending on filesystem blocksize,
63 # and iosize. What we want to test is that the limit is enforced
64 # (ie. blksize less than limit but not unduly less - ~85% is kind)
65 # nowadays we actually get much closer to the limit before EDQUOT.
67 _filter_and_check_blks()
70 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
72 $minimum = '$bhard' * 85/100;
73 if (($1 < $minimum || $1 > $maximum) && '$noextsz') {
74 printf(" URK %d: %d is out of range! [%d,%d]\n",
75 '$id', $1, $minimum, $maximum);
77 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
86 if [ $opt = "u" -o $opt = "uno" ]; then
89 elif [ $opt = "g" -o $opt = "gno" ]; then
92 elif [ $opt = "p" -o $opt = "pno" ]; then
96 [ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
98 echo "Using type=$type id=$id" >> $seqres.full
103 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
104 cat $tmp.mkfs >>$seqres.full
106 # keep the blocksize and data size for dd later
111 # Figure out whether we're doing large allocations
112 # (bail out if they're so large they stuff the test up)
113 _test_inode_flag extsz-inherit $SCRATCH_MNT
115 extsize=`_test_inode_extsz $SCRATCH_MNT`
116 [ $extsize -ge 512000 ] && \
117 _notrun "Extent size hint is too large ($extsize bytes)"
121 echo "Using type=$type id=$id" >>$seqres.full
124 echo "*** report no quota settings" | tee -a $seqres.full
125 xfs_quota -D $tmp.projects -P $tmp.projid -x \
126 -c "repquota -birnN -$type" $SCRATCH_DEV |
127 _filter_report | LC_COLLATE=POSIX sort -ru
130 echo "*** report initial settings" | tee -a $seqres.full
131 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
132 echo "ls -l $SCRATCH_MNT" >>$seqres.full
133 ls -l $SCRATCH_MNT >>$seqres.full
134 xfs_quota -D $tmp.projects -P $temp.projid -x \
135 -c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
136 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
138 xfs_quota -D $tmp.projects -P $tmp.projid -x \
139 -c "repquota -birnN -$type" $SCRATCH_DEV |
140 _filter_report | LC_COLLATE=POSIX sort -ru
143 echo "*** push past the soft inode limit" | tee -a $seqres.full
144 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
145 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
146 _file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
147 _file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
149 xfs_quota -D $tmp.projects -P $tmp.projid -x \
150 -c "repquota -birnN -$type" $SCRATCH_DEV |
151 _filter_report | LC_COLLATE=POSIX sort -ru
154 echo "*** push past the soft block limit" | tee -a $seqres.full
155 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
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 # Note: for quota accounting (not enforcement), EDQUOT is not expected
163 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
164 for i in 1 2 3 4 5 6 7 8 9 10 11 12
166 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
169 xfs_quota -D $tmp.projects -P $tmp.projid -x \
170 -c "repquota -birnN -$type" $SCRATCH_DEV |
171 _filter_report | LC_COLLATE=POSIX sort -ru
174 # Note: for quota accounting (not enforcement), EDQUOT is not expected
175 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
176 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
177 echo "ls -l $SCRATCH_MNT" >>$seqres.full
178 ls -l $SCRATCH_MNT >>$seqres.full
180 xfs_quota -D $tmp.projects -P $tmp.projid -x \
181 -c "repquota -birnN -$type" $SCRATCH_DEV |
182 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
190 cat >$tmp.projects <<EOF
194 cat >$tmp.projid <<EOF
199 projid_file="$tmp.projid"
202 _qmount_option "uquota"
206 _qmount_option "gquota"
209 echo "*** uqnoenforce"
210 _qmount_option "uqnoenforce"
213 echo "*** gqnoenforce"
214 _qmount_option "gqnoenforce"
218 _qmount_option "pquota"
221 echo "*** pqnoenforce"
222 _qmount_option "pqnoenforce"