diff mbox series

[v3] generic: per-type quota timers set/get test

Message ID 20200329051801.8363-1-zlang@redhat.com (mailing list archive)
State Accepted
Headers show
Series [v3] generic: per-type quota timers set/get test | expand

Commit Message

Zorro Lang March 29, 2020, 5:18 a.m. UTC
Set different grace time, make sure each of quota (user, group and
project) timers can be set (by setquota) and get (by repquota)
correctly.

Signed-off-by: Zorro Lang <zlang@redhat.com>
---

V2 did below changes:
1) Filter default quota timer (suggested by Eric Sandeen).
2) Try to merge the case from Darrick (please review):
https://marc.info/?l=fstests&m=158207247224104&w=2

V3 did below changes:
1) _require_scratch_xfs_crc if tests on XFS (suggested by Eryu Guan)

Thanks,
Zorro

 tests/generic/594     | 108 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/594.out |  50 +++++++++++++++++++
 tests/generic/group   |   1 +
 3 files changed, 159 insertions(+)
 create mode 100755 tests/generic/594
 create mode 100644 tests/generic/594.out

Comments

Eric Sandeen May 16, 2020, 5:23 p.m. UTC | #1
On 3/29/20 12:18 AM, Zorro Lang wrote:
> Set different grace time, make sure each of quota (user, group and
> project) timers can be set (by setquota) and get (by repquota)
> correctly.
> 

Sorry for the late review; this works now on xfs & ext4, with my
per-type patches in the kernel.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> Signed-off-by: Zorro Lang <zlang@redhat.com>
> ---
> 
> V2 did below changes:
> 1) Filter default quota timer (suggested by Eric Sandeen).
> 2) Try to merge the case from Darrick (please review):
> https://marc.info/?l=fstests&m=158207247224104&w=2
> 
> V3 did below changes:
> 1) _require_scratch_xfs_crc if tests on XFS (suggested by Eryu Guan)
> 
> Thanks,
> Zorro
> 
>  tests/generic/594     | 108 ++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/594.out |  50 +++++++++++++++++++
>  tests/generic/group   |   1 +
>  3 files changed, 159 insertions(+)
>  create mode 100755 tests/generic/594
>  create mode 100644 tests/generic/594.out
> 
> diff --git a/tests/generic/594 b/tests/generic/594
> new file mode 100755
> index 00000000..e501d54c
> --- /dev/null
> +++ b/tests/generic/594
> @@ -0,0 +1,108 @@
> +#! /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.
> +#
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	cd /
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/quota
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +_supported_fs generic
> +_supported_os Linux
> +_require_scratch
> +# 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
> diff --git a/tests/generic/594.out b/tests/generic/594.out
> new file mode 100644
> index 00000000..f25e0fac
> --- /dev/null
> +++ b/tests/generic/594.out
> @@ -0,0 +1,50 @@
> +QA output created by 594
> +1. set project quota timer
> +*** Report for user quotas on device SCRATCH_DEV
> +Block grace time: DEF_TIME; Inode grace time: DEF_TIME
> +*** Report for group quotas on device SCRATCH_DEV
> +Block grace time: DEF_TIME; Inode grace time: DEF_TIME
> +*** Report for project quotas on device SCRATCH_DEV
> +Block grace time: 00:10; Inode grace time: 00:20
> +
> +2. set group quota timer
> +*** Report for user quotas on device SCRATCH_DEV
> +Block grace time: DEF_TIME; Inode grace time: DEF_TIME
> +*** Report for group quotas on device SCRATCH_DEV
> +Block grace time: 00:30; Inode grace time: 00:40
> +*** Report for project quotas on device SCRATCH_DEV
> +Block grace time: 00:10; Inode grace time: 00:20
> +
> +3. set user quota timer
> +*** Report for user quotas on device SCRATCH_DEV
> +Block grace time: 00:50; Inode grace time: 01:00
> +*** Report for group quotas on device SCRATCH_DEV
> +Block grace time: 00:30; Inode grace time: 00:40
> +*** Report for project quotas on device SCRATCH_DEV
> +Block grace time: 00:10; Inode grace time: 00:20
> +
> +4. cycle mount test-1
> +*** Report for user quotas on device SCRATCH_DEV
> +Block grace time: 00:50; Inode grace time: 01:00
> +*** Report for group quotas on device SCRATCH_DEV
> +Block grace time: 00:30; Inode grace time: 00:40
> +*** Report for project quotas on device SCRATCH_DEV
> +Block grace time: 00:10; Inode grace time: 00:20
> +
> +5. fsck to force quota check
> +
> +6. cycle mount test-2
> +*** Report for user quotas on device SCRATCH_DEV
> +Block grace time: 00:50; Inode grace time: 01:00
> +*** Report for group quotas on device SCRATCH_DEV
> +Block grace time: 00:30; Inode grace time: 00:40
> +*** Report for project quotas on device SCRATCH_DEV
> +Block grace time: 00:10; Inode grace time: 00:20
> +
> +7. cycle mount test-3
> +*** Report for user quotas on device SCRATCH_DEV
> +Block grace time: 00:50; Inode grace time: 01:00
> +*** Report for group quotas on device SCRATCH_DEV
> +Block grace time: 00:30; Inode grace time: 00:40
> +*** Report for project quotas on device SCRATCH_DEV
> +Block grace time: 00:10; Inode grace time: 00:20
> diff --git a/tests/generic/group b/tests/generic/group
> index dc95b77b..a83f95cb 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -595,3 +595,4 @@
>  591 auto quick rw pipe splice
>  592 auto quick encrypt
>  593 auto quick encrypt
> +594 auto quick quota
>
Eric Sandeen May 16, 2020, 5:26 p.m. UTC | #2
On 5/16/20 12:23 PM, Eric Sandeen wrote:
> On 3/29/20 12:18 AM, Zorro Lang wrote:
>> Set different grace time, make sure each of quota (user, group and
>> project) timers can be set (by setquota) and get (by repquota)
>> correctly.
>>
> 
> Sorry for the late review; this works now on xfs & ext4, with my
> per-type patches in the kernel.
> 
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>

