4 # Exercises basic XFS quota functionality
5 # uquota, gquota, uqnoenforce, gqnoenforce, pquota, pqnoenforce
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
34 status=1 # failure is the default!
36 # get standard environment, filters and checks
44 umount $SCRATCH_MNT 2>/dev/null
47 trap "_cleanup; exit \$status" 0 1 2 3 15
50 # real QA test starts here
52 _supported_os Linux IRIX
55 cp /dev/null $seqres.full
56 chmod a+rwx $seqres.full # arbitrary users will write here
71 s/^\#'$id' /[NAME] /g;
72 s/^\#0 \d+ /[ROOT] 0 /g;
76 if ($ENV{'LARGE_SCRATCH_DEV'}) {
77 $val = $ENV{'NUM_SPACE_FILES'};
79 s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g'
82 # The actual point at which limit enforcement takes place for the
83 # hard block limit is variable depending on filesystem blocksize,
84 # and iosize. What we want to test is that the limit is enforced
85 # (ie. blksize less than limit but not unduly less - ~85% is kind)
86 # nowadays we actually get much closer to the limit before EDQUOT.
88 _filter_and_check_blks()
91 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
93 $minimum = '$bhard' * 85/100;
94 if (($1 < $minimum || $1 > $maximum) && '$noextsz') {
95 printf(" URK %d: %d is out of range! [%d,%d]\n",
96 '$id', $1, $minimum, $maximum);
98 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
105 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
106 cat $tmp.mkfs >>$seqres.full
108 # keep the blocksize and data size for dd later
113 # Figure out whether we're doing large allocations
114 # (bail out if they're so large they stuff the test up)
115 _test_inode_flag extsz-inherit $SCRATCH_MNT
117 extsize=`_test_inode_extsz $SCRATCH_MNT`
118 [ $extsize -ge 512000 ] && \
119 _notrun "Extent size hint is too large ($extsize bytes)"
123 echo "Using output from '" `ls -l $seq.out` "'" >>$seqres.full
124 echo "and using type=$type id=$id" >>$seqres.full
127 echo "*** report no quota settings" | tee -a $seqres.full
128 xfs_quota -D $tmp.projects -P $tmp.projid -x \
129 -c "repquota -birnN -$type" $SCRATCH_DEV |
130 _filter_report | LC_COLLATE=POSIX sort -ru
133 echo "*** report initial settings" | tee -a $seqres.full
134 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
135 echo "ls -l $SCRATCH_MNT" >>$seqres.full
136 ls -l $SCRATCH_MNT >>$seqres.full
137 xfs_quota -D $tmp.projects -P $temp.projid -x \
138 -c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
139 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
141 xfs_quota -D $tmp.projects -P $tmp.projid -x \
142 -c "repquota -birnN -$type" $SCRATCH_DEV |
143 _filter_report | LC_COLLATE=POSIX sort -ru
146 echo "*** push past the soft inode limit" | tee -a $seqres.full
147 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
148 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
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 block limit" | tee -a $seqres.full
156 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
158 xfs_quota -D $tmp.projects -P $tmp.projid -x \
159 -c "repquota -birnN -$type" $SCRATCH_DEV |
160 _filter_report | LC_COLLATE=POSIX sort -ru
163 # Note: for quota accounting (not enforcement), EDQUOT is not expected
164 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
165 for i in 1 2 3 4 5 6 7 8 9 10 11 12
167 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
170 xfs_quota -D $tmp.projects -P $tmp.projid -x \
171 -c "repquota -birnN -$type" $SCRATCH_DEV |
172 _filter_report | LC_COLLATE=POSIX sort -ru
175 # Note: for quota accounting (not enforcement), EDQUOT is not expected
176 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
177 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
178 echo "ls -l $SCRATCH_MNT" >>$seqres.full
179 ls -l $SCRATCH_MNT >>$seqres.full
181 xfs_quota -D $tmp.projects -P $tmp.projid -x \
182 -c "repquota -birnN -$type" $SCRATCH_DEV |
183 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
191 cat >$tmp.projects <<EOF
195 cat >$tmp.projid <<EOF
200 projid_file="$tmp.projid"
203 if [ "$HOSTOS" == "IRIX" ]
205 _qmount_option "quota"
207 _qmount_option "uquota"
212 _qmount_option "gquota"
215 echo "*** uqnoenforce"
216 if [ "$HOSTOS" == "IRIX" ]
218 _qmount_option "qnoenforce"
220 _qmount_option "uqnoenforce"
224 echo "*** gqnoenforce"
225 _qmount_option "gqnoenforce"
229 _qmount_option "pquota"
232 echo "*** pqnoenforce"
233 _qmount_option "pqnoenforce"