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 #-----------------------------------------------------------------------
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
35 # get standard environment, filters and checks
43 umount $SCRATCH_MNT 2>/dev/null
46 trap "_cleanup; exit \$status" 0 1 2 3 15
49 # real QA test starts here
51 _supported_os Linux IRIX
54 cp /dev/null $seq.full
55 chmod a+rwx $seq.full # arbitrary users will write here
70 s/^\#'$id' /[NAME] /g;
71 s/^\#0 \d+ /[ROOT] 0 /g;
75 # The actual point at which limit enforcement takes place for the
76 # hard block limit is variable depending on filesystem blocksize,
77 # and iosize. What we want to test is that the limit is enforced
78 # (ie. blksize less than limit but not unduly less - ~85% is kind)
79 # nowadays we actually get much closer to the limit before EDQUOT.
81 _filter_and_check_blks()
84 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
86 $minimum = '$bhard' * 85/100;
87 if (($1 < $minimum || $1 > $maximum) && '$noextsz') {
88 printf(" URK %d: %d is out of range! [%d,%d]\n",
89 '$id', $1, $minimum, $maximum);
91 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
98 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
99 cat $tmp.mkfs >>$seq.full
101 # keep the blocksize and data size for dd later
106 # Figure out whether we're doing large allocations
107 # (bail out if they're so large they stuff the test up)
108 _test_inode_flag extsz-inherit $SCRATCH_MNT
110 extsize=`_test_inode_extsz $SCRATCH_MNT`
111 [ $extsize -ge 512000 ] && \
112 _notrun "Extent size hint is too large ($extsize bytes)"
116 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
117 echo "and using type=$type id=$id" >>$seq.full
120 echo "*** report no quota settings" | tee -a $seq.full
121 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report | LC_COLLATE=POSIX sort -r
124 echo "*** report initial settings" | tee -a $seq.full
125 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
126 echo "ls -l $SCRATCH_MNT" >>$seq.full
127 ls -l $SCRATCH_MNT >>$seq.full
128 xfs_quota -D $tmp.projects -P $temp.projid -x \
129 -c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
130 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
132 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report | LC_COLLATE=POSIX sort -r
135 echo "*** push past the soft inode limit" | tee -a $seq.full
136 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
137 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
139 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report | LC_COLLATE=POSIX sort -r
142 echo "*** push past the soft block limit" | tee -a $seq.full
143 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
145 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report | LC_COLLATE=POSIX sort -r
148 # Note: for quota accounting (not enforcement), EDQUOT is not expected
149 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
150 for i in 1 2 3 4 5 6 7 8 9 10 11 12
152 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
155 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report | LC_COLLATE=POSIX sort -r
158 # Note: for quota accounting (not enforcement), EDQUOT is not expected
159 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
160 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
161 echo "ls -l $SCRATCH_MNT" >>$seq.full
162 ls -l $SCRATCH_MNT >>$seq.full
164 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_and_check_blks | LC_COLLATE=POSIX sort -r
172 cat >$tmp.projects <<EOF
176 cat >$tmp.projid <<EOF
181 projid_file="$tmp.projid"
184 if [ "$HOSTOS" == "IRIX" ]
186 _qmount_option "quota"
188 _qmount_option "uquota"
193 _qmount_option "gquota"
196 echo "*** uqnoenforce"
197 if [ "$HOSTOS" == "IRIX" ]
199 _qmount_option "qnoenforce"
201 _qmount_option "uqnoenforce"
205 echo "*** gqnoenforce"
206 _qmount_option "gqnoenforce"
210 _qmount_option "pquota"
213 echo "*** pqnoenforce"
214 _qmount_option "pqnoenforce"