From: Eric Sandeen <sandeen@redhat.com>
To: linux-xfs <linux-xfs@vger.kernel.org>, fstests <fstests@vger.kernel.org>
Subject: [PATCH 2/4] generic: test per-type quota softlimit enforcement timeout
Date: Mon, 18 May 2020 15:00:11 -0500 [thread overview]
Message-ID: <7102e1e3-bee6-7aa2-dce6-c0e7e0ce2983@redhat.com> (raw)
In-Reply-To: <9c9a63f3-13ab-d5b6-923c-4ea684b6b2f8@redhat.com>
From: Zorro Lang <zlang@redhat.com>
Set different block & inode grace timers for user, group and project
quotas, then test softlimit enforcement timeout, make sure different
grace timers as expected.
Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
common/quota | 4 +
tests/generic/902 | 187 ++++++++++++++++++++++++++++++++++++++++++
tests/generic/902.out | 41 +++++++++
tests/generic/group | 1 +
4 files changed, 233 insertions(+)
create mode 100755 tests/generic/902
create mode 100644 tests/generic/902.out
diff --git a/common/quota b/common/quota
index 240e0bbc..1437d5f7 100644
--- a/common/quota
+++ b/common/quota
@@ -217,6 +217,10 @@ _qmount()
if [ "$FSTYP" != "xfs" ]; then
quotacheck -ug $SCRATCH_MNT >>$seqres.full 2>&1
quotaon -ug $SCRATCH_MNT >>$seqres.full 2>&1
+ # try to turn on project quota if it's supported
+ if quotaon --help 2>&1 | grep -q '\-\-project'; then
+ quotaon --project $SCRATCH_MNT >>$seqres.full 2>&1
+ fi
fi
chmod ugo+rwx $SCRATCH_MNT
}
diff --git a/tests/generic/902 b/tests/generic/902
new file mode 100755
index 00000000..03b4dcb3
--- /dev/null
+++ b/tests/generic/902
@@ -0,0 +1,187 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Red Hat, Inc. All Rights Reserved.
+#
+# FS QA Test No. 902
+#
+# Test per-type(user, group and project) filesystem quota timers, make sure
+# enforcement
+#
+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()
+{
+ restore_project
+ 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
+
+require_project()
+{
+ rm -f $tmp.projects $tmp.projid
+ if [ -f /etc/projects ];then
+ cat /etc/projects > $tmp.projects
+ fi
+ if [ -f /etc/projid ];then
+ cat /etc/projid > $tmp.projid
+ fi
+
+ cat >/etc/projects <<EOF
+100:$SCRATCH_MNT/t
+EOF
+ cat >/etc/projid <<EOF
+$qa_user:100
+EOF
+ PROJECT_CHANGED=1
+}
+
+restore_project()
+{
+ if [ "$PROJECT_CHANGED" = "1" ];then
+ rm -f /etc/projects /etc/projid
+ if [ -f $tmp.projects ];then
+ cat $tmp.projects > /etc/projects
+ fi
+ if [ -f $tmp.projid ];then
+ cat $tmp.projid > /etc/projid
+ fi
+ fi
+}
+
+init_files()
+{
+ local dir=$1
+
+ echo "### Initialize files, and their mode and ownership"
+ touch $dir/file{1,2} 2>/dev/null
+ chown $qa_user $dir/file{1,2} 2>/dev/null
+ chgrp $qa_user $dir/file{1,2} 2>/dev/null
+ chmod 777 $dir 2>/dev/null
+}
+
+cleanup_files()
+{
+ echo "### Remove all files"
+ rm -f ${1}/file{1,2,3,4,5,6}
+}
+
+test_grace()
+{
+ local type=$1
+ local dir=$2
+ local bgrace=$3
+ local igrace=$4
+
+ init_files $dir
+ echo "--- Test block quota ---"
+ # Firstly fit below block soft limit
+ echo "Write 225 blocks..."
+ su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((225 * $BLOCK_SIZE))' \
+ -c fsync $dir/file1" 2>&1 >>$seqres.full | \
+ _filter_xfs_io_error | tee -a $seqres.full
+ repquota -v -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+ # Secondly overcome block soft limit
+ echo "Rewrite 250 blocks plus 1 byte, over the block softlimit..."
+ su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((250 * $BLOCK_SIZE + 1))' \
+ -c fsync $dir/file1" 2>&1 >>$seqres.full | \
+ _filter_xfs_io_error | tee -a $seqres.full
+ repquota -v -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+ # Reset grace time here, make below grace time test more accurate
+ setquota -$type $qa_user -T $bgrace $igrace $SCRATCH_MNT 2>/dev/null
+ # Now sleep enough grace time and check that softlimit got enforced
+ sleep $((bgrace + 1))
+ echo "Try to write 1 one more block after grace..."
+ su $qa_user -c "$XFS_IO_PROG -c 'truncate 0' -c 'pwrite 0 $BLOCK_SIZE' \
+ $dir/file2" 2>&1 >>$seqres.full | _filter_xfs_io_error | \
+ tee -a $seqres.full
+ repquota -v -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+ echo "--- Test inode quota ---"
+ # And now the softlimit test for inodes
+ # First reset space limits so that we don't have problems with
+ # space reservations on XFS
+ setquota -$type $qa_user 0 0 3 100 $SCRATCH_MNT
+ echo "Create 2 more files, over the inode softlimit..."
+ su $qa_user -c "touch $dir/file3 $dir/file4" 2>&1 >>$seqres.full | \
+ _filter_scratch | tee -a $seqres.full
+ repquota -v -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+ # Reset grace time here, make below grace time test more accurate
+ setquota -$type $qa_user -T $bgrace $igrace $SCRATCH_MNT 2>/dev/null
+ # Wait and check grace time enforcement
+ sleep $((igrace+1))
+ echo "Try to create one more inode after grace..."
+ su $qa_user -c "touch $dir/file5" 2>&1 >>$seqres.full |
+ _filter_scratch | tee -a $seqres.full
+ repquota -v -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
+ cleanup_files $dir
+}
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_setquota_project
+_require_quota
+_require_user
+_require_group
+
+_scratch_mkfs >$seqres.full 2>&1
+_scratch_enable_pquota
+_qmount_option "usrquota,grpquota,prjquota"
+_qmount
+_require_prjquota $SCRATCH_DEV
+BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
+rm -rf $SCRATCH_MNT/t
+mkdir $SCRATCH_MNT/t
+$XFS_IO_PROG -r -c "chproj 100" -c "chattr +P" $SCRATCH_MNT/t
+require_project
+
+echo "### Set up different grace timers to each type of quota"
+UBGRACE=12
+UIGRACE=10
+GBGRACE=4
+GIGRACE=2
+PBGRACE=8
+PIGRACE=6
+
+setquota -u $qa_user $((250 * $BLOCK_SIZE / 1024)) \
+ $((1000 * $BLOCK_SIZE / 1024)) 3 100 $SCRATCH_MNT
+setquota -u -t $UBGRACE $UIGRACE $SCRATCH_MNT
+echo; echo "### Test user quota softlimit and grace time"
+test_grace u $SCRATCH_MNT $UBGRACE $UIGRACE
+# Reset the user quota space & inode limits, avoid it affect later test
+setquota -u $qa_user 0 0 0 0 $SCRATCH_MNT
+
+setquota -g $qa_user $((250 * $BLOCK_SIZE / 1024)) \
+ $((1000 * $BLOCK_SIZE / 1024)) 3 100 $SCRATCH_MNT
+setquota -g -t $GBGRACE $GIGRACE $SCRATCH_MNT
+echo; echo "### Test group quota softlimit and grace time"
+test_grace g $SCRATCH_MNT $GBGRACE $GIGRACE
+# Reset the group quota space & inode limits, avoid it affect later test
+setquota -g $qa_user 0 0 0 0 $SCRATCH_MNT
+
+setquota -P $qa_user $((250 * $BLOCK_SIZE / 1024)) \
+ $((1000 * $BLOCK_SIZE / 1024)) 3 100 $SCRATCH_MNT
+setquota -P -t $PBGRACE $PIGRACE $SCRATCH_MNT
+echo; echo "### Test project quota softlimit and grace time"
+test_grace P $SCRATCH_MNT/t $PBGRACE $PIGRACE
+# Reset the project quota space & inode limits
+setquota -P $qa_user 0 0 0 0 $SCRATCH_MNT
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/902.out b/tests/generic/902.out
new file mode 100644
index 00000000..6e15eaeb
--- /dev/null
+++ b/tests/generic/902.out
@@ -0,0 +1,41 @@
+QA output created by 902
+### Set up different grace timers to each type of quota
+
+### Test user quota softlimit and grace time
+### Initialize files, and their mode and ownership
+--- Test block quota ---
+Write 225 blocks...
+Rewrite 250 blocks plus 1 byte, over the block softlimit...
+Try to write 1 one more block after grace...
+pwrite: Disk quota exceeded
+--- Test inode quota ---
+Create 2 more files, over the inode softlimit...
+Try to create one more inode after grace...
+touch: cannot touch 'SCRATCH_MNT/file5': Disk quota exceeded
+### Remove all files
+
+### Test group quota softlimit and grace time
+### Initialize files, and their mode and ownership
+--- Test block quota ---
+Write 225 blocks...
+Rewrite 250 blocks plus 1 byte, over the block softlimit...
+Try to write 1 one more block after grace...
+pwrite: Disk quota exceeded
+--- Test inode quota ---
+Create 2 more files, over the inode softlimit...
+Try to create one more inode after grace...
+touch: cannot touch 'SCRATCH_MNT/file5': Disk quota exceeded
+### Remove all files
+
+### Test project quota softlimit and grace time
+### Initialize files, and their mode and ownership
+--- Test block quota ---
+Write 225 blocks...
+Rewrite 250 blocks plus 1 byte, over the block softlimit...
+Try to write 1 one more block after grace...
+pwrite: Disk quota exceeded
+--- Test inode quota ---
+Create 2 more files, over the inode softlimit...
+Try to create one more inode after grace...
+touch: cannot touch 'SCRATCH_MNT/t/file5': Disk quota exceeded
+### Remove all files
diff --git a/tests/generic/group b/tests/generic/group
index 50c340a6..66e71a70 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -601,3 +601,4 @@
596 auto quick
900 auto quick perms
901 auto quick perms
+902 auto quick quota
--
2.17.0
next prev parent reply other threads:[~2020-05-18 20:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ea649599-f8a9-deb9-726e-329939befade@redhat.com>
2020-05-18 19:59 ` [PATCH 0/4] fstests: more quota related tests Eric Sandeen
2020-05-18 19:59 ` [PATCH 1/4] xfs: make sure our default quota warning limits and grace periods survive quotacheck Eric Sandeen
2020-05-31 16:17 ` Eryu Guan
2020-05-18 20:00 ` Eric Sandeen [this message]
2020-05-31 16:15 ` [PATCH 2/4] generic: test per-type quota softlimit enforcement timeout Eryu Guan
2020-06-01 12:48 ` Zorro Lang
2020-06-01 14:36 ` Eric Sandeen
2020-06-01 16:39 ` Darrick J. Wong
2020-06-11 5:12 ` Zorro Lang
2020-06-11 15:40 ` Darrick J. Wong
2020-05-18 20:00 ` [PATCH 3/4] fstests: individual user grace period extension via setquota Eric Sandeen
2020-05-18 20:01 ` [PATCH 4/4] fstests: individual user grace period extension via xfs_quota Eric Sandeen
2020-05-20 15:39 ` [PATCH 0/4] fstests: more quota related tests Darrick J. Wong
2020-05-20 15:46 ` Eric Sandeen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7102e1e3-bee6-7aa2-dce6-c0e7e0ce2983@redhat.com \
--to=sandeen@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).