4 # Exercises basic XFS quota functionality
5 # MOUNT_OPTIONS env var switches the test type (uid/gid/acct/enfd)
6 # options are: (-o) uquota, gquota, uqnoenforce, gqnoenforce
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or modify it
12 # under the terms of version 2 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, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 # Further, this software is distributed without any warranty that it is
20 # free of the rightful claim of any third person regarding infringement
21 # or the like. Any license provided herein, whether implied or
22 # otherwise, applies only to this software file. Patent licenses, if
23 # any, provided herein do not apply to combinations of this program with
24 # other software, or any other product whatsoever.
26 # You should have received a copy of the GNU General Public License along
27 # with this program; if not, write the Free Software Foundation, Inc., 59
28 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
30 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
31 # Mountain View, CA 94043, or:
35 # For further information regarding this notice, see:
37 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
38 #-----------------------------------------------------------------------
44 echo "QA output created by $seq"
48 status=1 # failure is the default!
50 # get standard environment, filters and checks
58 echo; echo "*** unmount"
59 umount $SCRATCH_MNT 2>/dev/null
62 trap "_cleanup; exit \$status" 0 1 2 3 15
65 # real QA test starts here
67 _supported_os Linux IRIX
70 cp /dev/null $seq.full
71 chmod a+rwx $seq.full # arbitrary users will write here
77 if [ -z "$MOUNT_OPTIONS" ]; then
78 export MOUNT_OPTIONS="-o uquota"
86 # The actual point at which limit enforcement takes place for the
87 # hard block limit is variable depending on filesystem blocksize,
88 # and iosize. What we want to test is that the limit is enforced
89 # (ie. blksize less than limit but not unduly less - ~85% is kind)
90 # nowadays we actually get much closer to the limit before EDQUOT.
92 _filter_and_check_blocks()
95 if (/^'$name'\s+([-|+]){2}\s+(\d+)/ && '$enforce') {
96 $maximum = '$blkhard';
97 $minimum = '$blkhard' * 85/100;
98 if ($2 < $minimum || $2 > $maximum) {
99 printf(" URK - %d is out of range! [%d,%d] \n",
100 $2, $minimum, $maximum);
102 s/^('$name'\s+[-|+][-|+]\s+)(\d+)/\1 OK/g;
107 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
108 cat $tmp.mkfs >>$seq.full
110 # keep the blocksize and data size for dd later
115 # Irix uses filesystem name and Linux uses device of filesystem
116 if [ $HOSTOS = "Linux" ]; then
117 QUOTA_FS=$SCRATCH_DEV
119 QUOTA_FS=$SCRATCH_MNT
122 # setup exactly what it is we'll be testing
124 if src/feature -u $SCRATCH_DEV
126 type=u ; eval `_choose_uid`; ln -s $seq.usrquota $seq.out
127 elif src/feature -g $SCRATCH_DEV
129 type=g ; eval `_choose_gid`; ln -s $seq.grpquota $seq.out
130 elif src/feature -U $SCRATCH_DEV
132 type=u ; eval `_choose_uid`; ln -s $seq.uqnoenforce $seq.out
134 elif src/feature -G $SCRATCH_DEV
136 type=g ; eval `_choose_gid`; ln -s $seq.gqnoenforce $seq.out
139 _notrun "No quota support at mount time"
142 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
143 echo "and using type=$type id=$id" >>$seq.full
146 echo "*** report no quota settings" | tee -a $seq.full
147 _repquota -$type $QUOTA_FS | _filter_repquota
150 echo "*** report initial settings" | tee -a $seq.full
151 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
152 echo "ls -l $SCRATCH_MNT" >>$seq.full
153 ls -l $SCRATCH_MNT >>$seq.full
154 _setquota -$type $id $blksoft $blkhard $inosoft $inohard $QUOTA_FS
155 _repquota -$type $QUOTA_FS | _filter_repquota
158 echo "*** push past the soft inode limit" | tee -a $seq.full
159 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
160 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
162 _repquota -$type $QUOTA_FS | _filter_repquota
165 echo "*** push past the soft block limit" | tee -a $seq.full
166 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
168 _repquota -$type $QUOTA_FS | _filter_repquota
171 # Note: for quota accounting (not enforcement), EDQUOT is not expected
172 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
173 for i in 1 2 3 4 5 6 7 8 9 10 11 12
175 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
178 _repquota -$type $QUOTA_FS | _filter_repquota
181 # Note: for quota accounting (not enforcement), EDQUOT is not expected
182 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
183 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
184 echo "ls -l $SCRATCH_MNT" >>$seq.full
185 ls -l $SCRATCH_MNT >>$seq.full
187 _repquota -$type $QUOTA_FS | _filter_and_check_blocks