Oh, this is already merged.  o_O sorry, ignore my new RVB.

>> Signed-off-by: Zorro Lang <zlang@redhat.com>
>> ---
diff mbox series

Patch

diff --git a/tests/generic/594 b/tests/generic/594
new file mode 100755
index 00000000..e501d54c
--- /dev/null
+++ b/tests/generic/594
@@ -0,0 +1,108 @@ 
+#! /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.
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/quota
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+# 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
diff --git a/tests/generic/594.out b/tests/generic/594.out
new file mode 100644
index 00000000..f25e0fac
--- /dev/null
+++ b/tests/generic/594.out
@@ -0,0 +1,50 @@ 
+QA output created by 594
+1. set project quota timer
+*** Report for user quotas on device SCRATCH_DEV
+Block grace time: DEF_TIME; Inode grace time: DEF_TIME
+*** Report for group quotas on device SCRATCH_DEV
+Block grace time: DEF_TIME; Inode grace time: DEF_TIME
+*** Report for project quotas on device SCRATCH_DEV
+Block grace time: 00:10; Inode grace time: 00:20
+
+2. set group quota timer
+*** Report for user quotas on device SCRATCH_DEV
+Block grace time: DEF_TIME; Inode grace time: DEF_TIME
+*** Report for group quotas on device SCRATCH_DEV
+Block grace time: 00:30; Inode grace time: 00:40
+*** Report for project quotas on device SCRATCH_DEV
+Block grace time: 00:10; Inode grace time: 00:20
+
+3. set user quota timer
+*** Report for user quotas on device SCRATCH_DEV
+Block grace time: 00:50; Inode grace time: 01:00
+*** Report for group quotas on device SCRATCH_DEV
+Block grace time: 00:30; Inode grace time: 00:40
+*** Report for project quotas on device SCRATCH_DEV
+Block grace time: 00:10; Inode grace time: 00:20
+
+4. cycle mount test-1
+*** Report for user quotas on device SCRATCH_DEV
+Block grace time: 00:50; Inode grace time: 01:00
+*** Report for group quotas on device SCRATCH_DEV
+Block grace time: 00:30; Inode grace time: 00:40
+*** Report for project quotas on device SCRATCH_DEV
+Block grace time: 00:10; Inode grace time: 00:20
+
+5. fsck to force quota check
+
+6. cycle mount test-2
+*** Report for user quotas on device SCRATCH_DEV
+Block grace time: 00:50; Inode grace time: 01:00
+*** Report for group quotas on device SCRATCH_DEV
+Block grace time: 00:30; Inode grace time: 00:40
+*** Report for project quotas on device SCRATCH_DEV
+Block grace time: 00:10; Inode grace time: 00:20
+
+7. cycle mount test-3
+*** Report for user quotas on device SCRATCH_DEV
+Block grace time: 00:50; Inode grace time: 01:00
+*** Report for group quotas on device SCRATCH_DEV
+Block grace time: 00:30; Inode grace time: 00:40
+*** Report for project quotas on device SCRATCH_DEV
+Block grace time: 00:10; Inode grace time: 00:20
diff --git a/tests/generic/group b/tests/generic/group
index dc95b77b..a83f95cb 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -595,3 +595,4 @@ 
 591 auto quick rw pipe splice
 592 auto quick encrypt
 593 auto quick encrypt
+594 auto quick quota