5 # Exercises basic XFS quota functionality
6 # MOUNT_OPTIONS env var switches the test type (uid/gid/acct/enfd)
7 # options are: (-o) usrquota, grpquota, uqnoenforce, gqnoenforce
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
13 # This program is free software; you can redistribute it and/or modify it
14 # under the terms of version 2 of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 # Further, this software is distributed without any warranty that it is
22 # free of the rightful claim of any third person regarding infringement
23 # or the like. Any license provided herein, whether implied or
24 # otherwise, applies only to this software file. Patent licenses, if
25 # any, provided herein do not apply to combinations of this program with
26 # other software, or any other product whatsoever.
28 # You should have received a copy of the GNU General Public License along
29 # with this program; if not, write the Free Software Foundation, Inc., 59
30 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
32 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
33 # Mountain View, CA 94043, or:
37 # For further information regarding this notice, see:
39 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
40 #-----------------------------------------------------------------------
46 echo "QA output created by $seq"
50 status=1 # failure is the default!
52 # get standard environment, filters and checks
59 echo; echo "*** unmount"
60 umount $SCRATCH_MNT 2>/dev/null
63 trap "_cleanup; exit \$status" 0 1 2 3 15
65 cp /dev/null $seq.full
66 chmod a+rwx $seq.full # arbitrary users will write here
76 # The actual point at which limit enforcement takes place for the
77 # hard block limit is variable depending on filesystem blocksize,
78 # and iosize. What we want to test is that the limit is enforced
79 # (ie. blksize less than limit but not unduly less - ~85% is kind,
80 # nowadays we actually get much closer to the limit before EDQUOT.
82 _filter_and_check_blocks()
85 if (/^'$name'\s+([-|+]){2}\s+(\d+)/ && '$enforce') {
86 $maximum = '$blkhard';
87 $minimum = '$blkhard' * 85/100;
88 if ($2 < $minimum || $2 > $maximum) {
89 printf(" URK - %d is out of range! [%d,%d] \n",
90 $2, $minimum, $maximum);
92 s/^('$name'\s+[-|+][-|+]\s+)(\d+)/\1 OK/g;
97 # real QA test starts here
98 mkfs_xfs $SCRATCH_DEV | _filter_mkfs 2>$tmp.mkfs
99 cat $tmp.mkfs >>$seq.full
101 # keep the blocksize and data size for dd later
106 # setup exactly what it is we'll be testing
108 if src/feature -u $SCRATCH_DEV
110 type=u ; eval `_choose_uid`; ln $seq.usrquota $seq.out
111 elif src/feature -g $SCRATCH_DEV
113 type=g ; eval `_choose_gid`; ln $seq.grpquota $seq.out
114 elif src/feature -U $SCRATCH_DEV
116 type=u ; eval `_choose_uid`; ln $seq.uqnoenforce $seq.out
118 elif src/feature -G $SCRATCH_DEV
120 type=g ; eval `_choose_gid`; ln $seq.gqnoenforce $seq.out
123 _notrun "No quota support at mount time"
126 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
127 echo "and using type=$type id=$id" >>$seq.full
130 echo "*** report no quota settings" | tee -a $seq.full
131 repquota -$type $SCRATCH_DEV | _filter_repquota
134 echo "*** report initial settings" | tee -a $seq.full
135 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
136 setquota -$type $id $blksoft $blkhard $inosoft $inohard $SCRATCH_DEV
137 repquota -$type $SCRATCH_DEV | _filter_repquota
140 echo "*** push past the soft inode limit" | tee -a $seq.full
141 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
142 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
144 repquota -$type $SCRATCH_DEV | _filter_repquota
147 echo "*** push past the soft block limit" | tee -a $seq.full
148 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
150 repquota -$type $SCRATCH_DEV | _filter_repquota
153 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
154 for i in 1 2 3 4 5 6 7 8 9 10 11 12
156 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
159 repquota -$type $SCRATCH_DEV | _filter_repquota
162 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
163 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
165 repquota -$type $SCRATCH_DEV | _filter_and_check_blocks