generic/223: make sure all files get created on the data device
[xfstests-dev.git] / tests / generic / 594
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 594
6 #
7 # Test per-type(user, group and project) filesystem quota timers, make sure
8 # each of grace time can be set/get properly.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/quota
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34 _supported_fs generic
35 _require_scratch
36 _require_setquota_project
37 # V4 XFS doesn't support to mount project and group quota together
38 if [ "$FSTYP" = "xfs" ];then
39         _require_scratch_xfs_crc
40 fi
41 _require_quota
42
43 _scratch_mkfs >$seqres.full 2>&1
44 _scratch_enable_pquota
45 _qmount_option "usrquota,grpquota,prjquota"
46 _qmount
47 _require_prjquota $SCRATCH_DEV
48
49 MIN=60
50
51 # get default time at first
52 def_time=`repquota -u $SCRATCH_MNT | \
53                 sed -n -e "/^Block/s/.* time: \(.*\); .* time: \(.*\)/\1 \2/p"`
54 echo "Default block and inode grace timers are: $def_time" >> $seqres.full
55
56 filter_repquota()
57 {
58         local blocktime=$1
59         local inodetime=$2
60
61         _filter_scratch | sed -e "s,$blocktime,DEF_TIME,g" \
62                               -e "s,$inodetime,DEF_TIME,g"
63 }
64
65 echo "1. set project quota timer"
66 setquota -t -P $((10 * MIN)) $((20 * MIN)) $SCRATCH_MNT
67 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
68 echo
69
70 echo "2. set group quota timer"
71 setquota -t -g $((30 * MIN)) $((40 * MIN)) $SCRATCH_MNT
72 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
73 echo
74
75 echo "3. set user quota timer"
76 setquota -t -u $((50 * MIN)) $((60 * MIN)) $SCRATCH_MNT
77 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
78 echo
79
80 # cycle mount, make sure the quota timers are still right
81 echo "4. cycle mount test-1"
82 _qmount
83 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
84 echo
85
86 # Run repair to force quota check
87 echo "5. fsck to force quota check"
88 _scratch_unmount
89 _repair_scratch_fs >> $seqres.full 2>&1
90 echo
91
92 # Remount (this time to run quotacheck) and check the limits.  There's a bug
93 # in quotacheck where we would reset the ondisk default grace period to zero
94 # while the incore copy stays at whatever was read in prior to quotacheck.
95 # This will show up after the /next/ remount.
96 echo "6. cycle mount test-2"
97 _qmount
98 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
99 echo
100
101 # Remount and check the limits
102 echo "7. cycle mount test-3"
103 _qmount
104 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
105
106 # success, all done
107 status=0
108 exit