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.
10 #-----------------------------------------------------------------------
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
22 # get standard environment, filters and checks
30 echo; echo "*** unmount"
31 umount $SCRATCH_MNT 2>/dev/null
34 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # real QA test starts here
39 _supported_os Linux IRIX
42 cp /dev/null $seq.full
43 chmod a+rwx $seq.full # arbitrary users will write here
49 [ -z "$MOUNT_OPTIONS" ] && export MOUNT_OPTIONS="-o uquota"
56 # The actual point at which limit enforcement takes place for the
57 # hard block limit is variable depending on filesystem blocksize,
58 # and iosize. What we want to test is that the limit is enforced
59 # (ie. blksize less than limit but not unduly less - ~85% is kind)
60 # nowadays we actually get much closer to the limit before EDQUOT.
62 _filter_and_check_blocks()
65 if (/^'$name'\s+([-|+]){2}\s+(\d+)/ && '$enforce') {
66 $maximum = '$blkhard';
67 $minimum = '$blkhard' * 85/100;
68 if ($2 < $minimum || $2 > $maximum) {
69 printf(" URK - %d is out of range! [%d,%d] \n",
70 $2, $minimum, $maximum);
72 s/^('$name'\s+[-|+][-|+]\s+)(\d+)/\1 OK/g;
77 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
78 cat $tmp.mkfs >>$seq.full
80 # keep the blocksize and data size for dd later
85 # Irix uses filesystem name and Linux uses device of filesystem
86 if [ $HOSTOS = "Linux" ]; then
94 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
95 echo "and using type=$type id=$id" >>$seq.full
98 echo "*** report no quota settings" | tee -a $seq.full
99 _repquota -$type $QUOTA_FS | _filter_repquota
102 echo "*** report initial settings" | tee -a $seq.full
103 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
104 echo "ls -l $SCRATCH_MNT" >>$seq.full
105 ls -l $SCRATCH_MNT >>$seq.full
106 _setquota -$type $id $blksoft $blkhard $inosoft $inohard $QUOTA_FS
107 _repquota -$type $QUOTA_FS | _filter_repquota
110 echo "*** push past the soft inode limit" | tee -a $seq.full
111 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
112 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
114 _repquota -$type $QUOTA_FS | _filter_repquota
117 echo "*** push past the soft block limit" | tee -a $seq.full
118 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
120 _repquota -$type $QUOTA_FS | _filter_repquota
123 # Note: for quota accounting (not enforcement), EDQUOT is not expected
124 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
125 for i in 1 2 3 4 5 6 7 8 9 10 11 12
127 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
130 _repquota -$type $QUOTA_FS | _filter_repquota
133 # Note: for quota accounting (not enforcement), EDQUOT is not expected
134 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
135 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
136 echo "ls -l $SCRATCH_MNT" >>$seq.full
137 ls -l $SCRATCH_MNT >>$seq.full
139 _repquota -$type $QUOTA_FS | _filter_and_check_blocks