FSTests Archive on lore.kernel.org
 help / color / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [RFC PATCH] generic: test PF_MEMALLOC interfering with accounting file write
Date: Thu, 12 Mar 2020 15:30:37 -0700
Message-ID: <20200312223037.GF8044@magnolia> (raw)
In-Reply-To: <20200312221437.141484-1-ebiggers@kernel.org>

On Thu, Mar 12, 2020 at 03:14:37PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> Add a regression test for the bug fixed by commit 10a98cb16d80 ("xfs:
> clear PF_MEMALLOC before exiting xfsaild thread").
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> 
> RFC for now since the commit is in xfs/for-next only, and I'm not sure
> the commit ID is stable.

It's not stable until it lands in Linus tree, unfortunately. :(

>  common/config         |  1 +
>  common/rc             | 11 ++++++++
>  tests/generic/901     | 60 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/901.out |  2 ++
>  tests/generic/group   |  1 +
>  5 files changed, 75 insertions(+)
>  create mode 100644 tests/generic/901
>  create mode 100644 tests/generic/901.out
> 
> diff --git a/common/config b/common/config
> index 1116cb995..8023273da 100644
> --- a/common/config
> +++ b/common/config
> @@ -220,6 +220,7 @@ export DUPEREMOVE_PROG="$(type -P duperemove)"
>  export CC_PROG="$(type -P cc)"
>  export FSVERITY_PROG="$(type -P fsverity)"
>  export OPENSSL_PROG="$(type -P openssl)"
> +export ACCTON_PROG="$(type -P accton)"
>  
>  # use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
>  # newer systems have udevadm command but older systems like RHEL5 don't.
> diff --git a/common/rc b/common/rc
> index 454f5ccf5..0bc4b14f2 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4168,6 +4168,17 @@ _check_xfs_scrub_does_unicode() {
>  	return 0
>  }
>  
> +# Require the 'accton' userspace tool and CONFIG_BSD_PROCESS_ACCT=y.
> +_require_bsd_process_accounting()
> +{
> +	_require_command "$ACCTON_PROG" accton
> +	$ACCTON_PROG on &> $tmp.test_accton
> +	cat $tmp.test_accton >> $seqres.full
> +	if grep 'Function not implemented' $tmp.test_accton; then
> +		_notrun "BSD process accounting support unavailable"
> +	fi

Should we run "$ACCTON_PROG off" here to turn process accounting back
off until the test needs it again?

Otherwise the logic looks sound.  Thanks for writing this up!

--D

> +}
> +
>  init_rc
>  
>  ################################################################################
> diff --git a/tests/generic/901 b/tests/generic/901
> new file mode 100644
> index 000000000..c59300f1b
> --- /dev/null
> +++ b/tests/generic/901
> @@ -0,0 +1,60 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright 2020 Google LLC
> +#
> +# FS QA Test No. 901
> +#
> +# Regression test for the bug fixed by commit 10a98cb16d80 ("xfs: clear
> +# PF_MEMALLOC before exiting xfsaild thread").  If the bug exists, a kernel
> +# WARNING should be triggered.  See the commit message for details.
> +#
> +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()
> +{
> +	$ACCTON_PROG off >> $seqres.full
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +_supported_fs generic
> +_supported_os Linux
> +_require_bsd_process_accounting
> +_require_chattr S
> +_require_test
> +_require_scratch
> +
> +# To trigger the bug we must unmount a filesystem while BSD process accounting
> +# is enabled.  The accounting file must also be located on a different
> +# filesystem and have the sync flag set.
> +
> +accounting_file=$TEST_DIR/$seq
> +
> +rm -f $accounting_file
> +touch $accounting_file
> +$CHATTR_PROG +S $accounting_file
> +
> +_scratch_mkfs &>> $seqres.full
> +$ACCTON_PROG $accounting_file >> $seqres.full
> +_scratch_mount
> +_scratch_unmount
> +$ACCTON_PROG off >> $seqres.full
> +
> +echo "Silence is golden"
> +
> +status=0
> +exit
> diff --git a/tests/generic/901.out b/tests/generic/901.out
> new file mode 100644
> index 000000000..b206bc11d
> --- /dev/null
> +++ b/tests/generic/901.out
> @@ -0,0 +1,2 @@
> +QA output created by 901
> +Silence is golden
> diff --git a/tests/generic/group b/tests/generic/group
> index dc95b77b3..61a679793 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
> +901 auto quick
> -- 
> 2.25.1
> 

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 22:14 Eric Biggers
2020-03-12 22:30 ` Darrick J. Wong [this message]

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=20200312223037.GF8044@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=ebiggers@kernel.org \
    --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

FSTests Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/fstests/0 fstests/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 fstests fstests/ https://lore.kernel.org/fstests \
		fstests@vger.kernel.org
	public-inbox-index fstests

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.fstests


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git