2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # Exercises basic XFS quota functionality, with all 3 quotas together
8 # uquota, gquota, pquota
9 # uqnoenforce, gqnoenforce, pqnoenforce
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
19 # get standard environment, filters and checks
27 _scratch_unmount 2>/dev/null
30 trap "_cleanup; exit \$status" 0 1 2 3 15
32 # real QA test starts here
35 cp /dev/null $seqres.full
36 chmod a+rwx $seqres.full # arbitrary users will write here
43 # The actual point at which limit enforcement takes place for the
44 # hard block limit is variable depending on filesystem blocksize,
45 # and iosize. What we want to test is that the limit is enforced
46 # (ie. blksize less than limit but not unduly less - ~85% is kind)
47 # nowadays we actually get much closer to the limit before EDQUOT.
49 _filter_and_check_blks()
52 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
54 $minimum = '$bhard' * 85/100;
56 if (($used < $minimum || $used > $maximum) && '$noextsz') {
57 printf(" URK %d: %d is out of range! [%d,%d]\n",
58 '$id', $used, $minimum, $maximum);
60 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
62 ' | _filter_quota_report
68 # Figure out whether we're doing large allocations
69 # (bail out if they're so large they stuff the test up)
70 _test_inode_flag extsz-inherit $SCRATCH_MNT
72 extsize=`_test_inode_extsz $SCRATCH_MNT`
73 [ $extsize -ge 512000 ] && \
74 _notrun "Extent size hint is too large ($extsize bytes)"
78 echo "Using type=$type id=$id" >>$seqres.full
80 $XFS_QUOTA_PROG -x -c "warn -$type 65535 -d" $SCRATCH_DEV
83 echo "*** report no quota settings" | tee -a $seqres.full
84 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
85 -c "repquota -birnN -$type" $SCRATCH_DEV |
86 _filter_quota_report | LC_COLLATE=POSIX sort -ru
89 echo "*** report initial settings" | tee -a $seqres.full
90 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
91 echo "ls -l $SCRATCH_MNT" >>$seqres.full
92 ls -l $SCRATCH_MNT >>$seqres.full
93 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
94 -c "limit -$type bsoft=${bsoft} bhard=${bhard} $id" \
95 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
97 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
98 -c "repquota -birnN -$type" $SCRATCH_DEV |
99 _filter_quota_report | LC_COLLATE=POSIX sort -ru
102 echo "*** push past the soft inode limit" | tee -a $seqres.full
103 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
104 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
105 _file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
106 _file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
108 $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
109 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
110 -c "repquota -birnN -$type" $SCRATCH_DEV |
111 _filter_quota_report | LC_COLLATE=POSIX sort -ru
114 echo "*** push past the soft block limit" | tee -a $seqres.full
115 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 200
117 $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" \
118 -c "warn -b -$type 0 $id" $SCRATCH_DEV
119 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
120 -c "repquota -birnN -$type" $SCRATCH_DEV |
121 _filter_quota_report | LC_COLLATE=POSIX sort -ru
124 # Note: for quota accounting (not enforcement), EDQUOT is not expected
125 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
126 for i in 1 2 3 4 5 6 7 8 9 10 11 12
128 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
131 $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" \
132 -c "warn -i -$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 block limit (expect EDQUOT)" | tee -a $seqres.full
140 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 600
141 echo "ls -l $SCRATCH_MNT" >>$seqres.full
142 ls -l $SCRATCH_MNT >>$seqres.full
144 $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" $SCRATCH_DEV
145 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
146 -c "repquota -birnN -$type" $SCRATCH_DEV |
147 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
151 # clean up our files so we don't pollute the next run
156 _scratch_mkfs_xfs -m crc=1 2>/dev/null | _filter_mkfs 2>$tmp.mkfs
157 cat $tmp.mkfs >>$seqres.full
158 # keep the blocksize and data size for dd later
161 cat >$tmp.projects <<EOF
165 cat >$tmp.projid <<EOF
170 projid_file="$tmp.projid"
172 echo "*** user, group, and project"
173 _qmount_option "uquota,gquota,pquota"
176 bsize=$(_get_file_block_size $SCRATCH_MNT)
178 bsoft=$(( 100 * $bsize ))
179 bhard=$(( 500 * $bsize ))
183 # non-root users need to be able to write to this filesystem
184 chmod 777 $SCRATCH_MNT
194 _scratch_mkfs_xfs -m crc=1 2>/dev/null | _filter_mkfs 2>$tmp.mkfs
195 cat $tmp.mkfs >>$seqres.full
196 # keep the blocksize and data size for dd later
199 echo "*** uqnoenforce, gqnoenforce, and pqnoenforce"
200 _qmount_option "uqnoenforce,gqnoenforce,pqnoenforce"