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
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or modify it
13 # under the terms of version 2 of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 # Further, this software is distributed without any warranty that it is
21 # free of the rightful claim of any third person regarding infringement
22 # or the like. Any license provided herein, whether implied or
23 # otherwise, applies only to this software file. Patent licenses, if
24 # any, provided herein do not apply to combinations of this program with
25 # other software, or any other product whatsoever.
27 # You should have received a copy of the GNU General Public License along
28 # with this program; if not, write the Free Software Foundation, Inc., 59
29 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
31 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
32 # Mountain View, CA 94043, or:
36 # For further information regarding this notice, see:
38 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 #-----------------------------------------------------------------------
45 echo "QA output created by $seq"
49 status=1 # failure is the default!
51 # 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
64 cp /dev/null $seq.full
65 chmod a+rwx $seq.full # arbitrary users will write here
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_blocks()
84 if (/^'$name'\s+([-|+]){2}\s+(\d+)/ && '$enforce') {
85 $maximum = '$blkhard';
86 $minimum = '$blkhard' * 85/100;
87 if ($2 < $minimum || $2 > $maximum) {
88 printf(" URK - %d is out of range! [%d,%d] \n",
89 $2, $minimum, $maximum);
91 s/^('$name'\s+[-|+][-|+]\s+)(\d+)/\1 OK/g;
96 # real QA test starts here
97 mkfs_xfs $SCRATCH_DEV | _filter_mkfs 2>$tmp.mkfs
98 cat $tmp.mkfs >>$seq.full
100 # keep the blocksize and data size for dd later
105 # setup exactly what it is we'll be testing
107 if src/feature -u $SCRATCH_DEV
109 type=u ; eval `_choose_uid`; ln $seq.usrquota $seq.out
110 elif src/feature -g $SCRATCH_DEV
112 type=g ; eval `_choose_gid`; ln $seq.grpquota $seq.out
113 elif src/feature -U $SCRATCH_DEV
115 type=u ; eval `_choose_uid`; ln $seq.uqnoenforce $seq.out
117 elif src/feature -G $SCRATCH_DEV
119 type=g ; eval `_choose_gid`; ln $seq.gqnoenforce $seq.out
122 _notrun "No quota support at mount time"
125 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
126 echo "and using type=$type id=$id" >>$seq.full
129 echo "*** report no quota settings" | tee -a $seq.full
130 repquota -$type $SCRATCH_DEV | _filter_repquota
133 echo "*** report initial settings" | tee -a $seq.full
134 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
135 setquota -$type $id $blksoft $blkhard $inosoft $inohard $SCRATCH_DEV
136 repquota -$type $SCRATCH_DEV | _filter_repquota
139 echo "*** push past the soft inode limit" | tee -a $seq.full
140 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
141 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
143 repquota -$type $SCRATCH_DEV | _filter_repquota
146 echo "*** push past the soft block limit" | tee -a $seq.full
147 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
149 repquota -$type $SCRATCH_DEV | _filter_repquota
152 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
153 for i in 1 2 3 4 5 6 7 8 9 10 11 12
155 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
158 repquota -$type $SCRATCH_DEV | _filter_repquota
161 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
162 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
164 repquota -$type $SCRATCH_DEV | _filter_and_check_blocks