xfstests: remove stale machine configs
[xfstests-dev.git] / 050
1 #! /bin/bash
2 # FS QA Test No. 050
3 #
4 # Exercises basic XFS quota functionality
5 #       uquota, gquota, uqnoenforce, gqnoenforce, pquota, pqnoenforce
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
9 #
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.
13 #
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.
18 #
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
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36 . ./common.quota
37
38 _cleanup()
39 {
40         cd /
41         umount $SCRATCH_MNT 2>/dev/null
42         rm -f $tmp.*
43 }
44 trap "_cleanup; exit \$status" 0 1 2 3 15
45
46
47 # real QA test starts here
48 _supported_fs xfs
49 _supported_os Linux IRIX
50
51
52 cp /dev/null $seq.full
53 chmod a+rwx $seq.full   # arbitrary users will write here
54
55 _require_scratch
56 _require_xfs_quota
57
58 bsoft=100
59 bhard=500
60 isoft=4
61 ihard=10
62
63
64 _filter_report()
65 {
66         tr -s '[:space:]' | \
67         perl -npe '
68                 s/^\#'$id' /[NAME] /g;
69                 s/^\#0 \d+ /[ROOT] 0 /g;
70                 s/6 days/7 days/g' |
71         perl -npe '
72                 $val = 0;
73                 if ($ENV{'LARGE_SCRATCH_DEV'}) {
74                         $val = $ENV{'NUM_SPACE_FILES'};
75                 }
76                 s/(^\[ROOT\] \S+ \S+ \S+ \S+ \[--------\] )(\S+)/$1@{[$2 - $val]}/g'
77 }
78
79 # The actual point at which limit enforcement takes place for the
80 # hard block limit is variable depending on filesystem blocksize,
81 # and iosize.  What we want to test is that the limit is enforced
82 # (ie. blksize less than limit but not unduly less - ~85% is kind)
83 # nowadays we actually get much closer to the limit before EDQUOT.
84 #
85 _filter_and_check_blks()
86 {
87         perl -npe '
88                 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
89                         $maximum = '$bhard';
90                         $minimum = '$bhard' * 85/100;
91                         if (($1 < $minimum || $1 > $maximum) && '$noextsz') {
92                                 printf(" URK %d: %d is out of range! [%d,%d]\n",
93                                         '$id', $1, $minimum, $maximum);
94                         }
95                         s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
96                 }
97         ' | _filter_report
98 }
99
100 _exercise()
101 {
102         _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
103         cat $tmp.mkfs >>$seq.full
104
105         # keep the blocksize and data size for dd later
106         . $tmp.mkfs
107
108         _qmount
109
110         # Figure out whether we're doing large allocations
111         # (bail out if they're so large they stuff the test up)
112         _test_inode_flag extsz-inherit $SCRATCH_MNT
113         noextsz=$?
114         extsize=`_test_inode_extsz $SCRATCH_MNT`
115         [ $extsize -ge 512000 ] && \
116                 _notrun "Extent size hint is too large ($extsize bytes)"
117
118         _qsetup
119
120         echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
121         echo "and using type=$type id=$id" >>$seq.full
122
123         echo
124         echo "*** report no quota settings" | tee -a $seq.full
125         xfs_quota -D $tmp.projects -P $tmp.projid -x \
126                 -c "repquota -birnN -$type" $SCRATCH_DEV |
127                 _filter_report | LC_COLLATE=POSIX sort -ru
128
129         echo
130         echo "*** report initial settings" | tee -a $seq.full
131         _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
132         echo "ls -l $SCRATCH_MNT" >>$seq.full
133         ls -l $SCRATCH_MNT >>$seq.full
134         xfs_quota -D $tmp.projects -P $temp.projid -x \
135                 -c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
136                 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
137                 $SCRATCH_DEV
138         xfs_quota -D $tmp.projects -P $tmp.projid -x \
139                 -c "repquota -birnN -$type" $SCRATCH_DEV |
140                 _filter_report | LC_COLLATE=POSIX sort -ru
141
142         echo
143         echo "*** push past the soft inode limit" | tee -a $seq.full
144         _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
145         _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
146         _qmount
147         xfs_quota -D $tmp.projects -P $tmp.projid -x \
148                 -c "repquota -birnN -$type" $SCRATCH_DEV |
149                 _filter_report | LC_COLLATE=POSIX sort -ru
150
151         echo
152         echo "*** push past the soft block limit" | tee -a $seq.full
153         _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
154         _qmount
155         xfs_quota -D $tmp.projects -P $tmp.projid -x \
156                 -c "repquota -birnN -$type" $SCRATCH_DEV |
157                 _filter_report | LC_COLLATE=POSIX sort -ru
158
159         echo
160         # Note: for quota accounting (not enforcement), EDQUOT is not expected
161         echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
162         for i in 1 2 3 4 5 6 7 8 9 10 11 12
163         do
164                 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
165         done
166         _qmount
167         xfs_quota -D $tmp.projects -P $tmp.projid -x \
168                 -c "repquota -birnN -$type" $SCRATCH_DEV |
169                 _filter_report | LC_COLLATE=POSIX sort -ru
170
171         echo
172         # Note: for quota accounting (not enforcement), EDQUOT is not expected
173         echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
174         _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
175         echo "ls -l $SCRATCH_MNT" >>$seq.full
176         ls -l $SCRATCH_MNT >>$seq.full
177         _qmount
178         xfs_quota -D $tmp.projects -P $tmp.projid -x \
179                 -c "repquota -birnN -$type" $SCRATCH_DEV |
180                 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
181
182         echo
183         echo "*** unmount"
184         umount $SCRATCH_MNT
185
186 }
187
188 cat >$tmp.projects <<EOF
189 1:$SCRATCH_MNT
190 EOF
191
192 cat >$tmp.projid <<EOF
193 root:0
194 scrach:1
195 EOF
196
197 projid_file="$tmp.projid"
198
199 echo "*** user"
200 if [ "$HOSTOS" == "IRIX" ]
201 then
202         _qmount_option "quota"
203 else
204         _qmount_option "uquota"
205 fi
206 _exercise
207
208 echo "*** group"
209 _qmount_option "gquota"
210 _exercise
211
212 echo "*** uqnoenforce"
213 if [ "$HOSTOS" == "IRIX" ]
214 then
215         _qmount_option "qnoenforce"
216 else
217         _qmount_option "uqnoenforce"
218 fi
219 _exercise
220
221 echo "*** gqnoenforce"
222 _qmount_option "gqnoenforce"
223 _exercise
224
225 echo "*** pquota"
226 _qmount_option "pquota"
227 _exercise
228
229 echo "*** pqnoenforce"
230 _qmount_option "pqnoenforce"
231 _exercise
232
233 # success, all done
234 status=0
235 exit