2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
7 # Check that quota softlimit warnings work the way they should. This means
8 # that we can disobey the softlimit up to warnlimit times before it turns into
9 # hard(er) enforcement. This is a functional test for quota warnings, but
10 # since the functionality has been broken for decades, this is also a
11 # regression test for commit 4b8628d57b72 ("xfs: actually bump warning counts
12 # when we send warnings").
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
29 # get standard environment, filters and checks
34 # real QA test starts here
45 if [ $opt = "u" -o $opt = "uno" ]; then
48 elif [ $opt = "g" -o $opt = "gno" ]; then
51 elif [ $opt = "p" -o $opt = "pno" ]; then
55 [ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
57 echo "Using type=$type id=$id" >> $seqres.full
61 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
62 cat $tmp.mkfs >>$seqres.full
64 # keep the blocksize and data size for dd later
71 echo "Using type=$type id=$id" >>$seqres.full
74 echo "*** report initial settings" | tee -a $seqres.full
76 -c "limit -$type isoft=3 ihard=500000 $id" \
77 -c "warn -$type -i -d 13" \
80 -c "state -$type" >> $seqres.full
82 -c "repquota -birnN -$type" $SCRATCH_DEV |
83 _filter_quota_report | LC_COLLATE=POSIX sort -ru
86 echo "*** push past the soft inode limit" | tee -a $seqres.full
87 _file_as_id $SCRATCH_MNT/softok1 $id $type $bsize 0
88 _file_as_id $SCRATCH_MNT/softok2 $id $type $bsize 0
89 _file_as_id $SCRATCH_MNT/softok3 $id $type $bsize 0
90 _file_as_id $SCRATCH_MNT/softwarn1 $id $type $bsize 0
91 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
92 -c "repquota -birnN -$type" $SCRATCH_DEV |
93 _filter_quota_report | LC_COLLATE=POSIX sort -ru
96 echo "*** push further past the soft inode limit" | tee -a $seqres.full
97 for warn_nr in $(seq 2 5); do
98 _file_as_id $SCRATCH_MNT/softwarn$warn_nr $id $type $bsize 0
100 $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
101 -c "repquota -birnN -$type" $SCRATCH_DEV |
102 _filter_quota_report | LC_COLLATE=POSIX sort -ru
105 echo "*** push past the soft inode warning limit" | tee -a $seqres.full
106 for warn_nr in $(seq 6 15); do
107 _file_as_id $SCRATCH_MNT/softwarn$warn_nr $id $type $bsize 0
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
118 _scratch_mkfs > $seqres.full
119 _scratch_mount >> $seqres.full
121 chmod a+rwx $SCRATCH_MNT $seqres.full # arbitrary users will write here
122 bsize=$(_get_file_block_size $SCRATCH_MNT)
125 cat >$tmp.projects <<EOF
129 cat >$tmp.projid <<EOF
134 projid_file="$tmp.projid"
137 _qmount_option "uquota"
141 _qmount_option "gquota"
144 echo "*** uqnoenforce"
145 _qmount_option "uqnoenforce"
148 echo "*** gqnoenforce"
149 _qmount_option "gqnoenforce"
153 _qmount_option "pquota"
156 echo "*** pqnoenforce"
157 _qmount_option "pqnoenforce"