2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # Exercises basic XFS quota functionality, with all 3 quotas together
8 # uquota, gquota, pquota
9 # uqnoenforce, gqnoenforce, pqnoenforce
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
19 # get standard environment, filters and checks
27 _scratch_unmount 2>/dev/null
30 trap "_cleanup; exit \$status" 0 1 2 3 15
32 # real QA test starts here
36 cp /dev/null $seqres.full
37 chmod a+rwx $seqres.full # arbitrary users will write here
53 s/^\#'$id' /[NAME] /g;
54 s/^\#0 \d+ /[ROOT] 0 /g;
58 if ($ENV{'LARGE_SCRATCH_DEV'}) {
59 $val = $ENV{'NUM_SPACE_FILES'};
61 s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g'
64 # The actual point at which limit enforcement takes place for the
65 # hard block limit is variable depending on filesystem blocksize,
66 # and iosize. What we want to test is that the limit is enforced
67 # (ie. blksize less than limit but not unduly less - ~85% is kind)
68 # nowadays we actually get much closer to the limit before EDQUOT.
70 _filter_and_check_blks()
73 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
75 $minimum = '$bhard' * 85/100;
76 if (($1 < $minimum || $1 > $maximum) && '$noextsz') {
77 printf(" URK %d: %d is out of range! [%d,%d]\n",
78 '$id', $1, $minimum, $maximum);
80 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
89 if [ $opt = "u" -o $opt = "uno" ]; then
92 elif [ $opt = "g" -o $opt = "gno" ]; then
95 elif [ $opt = "p" -o $opt = "pno" ]; then
99 [ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
101 echo "Using type=$type id=$id" >> $seqres.full
107 # Figure out whether we're doing large allocations
108 # (bail out if they're so large they stuff the test up)
109 _test_inode_flag extsz-inherit $SCRATCH_MNT
111 extsize=`_test_inode_extsz $SCRATCH_MNT`
112 [ $extsize -ge 512000 ] && \
113 _notrun "Extent size hint is too large ($extsize bytes)"
117 echo "Using type=$type id=$id" >>$seqres.full
120 echo "*** report no quota settings" | tee -a $seqres.full
121 xfs_quota -D $tmp.projects -P $tmp.projid -x \
122 -c "repquota -birnN -$type" $SCRATCH_DEV |
123 _filter_report | LC_COLLATE=POSIX sort -ru
126 echo "*** report initial settings" | tee -a $seqres.full
127 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
128 echo "ls -l $SCRATCH_MNT" >>$seqres.full
129 ls -l $SCRATCH_MNT >>$seqres.full
130 xfs_quota -D $tmp.projects -P $tmp.projid -x \
131 -c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
132 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
134 xfs_quota -D $tmp.projects -P $tmp.projid -x \
135 -c "repquota -birnN -$type" $SCRATCH_DEV |
136 _filter_report | LC_COLLATE=POSIX sort -ru
139 echo "*** push past the soft inode limit" | tee -a $seqres.full
140 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
141 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
142 _file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
143 _file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
145 xfs_quota -D $tmp.projects -P $tmp.projid -x \
146 -c "repquota -birnN -$type" $SCRATCH_DEV |
147 _filter_report | LC_COLLATE=POSIX sort -ru
150 echo "*** push past the soft block limit" | tee -a $seqres.full
151 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
153 xfs_quota -D $tmp.projects -P $tmp.projid -x \
154 -c "repquota -birnN -$type" $SCRATCH_DEV |
155 _filter_report | LC_COLLATE=POSIX sort -ru
158 # Note: for quota accounting (not enforcement), EDQUOT is not expected
159 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
160 for i in 1 2 3 4 5 6 7 8 9 10 11 12
162 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
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 block limit (expect EDQUOT)" | tee -a $seqres.full
172 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
173 echo "ls -l $SCRATCH_MNT" >>$seqres.full
174 ls -l $SCRATCH_MNT >>$seqres.full
176 xfs_quota -D $tmp.projects -P $tmp.projid -x \
177 -c "repquota -birnN -$type" $SCRATCH_DEV |
178 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
182 # clean up our files so we don't pollute the next run
187 _scratch_mkfs_xfs -m crc=1 2>/dev/null | _filter_mkfs 2>$tmp.mkfs
188 cat $tmp.mkfs >>$seqres.full
189 # keep the blocksize and data size for dd later
192 cat >$tmp.projects <<EOF
196 cat >$tmp.projid <<EOF
201 projid_file="$tmp.projid"
203 echo "*** user, group, and project"
204 _qmount_option "uquota,gquota,pquota"
207 # non-root users need to be able to write to this filesystem
208 chmod 777 $SCRATCH_MNT
218 _scratch_mkfs_xfs -m crc=1 2>/dev/null | _filter_mkfs 2>$tmp.mkfs
219 cat $tmp.mkfs >>$seqres.full
220 # keep the blocksize and data size for dd later
223 echo "*** uqnoenforce, gqnoenforce, and pqnoenforce"
224 _qmount_option "uqnoenforce,gqnoenforce,pqnoenforce"