summaryrefslogtreecommitdiff
path: root/tests/generic/594
blob: 88f9a0dccc69a3cf70dd63817455b99ca794013f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2020 Red Hat, Inc.  All Rights Reserved.
#
# FS QA Test No. 594
#
# Test per-type(user, group and project) filesystem quota timers, make sure
# each of grace time can be set/get properly.
#
. ./common/preamble
_begin_fstest auto quick quota

# Import common functions.
. ./common/filter
. ./common/quota

# real QA test starts here
_supported_fs generic
_require_scratch
_require_setquota_project
# V4 XFS doesn't support to mount project and group quota together
if [ "$FSTYP" = "xfs" ];then
	_require_scratch_xfs_crc
fi
_require_quota

_scratch_mkfs >$seqres.full 2>&1
_scratch_enable_pquota
_qmount_option "usrquota,grpquota,prjquota"
_qmount
_require_prjquota $SCRATCH_DEV

MIN=60

# get default time at first
def_time=`repquota -u $SCRATCH_MNT | \
		sed -n -e "/^Block/s/.* time: \(.*\); .* time: \(.*\)/\1 \2/p"`
echo "Default block and inode grace timers are: $def_time" >> $seqres.full

filter_repquota()
{
	local blocktime=$1
	local inodetime=$2

	_filter_scratch | sed -e "s,$blocktime,DEF_TIME,g" \
			      -e "s,$inodetime,DEF_TIME,g"
}

echo "1. set project quota timer"
setquota -t -P $((10 * MIN)) $((20 * MIN)) $SCRATCH_MNT
repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
echo

echo "2. set group quota timer"
setquota -t -g $((30 * MIN)) $((40 * MIN)) $SCRATCH_MNT
repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
echo

echo "3. set user quota timer"
setquota -t -u $((50 * MIN)) $((60 * MIN)) $SCRATCH_MNT
repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
echo

# cycle mount, make sure the quota timers are still right
echo "4. cycle mount test-1"
_qmount
repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
echo

# Run repair to force quota check
echo "5. fsck to force quota check"
_scratch_unmount
_repair_scratch_fs >> $seqres.full 2>&1
echo

# Remount (this time to run quotacheck) and check the limits.  There's a bug
# in quotacheck where we would reset the ondisk default grace period to zero
# while the incore copy stays at whatever was read in prior to quotacheck.
# This will show up after the /next/ remount.
echo "6. cycle mount test-2"
_qmount
repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time
echo

# Remount and check the limits
echo "7. cycle mount test-3"
_qmount
repquota -ugP $SCRATCH_MNT | grep "Report\|^Block" | filter_repquota $def_time

# success, all done
status=0
exit