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 _begin_fstest auto quick quota
13 # Import common functions.
17 # real QA test starts here
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
27 _scratch_mkfs >$seqres.full 2>&1
28 _scratch_enable_pquota
29 _qmount_option "usrquota,grpquota,prjquota"
31 _require_prjquota $SCRATCH_DEV
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
45 _filter_scratch | sed -e "s,$blocktime,DEF_TIME,g" \
46 -e "s,$inodetime,DEF_TIME,g"
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
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
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
64 # cycle mount, make sure the quota timers are still right
65 echo "4. cycle mount test-1"
67 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
70 # Run repair to force quota check
71 echo "5. fsck to force quota check"
73 _repair_scratch_fs >> $seqres.full 2>&1
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"
82 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
85 # Remount and check the limits
86 echo "7. cycle mount test-3"
88 repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time