linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eryu Guan <guan@eryu.me>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Eryu Guan <guaneryu@gmail.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	linux-unionfs@vger.kernel.org, fstests@vger.kernel.org
Subject: Re: [PATCH] overlay: add test for copy up of lower file attributes
Date: Mon, 26 Jul 2021 00:27:39 +0800	[thread overview]
Message-ID: <YP2Q+xTjGICXfOwl@desktop> (raw)
In-Reply-To: <20210722164634.394499-1-amir73il@gmail.com>

On Thu, Jul 22, 2021 at 07:46:34PM +0300, Amir Goldstein wrote:
> Overlayfs copies up a subset of lower file attributes since kernel
> commits:
> 173ff5c9ec37 ("ovl: consistent behavior for immutable/append-only inodes")
> 2e3f6e87c2b0 ("ovl: copy up sync/noatime fileattr flags")
> 
> This test verifies this functionality works correctly and that it
> survives power failure and/or mount cycle.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

Looks good to me overall, just one minor question below.

> ---
> 
> Eryu,
> 
> This test is failing on master and passes on overlayfs-next.
> 
> Thanks,
> Amir.
> 
>  tests/overlay/078     | 145 ++++++++++++++++++++++++++++++++++++++++++
>  tests/overlay/078.out |   2 +
>  2 files changed, 147 insertions(+)
>  create mode 100755 tests/overlay/078
>  create mode 100644 tests/overlay/078.out
> 
> diff --git a/tests/overlay/078 b/tests/overlay/078
> new file mode 100755
> index 00000000..b43449d1
> --- /dev/null
> +++ b/tests/overlay/078
> @@ -0,0 +1,145 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2018 Huawei.  All Rights Reserved.
> +# Copyright (C) 2021 CTERA Networks. All Rights Reserved.
> +#
> +# FS QA Test 078
> +#
> +# Test copy up of lower file attributes.
> +#
> +# Overlayfs copies up a subset of lower file attributes since kernel commits:
> +# 173ff5c9ec37 ("ovl: consistent behavior for immutable/append-only inodes")
> +# 2e3f6e87c2b0 ("ovl: copy up sync/noatime fileattr flags")
> +#
> +# This test is similar and was derived from generic/507, but instead
> +# of creating new files which are created in upper layer, prepare
> +# the file with attributes in lower layer and verify that attributes
> +# are not lost during copy up, (optional) shutdown and mount cycle.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick perms shutdown

I noticed that generic/507 has the same groups defined, but I'm
wondering if 'perms' is right group, 'attr' seems a better fit to me.
And we could add 'copyup' group as well.

> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +	cd /
> +	$CHATTR_PROG -ai $lowertestfile &> /dev/null
> +	rm -f $tmp.*
> +}
> +
> +# Import common functions.
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs generic

s/generic/overlay/

Thanks,
Eryu

> +
> +_require_command "$LSATTR_PROG" lasttr
> +_require_command "$CHATTR_PROG" chattr
> +_require_chattr ASai
> +_require_xfs_io_command "syncfs"
> +
> +_require_scratch
> +_require_scratch_shutdown
> +
> +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
> +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
> +workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
> +lowertestfile=$lowerdir/testfile
> +testfile=$SCRATCH_MNT/testfile
> +
> +_scratch_mkfs
> +mkdir -p $lowerdir
> +touch $lowertestfile
> +_scratch_mount
> +
> +# Set another flag on lowertestfile and verify all flags
> +# are kept though copy up (optional shutdown) and mount cycle
> +do_check()
> +{
> +	attr=$1
> +
> +	echo "Test chattr +$1 $2" >> $seqres.full
> +
> +	$UMOUNT_PROG $SCRATCH_MNT
> +
> +	# Add attribute to lower file
> +	$CHATTR_PROG +$attr $lowertestfile
> +
> +	# Re-create upperdir/workdir
> +	rm -rf $upperdir $workdir
> +	mkdir -p $upperdir $workdir
> +
> +	if [ "$2" == "shutdown" ]; then
> +		$XFS_IO_PROG -r $lowertestfile -c "fsync" | _filter_xfs_io
> +	fi
> +
> +	_scratch_mount
> +
> +	before=`$LSATTR_PROG $testfile`
> +
> +	# Write file in append mode to test copy up of append-only attribute
> +	# Expect failure on write to immutable file
> +	expect=0
> +	if [ "$1" == "i" ]; then
> +		expect=1
> +	fi
> +	$XFS_IO_PROG -a -c "pwrite -S 0x61 0 10" $testfile >> $seqres.full 2>&1
> +	result=$?
> +	if [ $result != $expect ]; then
> +		echo "Write unexpectedly returned $result for file with attribute '$attr'"
> +	fi
> +
> +	if [ "$2" == "shutdown" ]; then
> +		$XFS_IO_PROG -r $testfile -c "fsync" | _filter_xfs_io
> +		_scratch_shutdown | tee -a $seqres.full
> +	fi
> +
> +	_scratch_cycle_mount
> +
> +	after=`$LSATTR_PROG $testfile`
> +	echo "Before copy up: $before" >> $seqres.full
> +	echo "After  copy up: $after" >> $seqres.full
> +
> +	# Verify attributes were not lost during copy up, shutdown and mount cycle
> +	if [ "$before" != "$after" ]; then
> +		echo "Before copy up: $before"
> +		echo "After  copy up: $after"
> +	fi
> +
> +	echo "Test chattr -$1 $2" >> $seqres.full
> +
> +	# Delete attribute from overlay file
> +	$CHATTR_PROG -$attr $testfile
> +
> +	before=`$LSATTR_PROG $testfile`
> +
> +	if [ "$2" == "shutdown" ]; then
> +		$XFS_IO_PROG -r $testfile -c "fsync" | _filter_xfs_io
> +		_scratch_shutdown | tee -a $seqres.full
> +	fi
> +
> +	_scratch_cycle_mount
> +
> +	after=`$LSATTR_PROG $testfile`
> +	echo "Before mount cycle: $before" >> $seqres.full
> +	echo "After  mount cycle: $after" >> $seqres.full
> +
> +	# Verify attribute deletion was not lost during shutdown or mount cycle
> +	if [ "$before" != "$after" ]; then
> +		echo "Before mount cycle: $before"
> +		echo "After  mount cycle: $after"
> +	fi
> +}
> +
> +echo "Silence is golden"
> +
> +# This is the subset of attributes copied up by overlayfs since kernel
> +# commit ...
> +opts="A S a i"
> +for i in $opts; do
> +	do_check $i
> +	do_check $i shutdown
> +done
> +
> +status=0
> +exit
> diff --git a/tests/overlay/078.out b/tests/overlay/078.out
> new file mode 100644
> index 00000000..b8acea8c
> --- /dev/null
> +++ b/tests/overlay/078.out
> @@ -0,0 +1,2 @@
> +QA output created by 078
> +Silence is golden
> -- 
> 2.32.0
> 

  reply	other threads:[~2021-07-25 16:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-22 16:46 [PATCH] overlay: add test for copy up of lower file attributes Amir Goldstein
2021-07-25 16:27 ` Eryu Guan [this message]
2021-07-25 18:21   ` Amir Goldstein
2021-07-26  3:13     ` Eryu Guan
2021-08-02 23:07 ` Darrick J. Wong
2021-08-03  7:21   ` Amir Goldstein
2021-08-04  3:44     ` Darrick J. Wong

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=YP2Q+xTjGICXfOwl@desktop \
    --to=guan@eryu.me \
    --cc=amir73il@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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).