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 _begin_fstest quota auto quick
13 # Import common functions.
17 # Override the default cleanup function.
21 _scratch_unmount 2>/dev/null
25 # real QA test starts here
28 cp /dev/null $seqres.full
29 chmod a+rwx $seqres.full # arbitrary users will write here
34 _scratch_mkfs >/dev/null 2>&1
36 bsize=$(_get_file_block_size $SCRATCH_MNT)
39 bsoft=$(( 200 * $bsize ))
40 bhard=$(( 1000 * $bsize ))
44 # The actual point at which limit enforcement takes place for the
45 # hard block limit is variable depending on filesystem blocksize,
46 # and iosize. What we want to test is that the limit is enforced
47 # (ie. blksize less than limit but not unduly less - ~85% is kind)
48 # nowadays we actually get much closer to the limit before EDQUOT.
50 _filter_and_check_blks()
53 if (/^\#'$id'\s+(\d+)/ && '$enforce') {
55 $minimum = '$bhard' * 85/100;
57 if (($used < $minimum || $used > $maximum) && '$noextsz') {
58 printf(" URK %d: %d is out of range! [%d,%d]\n",
59 '$id', $used, $minimum, $maximum);
61 s/^(\#'$id'\s+)(\d+)/\1 =OK=/g;
63 ' | _filter_quota_report
68 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
69 cat $tmp.mkfs >>$seqres.full
71 # keep the blocksize and data size for dd later
76 # Figure out whether we're doing large allocations
77 # (bail out if they're so large they stuff the test up)
78 _test_inode_flag extsz-inherit $SCRATCH_MNT
80 extsize=`_test_inode_extsz $SCRATCH_MNT`
81 [ $extsize -ge 512000 ] && \
82 _notrun "Extent size hint is too large ($extsize bytes)"
86 echo "Using type=$type id=$id" >>$seqres.full
88 $XFS_QUOTA_PROG -x -c "warn -$type 65535 -d" $SCRATCH_DEV
91 echo "*** report no quota settings" | tee -a $seqres.full
92 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
93 -c "repquota -birnN -$type" $SCRATCH_DEV |
94 _filter_quota_report | LC_COLLATE=POSIX sort -ru
97 echo "*** report initial settings" | tee -a $seqres.full
98 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
99 echo "ls -l $SCRATCH_MNT" >>$seqres.full
100 ls -l $SCRATCH_MNT >>$seqres.full
101 $XFS_QUOTA_PROG -D $tmp.projects -P $temp.projid -x \
102 -c "limit -$type bsoft=${bsoft} bhard=${bhard} $id" \
103 -c "limit -$type isoft=$isoft ihard=$ihard $id" \
105 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
106 -c "repquota -birnN -$type" $SCRATCH_DEV |
107 _filter_quota_report | LC_COLLATE=POSIX sort -ru
110 echo "*** push past the soft inode limit" | tee -a $seqres.full
111 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
112 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
113 _file_as_id $SCRATCH_MNT/softie3 $id $type 1024 0
114 _file_as_id $SCRATCH_MNT/softie4 $id $type 1024 0
116 $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" $SCRATCH_DEV
117 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
118 -c "repquota -birnN -$type" $SCRATCH_DEV |
119 _filter_quota_report | LC_COLLATE=POSIX sort -ru
122 echo "*** push past the soft block limit" | tee -a $seqres.full
123 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 300
125 $XFS_QUOTA_PROG -x -c "warn -i -$type 0 $id" \
126 -c "warn -b -$type 0 $id" $SCRATCH_DEV
127 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
128 -c "repquota -birnN -$type" $SCRATCH_DEV |
129 _filter_quota_report | LC_COLLATE=POSIX sort -ru
132 # Note: for quota accounting (not enforcement), EDQUOT is not expected
133 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seqres.full
134 for i in 1 2 3 4 5 6 7 8 9 10 11 12
136 _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
139 $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" \
140 -c "warn -i -$type 0 $id" $SCRATCH_DEV
141 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
142 -c "repquota -birnN -$type" $SCRATCH_DEV |
143 _filter_quota_report | LC_COLLATE=POSIX sort -ru
146 # Note: for quota accounting (not enforcement), EDQUOT is not expected
147 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seqres.full
148 _file_as_id $SCRATCH_MNT/softie $id $type $bsize 1200
149 echo "ls -l $SCRATCH_MNT" >>$seqres.full
150 ls -l $SCRATCH_MNT >>$seqres.full
152 $XFS_QUOTA_PROG -x -c "warn -b -$type 0 $id" $SCRATCH_DEV
153 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
154 -c "repquota -birnN -$type" $SCRATCH_DEV |
155 _filter_and_check_blks | LC_COLLATE=POSIX sort -ru
163 cat >$tmp.projects <<EOF
167 cat >$tmp.projid <<EOF
172 projid_file="$tmp.projid"
175 _qmount_option "uquota"
179 _qmount_option "gquota"
182 echo "*** uqnoenforce"
183 _qmount_option "uqnoenforce"
186 echo "*** gqnoenforce"
187 _qmount_option "gqnoenforce"
191 _qmount_option "pquota"
194 echo "*** pqnoenforce"
195 _qmount_option "pqnoenforce"