fstests: move test group info to test files
[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 . ./common/preamble
11 _begin_fstest auto quick quota
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/quota
16
17 # real QA test starts here
18 _supported_fs generic
19 _require_scratch
20 _require_setquota_project
21 # V4 XFS doesn't support to mount project and group quota together
22 if [ "$FSTYP" = "xfs" ];then
23         _require_scratch_xfs_crc
24 fi
25 _require_quota
26
27 _scratch_mkfs >$seqres.full 2>&1
28 _scratch_enable_pquota
29 _qmount_option "usrquota,grpquota,prjquota"
30 _qmount
31 _require_prjquota $SCRATCH_DEV
32
33 MIN=60
34
35 # get default time at first
36 def_time=`repquota -u $SCRATCH_MNT | \
37                 sed -n -e "/^Block/s/.* time: \(.*\); .* time: \(.*\)/\1 \2/p"`
38 echo "Default block and inode grace timers are: $def_time" >> $seqres.full
39
40 filter_repquota()
41 {
42         local blocktime=$1
43         local inodetime=$2
44
45         _filter_scratch | sed -e "s,$blocktime,DEF_TIME,g" \
46                               -e "s,$inodetime,DEF_TIME,g"
47 }
48
49 echo "1. set project quota timer"
50 setquota -t -P $((10 * MIN)) $((20 * MIN)) $SCRATCH_MNT
51 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
52 echo
53
54 echo "2. set group quota timer"
55 setquota -t -g $((30 * MIN)) $((40 * MIN)) $SCRATCH_MNT
56 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
57 echo
58
59 echo "3. set user quota timer"
60 setquota -t -u $((50 * MIN)) $((60 * MIN)) $SCRATCH_MNT
61 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
62 echo
63
64 # cycle mount, make sure the quota timers are still right
65 echo "4. cycle mount test-1"
66 _qmount
67 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
68 echo
69
70 # Run repair to force quota check
71 echo "5. fsck to force quota check"
72 _scratch_unmount
73 _repair_scratch_fs >> $seqres.full 2>&1
74 echo
75
76 # Remount (this time to run quotacheck) and check the limits.  There's a bug
77 # in quotacheck where we would reset the ondisk default grace period to zero
78 # while the incore copy stays at whatever was read in prior to quotacheck.
79 # This will show up after the /next/ remount.
80 echo "6. cycle mount test-2"
81 _qmount
82 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
83 echo
84
85 # Remount and check the limits
86 echo "7. cycle mount test-3"
87 _qmount
88 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
89
90 # success, all done
91 status=0
92 exit