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 ))
50 # The actual point at which limit enforcement takes place for the
51 # hard block limit is variable depending on filesystem blocksize,
52 # and iosize. What we want to test is that the limit is enforced
53 # (ie. blksize less than limit but not unduly less - ~85% is kind)
54 # nowadays we actually get much closer to the limit before EDQUOT.
56 _filter_and_check_blks()
59 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
61 $minimum = '$bhard' * 85/100;
63 if (($used < $minimum || $used > $maximum) && '$noextsz') {
64 printf(" URK %d: %d is out of range! [%d,%d]\n",
65 '$id', $used, $minimum, $maximum);
67 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
69 ' | _filter_quota_report
76 if [ $opt = "u" -o $opt = "uno" ]; then
79 elif [ $opt = "g" -o $opt = "gno" ]; then
82 elif [ $opt = "p" -o $opt = "pno" ]; then
86 [ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
88 echo "Using type=$type id=$id" >> $seqres.full
93 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
94 cat $tmp.mkfs >>$seqres.full
96 # keep the blocksize and data size for dd later
101 # Figure out whether we're doing large allocations
102 # (bail out if they're so large they stuff the test up)
103 _test_inode_flag extsz-inherit $SCRATCH_MNT
105 extsize=`_test_inode_extsz $SCRATCH_MNT`
106 [ $extsize -ge 512000 ] && \
107 _notrun "Extent size hint is too large ($extsize bytes)"
111 echo "Using type=$type id=$id" >>$seqres.full
113 $XFS_QUOTA_PROG -x -c "warn -$type 65535 -d" $SCRATCH_DEV
116 echo "*** report no quota settings" | tee -a $seqres.full
117 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
118 -c "repquota -birnN -$type" $SCRATCH_DEV |
119 _filter_quota_report | LC_COLLATE=POSIX sort -ru
122 echo "*** report initial settings" | tee -a $seqres.full
123 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
124 echo "ls -l $SCRATCH_MNT" >>$seqres.full
125 ls -l $SCRATCH_MNT >>$seqres.full
126 $XFS_QUOTA_PROG -D $tmp.projects -P $temp.projid -x \
127 -c "limit -$type bsoft=${bsoft} bhard=${bhard} $id" \
128 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
130 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
131 -c "repquota -birnN -$type" $SCRATCH_DEV |
132 _filter_quota_report | LC_COLLATE=POSIX sort -ru
135 echo "*** push past the soft inode limit" | tee -a $seqres.full
136 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
137 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
138 _file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
139 _file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
141 $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
142 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
143 -c "repquota -birnN -$type" $SCRATCH_DEV |
144 _filter_quota_report | LC_COLLATE=POSIX sort -ru
147 echo "*** push past the soft block limit" | tee -a $seqres.full
148 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 300
150 $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" \
151 -c "warn -b -$type 0 $id" $SCRATCH_DEV
152 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
153 -c "repquota -birnN -$type" $SCRATCH_DEV |
154 _filter_quota_report | LC_COLLATE=POSIX sort -ru
157 # Note: for quota accounting (not enforcement), EDQUOT is not expected
158 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
159 for i in 1 2 3 4 5 6 7 8 9 10 11 12
161 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
164 $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" \
165 -c "warn -i -$type 0 $id" $SCRATCH_DEV
166 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
167 -c "repquota -birnN -$type" $SCRATCH_DEV |
168 _filter_quota_report | LC_COLLATE=POSIX sort -ru
171 # Note: for quota accounting (not enforcement), EDQUOT is not expected
172 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
173 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 1200
174 echo "ls -l $SCRATCH_MNT" >>$seqres.full
175 ls -l $SCRATCH_MNT >>$seqres.full
177 $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" $SCRATCH_DEV
178 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
179 -c "repquota -birnN -$type" $SCRATCH_DEV |
180 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
188 cat >$tmp.projects <<EOF
192 cat >$tmp.projid <<EOF
197 projid_file="$tmp.projid"
200 _qmount_option "uquota"
204 _qmount_option "gquota"
207 echo "*** uqnoenforce"
208 _qmount_option "uqnoenforce"
211 echo "*** gqnoenforce"
212 _qmount_option "gqnoenforce"
216 _qmount_option "pquota"
219 echo "*** pqnoenforce"
220 _qmount_option "pqnoenforce"