2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Red Hat, Inc. All Rights Reserved.
7 # Test per-type(user, group and project) filesystem quota timers, make sure
8 # each of grace time can be set/get properly.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
30 # remove previous $seqres.full before test
33 # real QA test starts here
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
43 _scratch_mkfs >$seqres.full 2>&1
44 _scratch_enable_pquota
45 _qmount_option "usrquota,grpquota,prjquota"
47 _require_prjquota $SCRATCH_DEV
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
61 _filter_scratch | sed -e "s,$blocktime,DEF_TIME,g" \
62 -e "s,$inodetime,DEF_TIME,g"
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
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
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
80 # cycle mount, make sure the quota timers are still right
81 echo "4. cycle mount test-1"
83 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
86 # Run repair to force quota check
87 echo "5. fsck to force quota check"
89 _repair_scratch_fs >> $seqres.full 2>&1
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"
98 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
101 # Remount and check the limits
102 echo "7. cycle mount test-3"
104 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time