xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / xfs / 144
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 144
6 #
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").
13
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1    # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/quota
33
34 # real QA test starts here
35 _supported_fs xfs
36 _require_xfs_quota
37 _require_scratch
38
39 rm -f $seqres.full
40
41 exercise() {
42         _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
43         cat $tmp.mkfs >>$seqres.full
44
45         # keep the blocksize and data size for dd later
46         . $tmp.mkfs
47
48         _qmount
49
50         _qsetup $1
51
52         echo "Using type=$type id=$id" >>$seqres.full
53
54         echo
55         echo "*** report initial settings" | tee -a $seqres.full
56         $XFS_QUOTA_PROG -x \
57                 -c "limit -$type isoft=3 ihard=500000 $id" \
58                 -c "warn -$type -i -d 13" \
59                 $SCRATCH_DEV
60         $XFS_QUOTA_PROG -x \
61                 -c "state -$type" >> $seqres.full
62         $XFS_QUOTA_PROG -x \
63                 -c "repquota -birnN -$type" $SCRATCH_DEV |
64                 _filter_quota_report | LC_COLLATE=POSIX sort -ru
65
66         echo
67         echo "*** push past the soft inode limit" | tee -a $seqres.full
68         _file_as_id $SCRATCH_MNT/softok1 $id $type $bsize 0
69         _file_as_id $SCRATCH_MNT/softok2 $id $type $bsize 0
70         _file_as_id $SCRATCH_MNT/softok3 $id $type $bsize 0
71         _file_as_id $SCRATCH_MNT/softwarn1 $id $type $bsize 0
72         $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
73                 -c "repquota -birnN -$type" $SCRATCH_DEV |
74                 _filter_quota_report | LC_COLLATE=POSIX sort -ru
75
76         echo
77         echo "*** push further past the soft inode limit" | tee -a $seqres.full
78         for warn_nr in $(seq 2 5); do
79                 _file_as_id $SCRATCH_MNT/softwarn$warn_nr $id $type $bsize 0
80         done
81         $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
82                 -c "repquota -birnN -$type" $SCRATCH_DEV |
83                 _filter_quota_report | LC_COLLATE=POSIX sort -ru
84
85         echo
86         echo "*** push past the soft inode warning limit" | tee -a $seqres.full
87         for warn_nr in $(seq 6 15); do
88                 _file_as_id $SCRATCH_MNT/softwarn$warn_nr $id $type $bsize 0
89         done
90         $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
91                 -c "repquota -birnN -$type" $SCRATCH_DEV |
92                 _filter_quota_report | LC_COLLATE=POSIX sort -ru
93
94         echo
95         echo "*** unmount"
96         _scratch_unmount
97 }
98
99 _scratch_mkfs > $seqres.full
100 _scratch_mount >> $seqres.full
101
102 chmod a+rwx $SCRATCH_MNT $seqres.full   # arbitrary users will write here
103 bsize=$(_get_file_block_size $SCRATCH_MNT)
104 _scratch_unmount
105
106 cat >$tmp.projects <<EOF
107 1:$SCRATCH_MNT
108 EOF
109
110 cat >$tmp.projid <<EOF
111 root:0
112 scratch:1
113 EOF
114
115 projid_file="$tmp.projid"
116
117 echo "*** user"
118 _qmount_option "uquota"
119 exercise u
120
121 echo "*** group"
122 _qmount_option "gquota"
123 exercise g
124
125 echo "*** uqnoenforce"
126 _qmount_option "uqnoenforce"
127 exercise uno
128
129 echo "*** gqnoenforce"
130 _qmount_option "gqnoenforce"
131 exercise gno
132
133 echo "*** pquota"
134 _qmount_option "pquota"
135 exercise p
136
137 echo "*** pqnoenforce"
138 _qmount_option "pqnoenforce"
139 exercise pno
140
141 # success, all done
142 status=0
143 exit