* [PATCH] xfs: test zone reset error handling
@ 2026-01-27 16:09 Christoph Hellwig
2026-01-28 1:42 ` Darrick J. Wong
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2026-01-27 16:09 UTC (permalink / raw)
To: zlang; +Cc: djwong, hans.holmberg, linux-xfs, fstests
Add a test that exercises the zone gc error handling, aka shutting
down the file system or not mounting it using the new error
injection knob and stats.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
tests/xfs/842 | 63 +++++++++++++++++++++++++++++++++++++++++++++++
tests/xfs/842.out | 2 ++
2 files changed, 65 insertions(+)
create mode 100755 tests/xfs/842
create mode 100644 tests/xfs/842.out
diff --git a/tests/xfs/842 b/tests/xfs/842
new file mode 100755
index 000000000000..8f6c13f1b19c
--- /dev/null
+++ b/tests/xfs/842
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Christoph Hellwig.
+#
+# FS QA Test No. 842
+#
+# Test that GC defragments sequentially written files.
+#
+. ./common/preamble
+_begin_fstest auto quick mount zone
+
+. ./common/filter
+. ./common/zoned
+
+_require_scratch
+_require_fs_sysfs stats/stats
+
+count_zone_resets() {
+ _get_fs_sysfs_attr $SCRATCH_DEV stats/stats | awk '/zoned/ {print $4}'
+}
+
+_scratch_mkfs >>$seqres.full 2>&1
+
+# figure out how much space we need for 3 zones worth of user data...
+blocksize=`_scratch_xfs_get_sb_field blocksize`
+rgblocks=`_scratch_xfs_get_sb_field rgextents`
+rgsize=$((3 * rgblocks * blocksize))
+echo "blocksize=${blocksize}, rgblocks=${rgblocks}, rgsize=${rgsize}" >>$seqres.full 2>&1
+
+# .. and create a file system with that size
+_scratch_mkfs_sized $rgsize >>$seqres.full 2>&1
+
+SAVED_MOUNT_OPTIONS="$MOUNT_OPTIONS"
+export MOUNT_OPTIONS="$MOUNT_OPTIONS -o errortag=zone_reset"
+_try_scratch_mount || _notrun "mount option not supported"
+_require_xfs_scratch_zoned
+
+# fill the file system and remove the data again, this should trigger zone
+# resets that will fail due to the error detection
+dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M >/dev/null 2>&1
+sync $SCRATCH_MNT
+rm $SCRATCH_MNT/foo
+sync $SCRATCH_MNT
+sleep 1
+
+touch $SCRATCH_MNT/bar 2>/dev/null && _fail "file system not shutdown"
+
+# unmount the shutdown file system
+_scratch_unmount
+
+# try mounting with error injection still enabled. This should fail.
+_try_scratch_mount && _fail "file system mounted despite zone reset errors"
+
+# now try without the error injection
+MOUNT_OPTIONS="$SAVED_MOUNT_OPTIONS"
+_scratch_mount
+
+# all three zones should be reset on mount
+nr_resets=$(count_zone_resets)
+echo "zone resets: $nr_resets"
+
+status=0
+exit
diff --git a/tests/xfs/842.out b/tests/xfs/842.out
new file mode 100644
index 000000000000..718805b5766e
--- /dev/null
+++ b/tests/xfs/842.out
@@ -0,0 +1,2 @@
+QA output created by 842
+zone resets: 3
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: test zone reset error handling
2026-01-27 16:09 [PATCH] xfs: test zone reset error handling Christoph Hellwig
@ 2026-01-28 1:42 ` Darrick J. Wong
2026-01-28 3:38 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2026-01-28 1:42 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: zlang, hans.holmberg, linux-xfs, fstests
On Tue, Jan 27, 2026 at 05:09:06PM +0100, Christoph Hellwig wrote:
> Add a test that exercises the zone gc error handling, aka shutting
> down the file system or not mounting it using the new error
> injection knob and stats.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> tests/xfs/842 | 63 +++++++++++++++++++++++++++++++++++++++++++++++
> tests/xfs/842.out | 2 ++
> 2 files changed, 65 insertions(+)
> create mode 100755 tests/xfs/842
> create mode 100644 tests/xfs/842.out
>
> diff --git a/tests/xfs/842 b/tests/xfs/842
> new file mode 100755
> index 000000000000..8f6c13f1b19c
> --- /dev/null
> +++ b/tests/xfs/842
> @@ -0,0 +1,63 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2026 Christoph Hellwig.
> +#
> +# FS QA Test No. 842
> +#
> +# Test that GC defragments sequentially written files.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick mount zone
> +
> +. ./common/filter
> +. ./common/zoned
> +
> +_require_scratch
> +_require_fs_sysfs stats/stats
> +
> +count_zone_resets() {
> + _get_fs_sysfs_attr $SCRATCH_DEV stats/stats | awk '/zoned/ {print $4}'
> +}
> +
> +_scratch_mkfs >>$seqres.full 2>&1
> +
> +# figure out how much space we need for 3 zones worth of user data...
> +blocksize=`_scratch_xfs_get_sb_field blocksize`
> +rgblocks=`_scratch_xfs_get_sb_field rgextents`
> +rgsize=$((3 * rgblocks * blocksize))
> +echo "blocksize=${blocksize}, rgblocks=${rgblocks}, rgsize=${rgsize}" >>$seqres.full 2>&1
> +
> +# .. and create a file system with that size
> +_scratch_mkfs_sized $rgsize >>$seqres.full 2>&1
> +
> +SAVED_MOUNT_OPTIONS="$MOUNT_OPTIONS"
> +export MOUNT_OPTIONS="$MOUNT_OPTIONS -o errortag=zone_reset"
> +_try_scratch_mount || _notrun "mount option not supported"
> +_require_xfs_scratch_zoned
> +
> +# fill the file system and remove the data again, this should trigger zone
> +# resets that will fail due to the error detection
> +dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M >/dev/null 2>&1
> +sync $SCRATCH_MNT
> +rm $SCRATCH_MNT/foo
> +sync $SCRATCH_MNT
> +sleep 1
> +
> +touch $SCRATCH_MNT/bar 2>/dev/null && _fail "file system not shutdown"
> +
> +# unmount the shutdown file system
> +_scratch_unmount
> +
> +# try mounting with error injection still enabled. This should fail.
> +_try_scratch_mount && _fail "file system mounted despite zone reset errors"
Is it necessary to _fail here explicitly? Or could you just echo that
string and let the golden output disturbance cause the test to fail?
--D
> +# now try without the error injection
> +MOUNT_OPTIONS="$SAVED_MOUNT_OPTIONS"
> +_scratch_mount
> +
> +# all three zones should be reset on mount
> +nr_resets=$(count_zone_resets)
> +echo "zone resets: $nr_resets"
> +
> +status=0
> +exit
> diff --git a/tests/xfs/842.out b/tests/xfs/842.out
> new file mode 100644
> index 000000000000..718805b5766e
> --- /dev/null
> +++ b/tests/xfs/842.out
> @@ -0,0 +1,2 @@
> +QA output created by 842
> +zone resets: 3
> --
> 2.47.3
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: test zone reset error handling
2026-01-28 1:42 ` Darrick J. Wong
@ 2026-01-28 3:38 ` Christoph Hellwig
2026-01-28 5:05 ` Darrick J. Wong
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2026-01-28 3:38 UTC (permalink / raw)
To: Darrick J. Wong
Cc: Christoph Hellwig, zlang, hans.holmberg, linux-xfs, fstests
On Tue, Jan 27, 2026 at 05:42:55PM -0800, Darrick J. Wong wrote:
> > +# try mounting with error injection still enabled. This should fail.
> > +_try_scratch_mount && _fail "file system mounted despite zone reset errors"
>
> Is it necessary to _fail here explicitly? Or could you just echo that
> string and let the golden output disturbance cause the test to fail?
The echo would work to. But why would that be prefable? Is there some
hidden downside to _fail I haven't noticed in all the years?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: test zone reset error handling
2026-01-28 3:38 ` Christoph Hellwig
@ 2026-01-28 5:05 ` Darrick J. Wong
0 siblings, 0 replies; 4+ messages in thread
From: Darrick J. Wong @ 2026-01-28 5:05 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: zlang, hans.holmberg, linux-xfs, fstests
On Wed, Jan 28, 2026 at 04:38:19AM +0100, Christoph Hellwig wrote:
> On Tue, Jan 27, 2026 at 05:42:55PM -0800, Darrick J. Wong wrote:
> > > +# try mounting with error injection still enabled. This should fail.
> > > +_try_scratch_mount && _fail "file system mounted despite zone reset errors"
> >
> > Is it necessary to _fail here explicitly? Or could you just echo that
> > string and let the golden output disturbance cause the test to fail?
>
> The echo would work to. But why would that be prefable? Is there some
> hidden downside to _fail I haven't noticed in all the years?
Nah, I was just wondering what happens if the test keeps going instead
of exiting immediately.
--D
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-28 5:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 16:09 [PATCH] xfs: test zone reset error handling Christoph Hellwig
2026-01-28 1:42 ` Darrick J. Wong
2026-01-28 3:38 ` Christoph Hellwig
2026-01-28 5:05 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox