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.
9 #-----------------------------------------------------------------------
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
21 # get standard environment, filters and checks
29 umount $SCRATCH_MNT 2>/dev/null
32 trap "_cleanup; exit \$status" 0 1 2 3 15
35 # real QA test starts here
37 _supported_os Linux IRIX
40 cp /dev/null $seq.full
41 chmod a+rwx $seq.full # arbitrary users will write here
54 tr -s '[:space:]' | sed -e "s/^\#$id /[NAME] /g" -e "s/^#0 /[ROOT] /g"
57 # The actual point at which limit enforcement takes place for the
58 # hard block limit is variable depending on filesystem blocksize,
59 # and iosize. What we want to test is that the limit is enforced
60 # (ie. blksize less than limit but not unduly less - ~85% is kind)
61 # nowadays we actually get much closer to the limit before EDQUOT.
63 _filter_and_check_blks()
66 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
68 $minimum = '$bhard' * 85/100;
69 if (($1 < $minimum || $1 > $maximum) && '$noextsz') {
70 printf(" URK %d: %d is out of range! [%d,%d]\n",
71 '$id', $1, $minimum, $maximum);
73 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
80 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
81 cat $tmp.mkfs >>$seq.full
83 # keep the blocksize and data size for dd later
88 # Figure out whether we're doing large allocations
89 # (bail out if they're so large they stuff the test up)
90 _test_inode_flag extsz-inherit $SCRATCH_MNT
92 extsize=`_test_inode_extsz $SCRATCH_MNT`
93 [ $extsize -ge 512000 ] && \
94 _notrun "Extent size hint is too large ($extsize bytes)"
98 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
99 echo "and using type=$type id=$id" >>$seq.full
102 echo "*** report no quota settings" | tee -a $seq.full
103 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report
106 echo "*** report initial settings" | tee -a $seq.full
107 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
108 echo "ls -l $SCRATCH_MNT" >>$seq.full
109 ls -l $SCRATCH_MNT >>$seq.full
110 xfs_quota -D $tmp.projects -P $temp.projid -x \
111 -c "limit -$type bsoft=${bsoft}k bhard=${bhard}k $id" \
112 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
114 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report
117 echo "*** push past the soft inode limit" | tee -a $seq.full
118 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
119 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
121 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report
124 echo "*** push past the soft block limit" | tee -a $seq.full
125 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
127 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report
130 # Note: for quota accounting (not enforcement), EDQUOT is not expected
131 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
132 for i in 1 2 3 4 5 6 7 8 9 10 11 12
134 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
137 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_report
140 # Note: for quota accounting (not enforcement), EDQUOT is not expected
141 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
142 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
143 echo "ls -l $SCRATCH_MNT" >>$seq.full
144 ls -l $SCRATCH_MNT >>$seq.full
146 xfs_quota -D $tmp.projects -P $tmp.projid -x -c "repquota -birnN -$type" $SCRATCH_DEV | _filter_and_check_blks
155 #ensures only one quota mount option is specified
158 #replace any user defined quota options
159 export MOUNT_OPTIONS=`echo $MOUNT_OPTIONS \
160 | sed -e 's/uquota/$q_opt/g' \
161 -e 's/gquota/$q_opt/g' \
162 -e 's/pquota/$q_opt/g' \
163 -e 's/quota/$q_opt/g' \
164 -e 's/uqnoenforce/$q_opt/g' \
165 -e 's/gqnoenforce/$q_opt/g' \
166 -e 's/pqnoenforce/$q_opt/g' \
167 -e 's/qnoenforce/$q_opt/g' \
168 | sed 's/$q_opt/'$1'/g'`
170 #check $q_opt is in new mount options
171 echo $MOUNT_OPTIONS | grep "$1" > /dev/null 2>&1
172 [ "$?" -eq 0 ] || export MOUNT_OPTIONS="$MOUNT_OPTIONS -o $1"
175 cat >$tmp.projects <<EOF
179 cat >$tmp.projid <<EOF
184 projid_file="$tmp.projid"
187 if [ "$HOSTOS" == "IRIX" ]
189 _qmount_option "quota"
191 _qmount_option "uquota"
196 _qmount_option "gquota"
199 echo "*** uqnoenforce"
200 if [ "$HOSTOS" == "IRIX" ]
202 _qmount_option "qnoenforce"
204 _qmount_option "uqnoenforce"
208 echo "*** gqnoenforce"
209 _qmount_option "gqnoenforce"
213 _qmount_option "pquota"
216 echo "*** pqnoenforce"
217 _qmount_option "pqnoenforce"