Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Zorro Lang <zlang@kernel.org>
To: Yao Sang <sangyao@kylinos.cn>
Cc: fstests@vger.kernel.org, linux-xfs@vger.kernel.org, hch@lst.de,
	 djwong@kernel.org
Subject: Re: [PATCH] xfs/333: test zoned realtime writeback EIO shutdown
Date: Mon, 15 Jun 2026 00:19:09 +0800	[thread overview]
Message-ID: <ai7LiV1TrX5D_E2J@zlang-mailbox> (raw)
In-Reply-To: <20260612074231.1109213-1-sangyao@kylinos.cn>

On Fri, Jun 12, 2026 at 03:42:31PM +0800, Yao Sang wrote:
> Create a zoned realtime filesystem with a single user data open zone,
> dirty one zone worth of data, and inject a writeback error on the
> realtime device.
> 
> After disabling fault injection, fsync a second write.  The filesystem
> must already be shut down so that the second fsync fails quickly instead
> of waiting for zoned allocation progress.
> 
> Signed-off-by: Yao Sang <sangyao@kylinos.cn>
> ---
> This is a test for the XFS zoned writeback shutdown fix posted as:
> https://lore.kernel.org/all/20260611015305.1583003-1-sangyao@kylinos.cn/
> 
> Tested on a ZNS realtime XFS setup with fail_make_request enabled.  The
> test passes with the v2 XFS fix applied.  On a kernel without that fix,
> the second fsync waits behind the consumed open zone and reproduces the
> hung writer condition.
> 
>  tests/xfs/333     | 69 +++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/333.out |  1 +
>  2 files changed, 70 insertions(+)
>  create mode 100755 tests/xfs/333
>  create mode 100644 tests/xfs/333.out
> 
> diff --git a/tests/xfs/333 b/tests/xfs/333
> new file mode 100755
> index 00000000..aafee4c3
> --- /dev/null
> +++ b/tests/xfs/333
> @@ -0,0 +1,69 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2026 Kylin Software.
> +#
> +# FS QA Test No. 333
> +#
> +# Check that an unrecoverable writeback error on a zoned realtime device shuts
> +# down the filesystem.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick rw zone eio
> +
> +. ./common/filter
> +. ./common/fail_make_request
> +. ./common/zoned
> +
> +_require_debugfs
> +_require_scratch_nocheck
> +_require_realtime
> +_require_block_device $SCRATCH_RTDEV
> +_require_zoned_device $SCRATCH_RTDEV
> +_require_command "$BLKZONE_PROG" blkzone
> +_require_fail_make_request
> +
> +_cleanup()
> +{
> +	[ -n "$SCRATCH_RTDEV" ] && \
> +		_bdev_fail_make_request $SCRATCH_RTDEV 0 > /dev/null 2>&1
> +	_disallow_fail_make_request > /dev/null 2>&1
> +	_scratch_unmount > /dev/null 2>&1
> +	cd /
> +	rm -r -f $tmp.*
> +}
> +_register_cleanup _cleanup
   ^^^^^^^^^^^^^^^^^
This line isn't necessary. Since "_register_cleanup _cleanup" is called in
_begin_fstest, it only registers the function name (not function instance).
The latest definition will be called automatically, so there's no need to
worry.

> +
> +zone_capacity=$(_zone_capacity 0 $SCRATCH_RTDEV)
> +echo "zone capacity: $zone_capacity" >> $seqres.full
> +
> +_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
> +
> +# Leave only one open zone for user data.  If writeback fails after consuming
> +# it, further writers must either see shutdown or wait forever for zone space.
> +export MOUNT_OPTIONS="$MOUNT_OPTIONS -o max_open_zones=2"
> +_try_scratch_mount || _notrun "mount option not supported"
> +_require_xfs_scratch_zoned 1
> +
> +_prepare_for_eio_shutdown $SCRATCH_DEV
   ^^^^^^^^^^^^^^^^^^^^^^^^^
This line is already called in _try_scratch_mount, don't need to call it again,
except you want to run it on another device.

> +
> +testfile=$SCRATCH_MNT/writeback-error
> +waitfile=$SCRATCH_MNT/wait-for-zone
> +
> +$XFS_IO_PROG -f -c "pwrite -S 0x58 0 $zone_capacity" $testfile \
> +	>> $seqres.full 2>&1 || _fail "failed to dirty test file"
> +
> +_allow_fail_make_request 100 100000 0 > /dev/null
> +_bdev_fail_make_request $SCRATCH_RTDEV 1 > /dev/null
> +
> +$XFS_IO_PROG -c "fsync" $testfile >> $seqres.full 2>&1 && \
> +	_fail "fsync succeeded despite realtime device error"
> +
> +_bdev_fail_make_request $SCRATCH_RTDEV 0 > /dev/null
> +_disallow_fail_make_request > /dev/null
> +
> +$XFS_IO_PROG -f -c "pwrite -S 0x59 0 4k" -c "fsync" $waitfile \
> +	>> $seqres.full 2>&1 && \
> +	_fail "filesystem did not shut down after zoned writeback error"

OK, others looks good to me.

Since above changes are straightforward, if you don't have any other updates
that require a V2, I can just remove those two redundant lines for you when
merging.

Reviewed-by: Zorro Lang <zlang@kernel.org>

Thanks,
Zorro

> +
> +status=0
> +exit
> diff --git a/tests/xfs/333.out b/tests/xfs/333.out
> new file mode 100644
> index 00000000..3e11d156
> --- /dev/null
> +++ b/tests/xfs/333.out
> @@ -0,0 +1 @@
> +QA output created by 333
> -- 
> 2.25.1
> 

  parent reply	other threads:[~2026-06-14 16:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-12  7:42 [PATCH] xfs/333: test zoned realtime writeback EIO shutdown Yao Sang
2026-06-12  8:08 ` Christoph Hellwig
2026-06-14 16:19 ` Zorro Lang [this message]
2026-06-14 17:19   ` 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=ai7LiV1TrX5D_E2J@zlang-mailbox \
    --to=zlang@kernel.org \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sangyao@kylinos.cn \
    /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