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
48 s/^\#'$id' /[NAME] /g;
49 s/^\#0 \d+ /[ROOT] 0 /g;
53 if ($ENV{'LARGE_SCRATCH_DEV'}) {
54 $val = $ENV{'NUM_SPACE_FILES'};
56 s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g' |
58 s|^(.*?) (\d+) (\d+) (\d+)|$1 @{[$2 * 1024 /'$bsize']} @{[$3 * 1024 /'$bsize']} @{[$4 * 1024 /'$bsize']}|'
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;
74 if (($used < $minimum || $used > $maximum) && '$noextsz') {
75 printf(" URK %d: %d is out of range! [%d,%d]\n",
76 '$id', $used, $minimum, $maximum);
78 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
87 if [ $opt = "u" -o $opt = "uno" ]; then
90 elif [ $opt = "g" -o $opt = "gno" ]; then
93 elif [ $opt = "p" -o $opt = "pno" ]; then
97 [ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
99 echo "Using type=$type id=$id" >> $seqres.full
105 # Figure out whether we're doing large allocations
106 # (bail out if they're so large they stuff the test up)
107 _test_inode_flag extsz-inherit $SCRATCH_MNT
109 extsize=`_test_inode_extsz $SCRATCH_MNT`
110 [ $extsize -ge 512000 ] && \
111 _notrun "Extent size hint is too large ($extsize bytes)"
115 echo "Using type=$type id=$id" >>$seqres.full
118 echo "*** report no quota settings" | tee -a $seqres.full
119 xfs_quota -D $tmp.projects -P $tmp.projid -x \
120 -c "repquota -birnN -$type" $SCRATCH_DEV |
121 _filter_report | LC_COLLATE=POSIX sort -ru
124 echo "*** report initial settings" | tee -a $seqres.full
125 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
126 echo "ls -l $SCRATCH_MNT" >>$seqres.full
127 ls -l $SCRATCH_MNT >>$seqres.full
128 xfs_quota -D $tmp.projects -P $tmp.projid -x \
129 -c "limit -$type bsoft=${bsoft} bhard=${bhard} $id" \
130 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
132 xfs_quota -D $tmp.projects -P $tmp.projid -x \
133 -c "repquota -birnN -$type" $SCRATCH_DEV |
134 _filter_report | LC_COLLATE=POSIX sort -ru
137 echo "*** push past the soft inode limit" | tee -a $seqres.full
138 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
139 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
140 _file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
141 _file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
143 xfs_quota -D $tmp.projects -P $tmp.projid -x \
144 -c "repquota -birnN -$type" $SCRATCH_DEV |
145 _filter_report | LC_COLLATE=POSIX sort -ru
148 echo "*** push past the soft block limit" | tee -a $seqres.full
149 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 200
151 xfs_quota -D $tmp.projects -P $tmp.projid -x \
152 -c "repquota -birnN -$type" $SCRATCH_DEV |
153 _filter_report | LC_COLLATE=POSIX sort -ru
156 # Note: for quota accounting (not enforcement), EDQUOT is not expected
157 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
158 for i in 1 2 3 4 5 6 7 8 9 10 11 12
160 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
163 xfs_quota -D $tmp.projects -P $tmp.projid -x \
164 -c "repquota -birnN -$type" $SCRATCH_DEV |
165 _filter_report | LC_COLLATE=POSIX sort -ru
168 # Note: for quota accounting (not enforcement), EDQUOT is not expected
169 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
170 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 600
171 echo "ls -l $SCRATCH_MNT" >>$seqres.full
172 ls -l $SCRATCH_MNT >>$seqres.full
174 xfs_quota -D $tmp.projects -P $tmp.projid -x \
175 -c "repquota -birnN -$type" $SCRATCH_DEV |
176 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
180 # clean up our files so we don't pollute the next run
185 _scratch_mkfs_xfs -m crc=1 2>/dev/null | _filter_mkfs 2>$tmp.mkfs
186 cat $tmp.mkfs >>$seqres.full
187 # keep the blocksize and data size for dd later
190 cat >$tmp.projects <<EOF
194 cat >$tmp.projid <<EOF
199 projid_file="$tmp.projid"
201 echo "*** user, group, and project"
202 _qmount_option "uquota,gquota,pquota"
205 bsize=$(_get_file_block_size $SCRATCH_MNT)
207 bsoft=$(( 100 * $bsize ))
208 bhard=$(( 500 * $bsize ))
212 # non-root users need to be able to write to this filesystem
213 chmod 777 $SCRATCH_MNT
223 _scratch_mkfs_xfs -m crc=1 2>/dev/null | _filter_mkfs 2>$tmp.mkfs
224 cat $tmp.mkfs >>$seqres.full
225 # keep the blocksize and data size for dd later
228 echo "*** uqnoenforce, gqnoenforce, and pqnoenforce"
229 _qmount_option "uqnoenforce,gqnoenforce,pqnoenforce"