[PATCH] xfs/333: test zoned realtime writeback EIO shutdown

Yao Sang <[email protected]>
Newsgroups org.kernel.vger.fstests,org.kernel.vger.linux-xfs
Message-ID <[email protected]>
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 <[email protected]>
---
This is a test for the XFS zoned writeback shutdown fix posted as:
https://lore.kernel.org/all/[email protected]/

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
+
+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
+
+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"
+
+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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.