2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # Exercises basic XFS quota functionality
8 # uquota, gquota, uqnoenforce, gqnoenforce, pquota, pqnoenforce
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
18 # get standard environment, filters and checks
26 _scratch_unmount 2>/dev/null
29 trap "_cleanup; exit \$status" 0 1 2 3 15
31 # real QA test starts here
34 cp /dev/null $seqres.full
35 chmod a+rwx $seqres.full # arbitrary users will write here
40 _scratch_mkfs >/dev/null 2>&1
42 bsize=$(_get_file_block_size $SCRATCH_MNT)
45 bsoft=$(( 200 * $bsize ))
46 bhard=$(( 1000 * $bsize ))
50 # The actual point at which limit enforcement takes place for the
51 # hard block limit is variable depending on filesystem blocksize,
52 # and iosize. What we want to test is that the limit is enforced
53 # (ie. blksize less than limit but not unduly less - ~85% is kind)
54 # nowadays we actually get much closer to the limit before EDQUOT.
56 _filter_and_check_blks()
59 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
61 $minimum = '$bhard' * 85/100;
63 if (($used < $minimum || $used > $maximum) && '$noextsz') {
64 printf(" URK %d: %d is out of range! [%d,%d]\n",
65 '$id', $used, $minimum, $maximum);
67 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
69 ' | _filter_quota_report
74 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
75 cat $tmp.mkfs >>$seqres.full
77 # keep the blocksize and data size for dd later
82 # Figure out whether we're doing large allocations
83 # (bail out if they're so large they stuff the test up)
84 _test_inode_flag extsz-inherit $SCRATCH_MNT
86 extsize=`_test_inode_extsz $SCRATCH_MNT`
87 [ $extsize -ge 512000 ] && \
88 _notrun "Extent size hint is too large ($extsize bytes)"
92 echo "Using type=$type id=$id" >>$seqres.full
94 $XFS_QUOTA_PROG -x -c "warn -$type 65535 -d" $SCRATCH_DEV
97 echo "*** report no quota settings" | tee -a $seqres.full
98 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
99 -c "repquota -birnN -$type" $SCRATCH_DEV |
100 _filter_quota_report | LC_COLLATE=POSIX sort -ru
103 echo "*** report initial settings" | tee -a $seqres.full
104 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
105 echo "ls -l $SCRATCH_MNT" >>$seqres.full
106 ls -l $SCRATCH_MNT >>$seqres.full
107 $XFS_QUOTA_PROG -D $tmp.projects -P $temp.projid -x \
108 -c "limit -$type bsoft=${bsoft} bhard=${bhard} $id" \
109 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
111 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
112 -c "repquota -birnN -$type" $SCRATCH_DEV |
113 _filter_quota_report | LC_COLLATE=POSIX sort -ru
116 echo "*** push past the soft inode limit" | tee -a $seqres.full
117 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
118 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
119 _file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
120 _file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
122 $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
123 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
124 -c "repquota -birnN -$type" $SCRATCH_DEV |
125 _filter_quota_report | LC_COLLATE=POSIX sort -ru
128 echo "*** push past the soft block limit" | tee -a $seqres.full
129 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 300
131 $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" \
132 -c "warn -b -$type 0 $id" $SCRATCH_DEV
133 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
134 -c "repquota -birnN -$type" $SCRATCH_DEV |
135 _filter_quota_report | LC_COLLATE=POSIX sort -ru
138 # Note: for quota accounting (not enforcement), EDQUOT is not expected
139 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
140 for i in 1 2 3 4 5 6 7 8 9 10 11 12
142 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
145 $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" \
146 -c "warn -i -$type 0 $id" $SCRATCH_DEV
147 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
148 -c "repquota -birnN -$type" $SCRATCH_DEV |
149 _filter_quota_report | LC_COLLATE=POSIX sort -ru
152 # Note: for quota accounting (not enforcement), EDQUOT is not expected
153 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
154 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 1200
155 echo "ls -l $SCRATCH_MNT" >>$seqres.full
156 ls -l $SCRATCH_MNT >>$seqres.full
158 $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" $SCRATCH_DEV
159 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
160 -c "repquota -birnN -$type" $SCRATCH_DEV |
161 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
169 cat >$tmp.projects <<EOF
173 cat >$tmp.projid <<EOF
178 projid_file="$tmp.projid"
181 _qmount_option "uquota"
185 _qmount_option "gquota"
188 echo "*** uqnoenforce"
189 _qmount_option "uqnoenforce"
192 echo "*** gqnoenforce"
193 _qmount_option "gqnoenforce"
197 _qmount_option "pquota"
200 echo "*** pqnoenforce"
201 _qmount_option "pqnoenforce"