Skip to contentSkip to conversation

xfs: test zone reset error handling

PATCH In review Christoph Hellwig 2 participants 4 messages Jan 27 – Jan 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: test zone reset error handling

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.

---
 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
tests/xfs/842 new file +63 -0
new file mode 100755
index 000000000000..8f6c13f1b19c
@@ -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
tests/xfs/842.out new file +2 -0
new file mode 100644
index 000000000000..718805b5766e
@@ -0,0 +1,2 @@
+QA output created by 842
+zone resets: 3
Signature · 1 line
2.47.3
#1 lore raw
Quoted 60 lines · Christoph Hellwig

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.

---
 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
tests/xfs/842 new file +42 -0
new file mode 100755
index 000000000000..8f6c13f1b19c
@@ -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

tests/xfs/842 line 52

Quoted 10 lines
tests/xfs/842 new file +10 -0
+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

Quoted 22 lines
tests/xfs/842 new file +10 -0
+# 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
tests/xfs/842.out new file +2 -0
new file mode 100644
index 000000000000..718805b5766e
@@ -0,0 +1,2 @@
+QA output created by 842
+zone resets: 3
Signature · 1 line
2.47.3
#2 lore raw
Quoted 5 lines · Darrick J. Wong

tests/xfs/842 line 52

Quoted 2 lines
tests/xfs/842 new file +2 -0
+# 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?

#3 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Darrick J. Wong

tests/xfs/842 line 52

Quoted 2 lines
tests/xfs/842 new file +2 -0
+# 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