All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@kernel.org>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH v3 1/2] generic: soft quota limits testing within grace time
Date: Thu, 12 May 2022 12:06:47 -0700	[thread overview]
Message-ID: <20220512190647.GC27174@magnolia> (raw)
In-Reply-To: <20220512182203.2839593-1-zlang@kernel.org>

On Fri, May 13, 2022 at 02:22:02AM +0800, Zorro Lang wrote:
> After soft limits are exceeded, within the grace time, fs quota
> should allow more space allocation before exceeding hard limits,
> even if allocating many small files.
> 
> This case can cover bc37e4fb5cac (xfs: revert "xfs: actually bump
> warning counts when we send warnings"). And will help to expose
> later behavior changes on this side.
> 
> Signed-off-by: Zorro Lang <zlang@redhat.com>
> ---
> 
> According to the review points of:
>   https://lore.kernel.org/fstests/20220511163806.uc4z7td2remhdru3@zlang-mailbox/T/#m23940b47261165a0442c7ae1eb4d96a1489a2935
> V3 did below changes:
> 1) fix some comments description
> 2) add a few hard limit test
> 3) And bring in [PATCH 2/2], to help g/603 to use the common functions of this
>    patch.
> 
> Thanks,
> Zorro
> 
>  common/quota          | 48 +++++++++++++++++++++
>  tests/generic/999     | 99 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/999.out |  2 +
>  3 files changed, 149 insertions(+)
>  create mode 100755 tests/generic/999
>  create mode 100644 tests/generic/999.out
> 
> diff --git a/common/quota b/common/quota
> index 7fa1a61a..67698f74 100644
> --- a/common/quota
> +++ b/common/quota
> @@ -351,5 +351,53 @@ _qsetup()
>  	echo "Using type=$type id=$id" >> $seqres.full
>  }
>  
> +# Help to create project quota on directory, works for xfs and other fs.
> +# Usage: _create_project_quota <dirname> <projid> [name]
> +# Although the [name] is optional, better to specify it if need a fixed name.
> +_create_project_quota()
> +{
> +	local prjdir=$1
> +	local id=$2
> +	local name=$3
> +
> +	if [ -z "$name" ];then
> +		name=`echo $projdir | tr \/ \_`
> +	fi
> +
> +	rm -rf $prjdir
> +	mkdir $prjdir
> +	chmod ugo+rwx $prjdir
> +
> +	if [ -f /etc/projects -a ! -f $tmp.projects.bk ];then
> +		cat /etc/projects > $tmp.projects.bk
> +		echo >/etc/projects
> +	fi
> +	if [ -f /etc/projid -a ! -f $tmp.projid.bk ];then
> +		cat /etc/projid > $tmp.projid.bk
> +		echo >/etc/projid
> +	fi
> +
> +	cat >>/etc/projects <<EOF
> +$id:$prjdir
> +EOF
> +	cat >>/etc/projid <<EOF
> +$name:$id
> +EOF
> +	$XFS_IO_PROG -r -c "chproj $id" -c "chattr +P" $prjdir
> +}
> +
> +# If you've called _create_project_quota, then use this function in _cleanup
> +_restore_project_quota()
> +{
> +	if [ -f $tmp.projects.bk ];then
> +		cat $tmp.projects.bk > /etc/projects && \
> +			rm -f $tmp.projects.bk
> +	fi
> +	if [ -f $tmp.projid.bk ];then
> +		cat $tmp.projid.bk > /etc/projid && \
> +			rm -f $tmp.projid.bk
> +	fi
> +}
> +
>  # make sure this script returns success
>  /bin/true
> diff --git a/tests/generic/999 b/tests/generic/999
> new file mode 100755
> index 00000000..76d68df5
> --- /dev/null
> +++ b/tests/generic/999
> @@ -0,0 +1,99 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022 Red Hat Inc.  All Rights Reserved.
> +#
> +# FS QA Test No. 999
> +#
> +# Make sure filesystem quota works well, after soft limits are exceeded. The
> +# fs quota should allow more space allocation before exceeding hard limits
> +# and with in grace time.
> +#
> +# But different with other similar testing, this case tries to write many small
> +# files, to cover bc37e4fb5cac (xfs: revert "xfs: actually bump warning counts
> +# when we send warnings"). If there's a behavior change some day, this case
> +# might help to detect that too.
> +#
> +. ./common/preamble
> +_begin_fstest auto quota
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +	_restore_project_quota
> +	cd /
> +	rm -r -f $tmp.*
> +}
> +
> +# Import common functions.
> +. ./common/quota
> +
> +# real QA test starts here
> +_supported_fs generic
> +_require_scratch
> +_require_quota
> +_require_user
> +_require_group
> +
> +# Make sure the kernel supports project quota
> +_scratch_mkfs >$seqres.full 2>&1
> +_scratch_enable_pquota
> +_qmount_option "prjquota"
> +_qmount
> +_require_prjquota $SCRATCH_DEV
> +
> +exercise()
> +{
> +	local type=$1
> +	local file=$SCRATCH_MNT/testfile
> +
> +	echo "= Test type=$type quota =" >>$seqres.full
> +	_scratch_unmount
> +	_scratch_mkfs >>$seqres.full 2>&1
> +	if [ "$1" = "P" ];then
> +		_scratch_enable_pquota
> +	fi
> +	_qmount
> +	if [ "$1" = "P" ];then
> +		_create_project_quota $SCRATCH_MNT/t 100 $qa_user
> +		file=$SCRATCH_MNT/t/testfile
> +	fi
> +
> +	setquota -${type} $qa_user 1M 200M 0 0 $SCRATCH_MNT
> +	setquota -${type} -t 86400 86400 $SCRATCH_MNT
> +	repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
> +	# Exceed the soft quota limit a bit at first
> +	su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 2m' -c fsync ${file}.0" >>$seqres.full 2>&1
> +	# Write more data more times under soft quota limit exhausted condition,
> +	# but not reach hard limit. To make sure each write won't trigger EDQUOT.
> +	for ((i=1; i<=100; i++));do
> +		su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.$i" >>$seqres.full 2>&1

Hmm -- if pwrite or fsync hit an error, shouldn't we let that end up in
999.out so that the golden output diff fails?

> +		if [ $? -ne 0 ];then
> +			echo "Unexpected error (type=$type)!"
> +			break
> +		fi
> +	done
> +	repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
> +
> +	# As we've tested soft limit, now exceed the hard limit and give it a
> +	# test in passing.
> +	su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 100m' -c fsync ${file}.hard.0" >>$seqres.full 2>&1
> +	for ((i=1; i<=10; i++));do
> +		su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.hard.$i" >>$seqres.full 2>&1

Don't we want to encode the actual error in the golden output?

--D

> +		if [ $? -eq 0 ];then
> +			echo "Unexpected success (type=$type)!"
> +			break
> +		fi
> +	done
> +}
> +
> +_qmount_option "usrquota"
> +exercise u
> +_qmount_option "grpquota"
> +exercise g
> +_qmount_option "prjquota"
> +exercise P
> +
> +echo "Silence is golden"
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/generic/999.out b/tests/generic/999.out
> new file mode 100644
> index 00000000..3b276ca8
> --- /dev/null
> +++ b/tests/generic/999.out
> @@ -0,0 +1,2 @@
> +QA output created by 999
> +Silence is golden
> -- 
> 2.31.1
> 

  parent reply	other threads:[~2022-05-12 19:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 18:22 [PATCH v3 1/2] generic: soft quota limits testing within grace time Zorro Lang
2022-05-12 18:22 ` [PATCH v3 2/2] generic/603: use project quota create and restore common helpers Zorro Lang
2022-05-12 19:07   ` Darrick J. Wong
2022-05-12 19:06 ` Darrick J. Wong [this message]
2022-05-12 20:16   ` [PATCH v3 1/2] generic: soft quota limits testing within grace time Zorro Lang
2022-05-13  0:58     ` Darrick J. Wong
2022-05-13  5:09       ` Zorro Lang

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=20220512190647.GC27174@magnolia \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=zlang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.