4 # Exercises basic XFS quota functionality, with all 3 quotas together
5 # uquota, gquota, pquota
6 # uqnoenforce, gqnoenforce, pqnoenforce
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
35 # get standard environment, filters and checks
43 _scratch_unmount 2>/dev/null
46 trap "_cleanup; exit \$status" 0 1 2 3 15
48 # real QA test starts here
52 cp /dev/null $seqres.full
53 chmod a+rwx $seqres.full # arbitrary users will write here
69 s/^\#'$id' /[NAME] /g;
70 s/^\#0 \d+ /[ROOT] 0 /g;
74 if ($ENV{'LARGE_SCRATCH_DEV'}) {
75 $val = $ENV{'NUM_SPACE_FILES'};
77 s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g'
80 # The actual point at which limit enforcement takes place for the
81 # hard block limit is variable depending on filesystem blocksize,
82 # and iosize. What we want to test is that the limit is enforced
83 # (ie. blksize less than limit but not unduly less - ~85% is kind)
84 # nowadays we actually get much closer to the limit before EDQUOT.
86 _filter_and_check_blks()
89 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
91 $minimum = '$bhard' * 85/100;
92 if (($1 < $minimum || $1 > $maximum) && '$noextsz') {
93 printf(" URK %d: %d is out of range! [%d,%d]\n",
94 '$id', $1, $minimum, $maximum);
96 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
105 if [ $opt = "u" -o $opt = "uno" ]; then
108 elif [ $opt = "g" -o $opt = "gno" ]; then
111 elif [ $opt = "p" -o $opt = "pno" ]; then
115 [ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
117 echo "Using type=$type id=$id" >> $seqres.full
123 # Figure out whether we're doing large allocations
124 # (bail out if they're so large they stuff the test up)
125 _test_inode_flag extsz-inherit $SCRATCH_MNT
127 extsize=`_test_inode_extsz $SCRATCH_MNT`
128 [ $extsize -ge 512000 ] && \
129 _notrun "Extent size hint is too large ($extsize bytes)"
133 echo "Using type=$type id=$id" >>$seqres.full
136 echo "*** report no quota settings" | tee -a $seqres.full
137 xfs_quota -D $tmp.projects -P $tmp.projid -x \
138 -c "repquota -birnN -$type" $SCRATCH_DEV |
139 _filter_report | LC_COLLATE=POSIX sort -ru
142 echo "*** report initial settings" | tee -a $seqres.full
143 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
144 echo "ls -l $SCRATCH_MNT" >>$seqres.full
145 ls -l $SCRATCH_MNT >>$seqres.full
146 xfs_quota -D $tmp.projects -P $temp.projid -x \
147 -c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
148 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
150 xfs_quota -D $tmp.projects -P $tmp.projid -x \
151 -c "repquota -birnN -$type" $SCRATCH_DEV |
152 _filter_report | LC_COLLATE=POSIX sort -ru
155 echo "*** push past the soft inode limit" | tee -a $seqres.full
156 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
157 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
159 xfs_quota -D $tmp.projects -P $tmp.projid -x \
160 -c "repquota -birnN -$type" $SCRATCH_DEV |
161 _filter_report | LC_COLLATE=POSIX sort -ru
164 echo "*** push past the soft block limit" | tee -a $seqres.full
165 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
167 xfs_quota -D $tmp.projects -P $tmp.projid -x \
168 -c "repquota -birnN -$type" $SCRATCH_DEV |
169 _filter_report | LC_COLLATE=POSIX sort -ru
172 # Note: for quota accounting (not enforcement), EDQUOT is not expected
173 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
174 for i in 1 2 3 4 5 6 7 8 9 10 11 12
176 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
179 xfs_quota -D $tmp.projects -P $tmp.projid -x \
180 -c "repquota -birnN -$type" $SCRATCH_DEV |
181 _filter_report | LC_COLLATE=POSIX sort -ru
184 # Note: for quota accounting (not enforcement), EDQUOT is not expected
185 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
186 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
187 echo "ls -l $SCRATCH_MNT" >>$seqres.full
188 ls -l $SCRATCH_MNT >>$seqres.full
190 xfs_quota -D $tmp.projects -P $tmp.projid -x \
191 -c "repquota -birnN -$type" $SCRATCH_DEV |
192 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
196 # clean up our files so we don't pollute the next run
201 _scratch_mkfs_xfs -m crc=1 2>/dev/null | _filter_mkfs 2>$tmp.mkfs
202 cat $tmp.mkfs >>$seqres.full
203 # keep the blocksize and data size for dd later
206 # non-root users need to be able to write to this filesystem
207 chmod 777 $SCRATCH_MNT
209 cat >$tmp.projects <<EOF
213 cat >$tmp.projid <<EOF
218 projid_file="$tmp.projid"
220 echo "*** user, group, and project"
221 _qmount_option "uquota,gquota,pquota"
231 _scratch_mkfs_xfs -m crc=1 2>/dev/null | _filter_mkfs 2>$tmp.mkfs
232 cat $tmp.mkfs >>$seqres.full
233 # keep the blocksize and data size for dd later
236 echo "*** uqnoenforce, gqnoenforce, and pqnoenforce"
237 _qmount_option "uqnoenforce,gqnoenforce,pqnoenforce"