generic/681, generic/682: add debugging information to $seqreq.full
[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 . ./common/preamble
15 _begin_fstest auto quick quota
16
17 # Import common functions.
18 . ./common/filter
19 . ./common/quota
20
21 # real QA test starts here
22 _supported_fs xfs
23 _require_xfs_quota
24 _require_scratch
25
26 exercise() {
27         _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
28         cat $tmp.mkfs >>$seqres.full
29
30         # keep the blocksize and data size for dd later
31         . $tmp.mkfs
32
33         _qmount
34
35         _qsetup $1
36
37         echo "Using type=$type id=$id" >>$seqres.full
38
39         echo
40         echo "*** report initial settings" | tee -a $seqres.full
41         $XFS_QUOTA_PROG -x \
42                 -c "limit -$type isoft=3 ihard=500000 $id" \
43                 -c "warn -$type -i -d 13" \
44                 $SCRATCH_DEV
45         $XFS_QUOTA_PROG -x \
46                 -c "state -$type" >> $seqres.full
47         $XFS_QUOTA_PROG -x \
48                 -c "repquota -birnN -$type" $SCRATCH_DEV |
49                 _filter_quota_report | LC_COLLATE=POSIX sort -ru
50
51         echo
52         echo "*** push past the soft inode limit" | tee -a $seqres.full
53         _file_as_id $SCRATCH_MNT/softok1 $id $type $bsize 0
54         _file_as_id $SCRATCH_MNT/softok2 $id $type $bsize 0
55         _file_as_id $SCRATCH_MNT/softok3 $id $type $bsize 0
56         _file_as_id $SCRATCH_MNT/softwarn1 $id $type $bsize 0
57         $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
58                 -c "repquota -birnN -$type" $SCRATCH_DEV |
59                 _filter_quota_report | LC_COLLATE=POSIX sort -ru
60
61         echo
62         echo "*** push further past the soft inode limit" | tee -a $seqres.full
63         for warn_nr in $(seq 2 5); do
64                 _file_as_id $SCRATCH_MNT/softwarn$warn_nr $id $type $bsize 0
65         done
66         $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
67                 -c "repquota -birnN -$type" $SCRATCH_DEV |
68                 _filter_quota_report | LC_COLLATE=POSIX sort -ru
69
70         echo
71         echo "*** push past the soft inode warning limit" | tee -a $seqres.full
72         for warn_nr in $(seq 6 15); do
73                 _file_as_id $SCRATCH_MNT/softwarn$warn_nr $id $type $bsize 0
74         done
75         $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
76                 -c "repquota -birnN -$type" $SCRATCH_DEV |
77                 _filter_quota_report | LC_COLLATE=POSIX sort -ru
78
79         echo
80         echo "*** unmount"
81         _scratch_unmount
82 }
83
84 _scratch_mkfs > $seqres.full
85 _scratch_mount >> $seqres.full
86
87 chmod a+rwx $SCRATCH_MNT $seqres.full   # arbitrary users will write here
88 bsize=$(_get_file_block_size $SCRATCH_MNT)
89 _scratch_unmount
90
91 cat >$tmp.projects <<EOF
92 1:$SCRATCH_MNT
93 EOF
94
95 cat >$tmp.projid <<EOF
96 root:0
97 scratch:1
98 EOF
99
100 projid_file="$tmp.projid"
101
102 echo "*** user"
103 _qmount_option "uquota"
104 exercise u
105
106 echo "*** group"
107 _qmount_option "gquota"
108 exercise g
109
110 echo "*** uqnoenforce"
111 _qmount_option "uqnoenforce"
112 exercise uno
113
114 echo "*** gqnoenforce"
115 _qmount_option "gqnoenforce"
116 exercise gno
117
118 echo "*** pquota"
119 _qmount_option "pquota"
120 exercise p
121
122 echo "*** pqnoenforce"
123 _qmount_option "pqnoenforce"
124 exercise pno
125
126 # success, all done
127 status=0
128 exit