Re: [PATCH 1/3] fstests: add helper _scratch_shutdown_and_syncfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 09, 2025 at 05:19:13PM +0200, Amir Goldstein wrote:
> Test xfs/546 has to chain syncfs after shutdown and cannot
> use the _scratch_shitdown helper, because after shutdown a fd
> cannot be opened to execute syncfs on.
> 
> The xfs_io command of chaining syncfs after shutdown is rather
> more complex to execute in the derived overlayfs test overlay/087.
> 
> Add a helper to abstract this complexity from test writers.
> Add a _require statement to match.
> 
> Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
> ---

As we talked, I think this version is good to me, I'll merge it with
the typo fix which Darrick metioned :)

Reviewed-by: Zorro Lang <zlang@xxxxxxxxxx>

Thanks,
Zorro

>  common/rc         | 27 +++++++++++++++++++++++++++
>  tests/overlay/087 | 13 +++----------
>  tests/xfs/546     |  5 ++---
>  3 files changed, 32 insertions(+), 13 deletions(-)
> 
> diff --git a/common/rc b/common/rc
> index f71cc8f0..d9a8b52e 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -595,6 +595,27 @@ _scratch_shutdown_handle()
>  	fi
>  }
>  
> +_scratch_shutdown_and_syncfs()
> +{
> +	if [ $FSTYP = "overlay" ]; then
> +		# In lagacy overlay usage, it may specify directory as
> +		# SCRATCH_DEV, in this case OVL_BASE_SCRATCH_DEV
> +		# will be null, so check OVL_BASE_SCRATCH_DEV before
> +		# running shutdown to avoid shutting down base fs accidently.
> +		if [ -z $OVL_BASE_SCRATCH_DEV ]; then
> +			_fail "_scratch_shutdown: call _require_scratch_shutdown first in test"
> +		fi
> +		# This command is complicated a bit because in the case of overlayfs the
> +		# syncfs fd needs to be opened before shutdown and it is different from the
> +		# shutdown fd, so we cannot use the _scratch_shutdown() helper.
> +		# Filter out xfs_io output of active fds.
> +		$XFS_IO_PROG -x -c "open $(_scratch_shutdown_handle)" -c 'shutdown -f ' \
> +				-c close -c syncfs $SCRATCH_MNT | grep -vF '[00'
> +	else
> +		$XFS_IO_PROG -x -c 'shutdown -f ' -c syncfs $SCRATCH_MNT
> +	fi
> +}
> +
>  _move_mount()
>  {
>  	local mnt=$1
> @@ -4102,6 +4123,12 @@ _require_scratch_shutdown()
>  	_scratch_unmount
>  }
>  
> +_require_scratch_shutdown_and_syncfs()
> +{
> +	_require_xfs_io_command syncfs
> +	_require_scratch_shutdown
> +}
> +
>  _check_s_dax()
>  {
>  	local target=$1
> diff --git a/tests/overlay/087 b/tests/overlay/087
> index a5afb0d5..2ad069db 100755
> --- a/tests/overlay/087
> +++ b/tests/overlay/087
> @@ -32,9 +32,8 @@ _begin_fstest auto quick mount shutdown
>  
>  
>  # Modify as appropriate.
> -_require_xfs_io_command syncfs
>  _require_scratch_nocheck
> -_require_scratch_shutdown
> +_require_scratch_shutdown_and_syncfs
>  
>  [ "$OVL_BASE_FSTYP" == "xfs" ] || \
>  	_notrun "base fs $OVL_BASE_FSTYP has unknown behavior with syncfs after shutdown"
> @@ -43,19 +42,13 @@ _require_scratch_shutdown
>  # bother checking the filesystem afterwards since we never wrote anything.
>  echo "=== syncfs after shutdown"
>  _scratch_mount
> -# This command is complicated a bit because in the case of overlayfs the
> -# syncfs fd needs to be opened before shutdown and it is different from the
> -# shutdown fd, so we cannot use the _scratch_shutdown() helper.
> -# Filter out xfs_io output of active fds.
> -$XFS_IO_PROG -x -c "open $(_scratch_shutdown_handle)" -c 'shutdown -f ' -c close -c syncfs $SCRATCH_MNT | \
> -	grep -vF '[00'
> +_scratch_shutdown_and_syncfs
>  
>  # Now repeat the same test with a volatile overlayfs mount and expect no error
>  _scratch_unmount
>  echo "=== syncfs after shutdown (volatile)"
>  _scratch_mount -o volatile
> -$XFS_IO_PROG -x -c "open $(_scratch_shutdown_handle)" -c 'shutdown -f ' -c close -c syncfs $SCRATCH_MNT | \
> -	grep -vF '[00'
> +_scratch_shutdown_and_syncfs
>  
>  # success, all done
>  status=0
> diff --git a/tests/xfs/546 b/tests/xfs/546
> index 316ffc50..c50d41a6 100755
> --- a/tests/xfs/546
> +++ b/tests/xfs/546
> @@ -27,14 +27,13 @@ _begin_fstest auto quick shutdown
>  
>  
>  # Modify as appropriate.
> -_require_xfs_io_command syncfs
>  _require_scratch_nocheck
> -_require_scratch_shutdown
> +_require_scratch_shutdown_and_syncfs
>  
>  # Reuse the fs formatted when we checked for the shutdown ioctl, and don't
>  # bother checking the filesystem afterwards since we never wrote anything.
>  _scratch_mount
> -$XFS_IO_PROG -x -c 'shutdown -f ' -c syncfs $SCRATCH_MNT
> +_scratch_shutdown_and_syncfs
>  
>  # success, all done
>  status=0
> -- 
> 2.34.1
> 





[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux