Skip to contentSkip to conversation

various tests for zone aligned RT subvolumes v2

PATCH In review Christoph Hellwig 2 participants 7 messages Dec 18, 2025 – Dec 19, 2025

lore
Share & tools
lore
#0 lore raw

Hi all,

this adds a few tests to make sure zoned RT subvolumes are always aligned to the zone size.

Changes since v1:
- don't run the rump RTG test on non-zoned setups
- use _scratch_xfs_{get,set}_sb_field
- also test mkfs on a non-aligned conventional device. This will fail without the mkfs patch just sent out.

#1 lore raw

PATCH 1/3 xfs: add a test that zoned file systems with rump RTG can't be mounted

Garbage collection assumes all zones contain the full amount of blocks. Mkfs already ensures this happens, but the kernel mount code did not verify this. Instead such a file system would eventually fail scrub.

Add a test to verify the new superblock verifier check.

---
 tests/xfs/651     | 33 +++++++++++++++++++++++++++++++++
 tests/xfs/651.out |  2 ++
 2 files changed, 35 insertions(+)
 create mode 100755 tests/xfs/651
 create mode 100644 tests/xfs/651.out
tests/xfs/651 new file +33 -0
new file mode 100755
index 000000000000..1e36fec408ff
@@ -0,0 +1,33 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Christoph Hellwig.
+#
+# FS QA Test No. 651
+#
+# Test that the sb verifier rejects zoned file system with rump RTGs.
+#
+. ./common/preamble
+_begin_fstest auto quick zone
+
+. ./common/zoned
+
+# we intentionally corrupt the superblock
+_require_scratch_nocheck
+
+_try_scratch_mkfs_xfs -r zoned=1 >> $seqres.full 2>&1 || \
+	_notrun "Can't create zoned file system"
+
+# adjust rblocks/rextents to not be zone aligned
+blocks=$(_scratch_xfs_get_sb_field rblocks)
+blocks=$((blocks - 4096))
+_scratch_xfs_set_sb_field rblocks ${blocks} >> $seqres.full 2>&1
+_scratch_xfs_set_sb_field rextents ${blocks} >> $seqres.full 2>&1
+
+if _try_scratch_mount >/dev/null 2>&1; then
+	echo "Mounted rump RTG file system (bad)"
+fi
+
+echo "Can't mount rump RTG file system (good)"
+
+status=0
+exit
tests/xfs/651.out new file +2 -0
new file mode 100644
index 000000000000..5d491b1894ea
@@ -0,0 +1,2 @@
+QA output created by 651
+Can't mount rump RTG file system (good)
Signature · 1 line
2.47.3
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] xfs: add a test that zoned file systems with rump RTG can't be mounted

Quoted 40 lines · Christoph Hellwig

Garbage collection assumes all zones contain the full amount of blocks. Mkfs already ensures this happens, but the kernel mount code did not verify this. Instead such a file system would eventually fail scrub.

Add a test to verify the new superblock verifier check.

---
 tests/xfs/651     | 33 +++++++++++++++++++++++++++++++++
 tests/xfs/651.out |  2 ++
 2 files changed, 35 insertions(+)
 create mode 100755 tests/xfs/651
 create mode 100644 tests/xfs/651.out
tests/xfs/651 new file +20 -0
new file mode 100755
index 000000000000..1e36fec408ff
@@ -0,0 +1,33 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Christoph Hellwig.
+#
+# FS QA Test No. 651
+#
+# Test that the sb verifier rejects zoned file system with rump RTGs.
+#
+. ./common/preamble
+_begin_fstest auto quick zone
+
+. ./common/zoned
+
+# we intentionally corrupt the superblock
+_require_scratch_nocheck
+
+_try_scratch_mkfs_xfs -r zoned=1 >> $seqres.full 2>&1 || \
+	_notrun "Can't create zoned file system"
+
+# adjust rblocks/rextents to not be zone aligned

tests/xfs/651 line 30

Quoted 10 lines
tests/xfs/651 new file +10 -0
+blocks=$(_scratch_xfs_get_sb_field rblocks)
+blocks=$((blocks - 4096))
+_scratch_xfs_set_sb_field rblocks ${blocks} >> $seqres.full 2>&1
+_scratch_xfs_set_sb_field rextents ${blocks} >> $seqres.full 2>&1
+
+if _try_scratch_mount >/dev/null 2>&1; then
+	echo "Mounted rump RTG file system (bad)"
+fi
+
+echo "Can't mount rump RTG file system (good)"

In theory this should be in an else clause, but as extra lines in the golden output is enough to fail the test, this code flow is correct.

--D

Quoted 15 lines
tests/xfs/651 new file +3 -0
+
+status=0
+exit
tests/xfs/651.out new file +2 -0
new file mode 100644
index 000000000000..5d491b1894ea
@@ -0,0 +1,2 @@
+QA output created by 651
+Can't mount rump RTG file system (good)
Signature · 1 line
2.47.3
#3 lore raw

Re: [PATCH 1/3] xfs: add a test that zoned file systems with rump RTG can't be mounted

Quoted 2 lines · Darrick J. Wong

In theory this should be in an else clause, but as extra lines in the golden output is enough to fail the test, this code flow is correct.

The else seems saner, I'll respin.

#4 lore raw

PATCH 2/3 xfs: test that RT growfs not aligned to zone size fails

In reply to Christoph Hellwig

Check that a file system with a zoned RT subvolume can't be resized to a size not aligned to the zone size.

Uses a zloop device so that we can control the exact zone size.

---
 tests/xfs/652     | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/652.out |  4 ++++
 2 files changed, 62 insertions(+)
 create mode 100755 tests/xfs/652
 create mode 100644 tests/xfs/652.out
tests/xfs/652 new file +58 -0
new file mode 100755
index 000000000000..91399be28df0
@@ -0,0 +1,58 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2025 Christoph Hellwig.
+#
+# FS QA Test No. 652
+#
+# Tests that xfs_growfs to a realtime volume size that is not zone aligned is
+# rejected.
+#
+. ./common/preamble
+_begin_fstest auto quick realtime growfs zone
+
+. ./common/filter
+. ./common/zoned
+
+_require_realtime
+_require_zloop
+_require_scratch
+_require_scratch_size $((16 * 1024 * 1024)) # 16GiB in kiB units
+
+_cleanup()
+{
+	if [ -n "$mnt" ]; then
+		_unmount $mnt 2>/dev/null
+	fi
+	_destroy_zloop $zloop
+	cd /
+	rm -r -f $tmp.*
+}
+
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+
+fsbsize=4096
+unaligned_size=$((((12 * 1024 * 1024 * 1024) + (fsbsize * 13)) / fsbsize))
+
+mnt="$SCRATCH_MNT/mnt"
+zloopdir="$SCRATCH_MNT/zloop"
+
+mkdir -p $mnt
+zloop=$(_create_zloop $zloopdir 256 2)
+
+echo "Format and mount zloop file system"
+_try_mkfs_dev -b size=4k -r size=10g $zloop >> $seqres.full 2>&1 ||\
+	_notrun "cannot mkfs zoned filesystem"
+_mount $zloop $mnt
+
+echo "Try to grow file system to a not zone aligned size"
+$XFS_GROWFS_PROG -R $unaligned_size $mnt >> $seqres.full 2>&1 && \
+	_fail "growfs to unaligned size succeeded"
+
+echo "Remount file system"
+umount $mnt
+_mount $zloop $mnt
+
+# success, all done
+status=0
+exit
tests/xfs/652.out new file +4 -0
new file mode 100644
index 000000000000..8de9ab41d47f
@@ -0,0 +1,4 @@
+QA output created by 652
+Format and mount zloop file system
+Try to grow file system to a not zone aligned size
+Remount file system
Signature · 1 line
2.47.3
#5 lore raw

PATCH 3/3 xfs: test that mkfs creates zone-aligned RT devices

In reply to Christoph Hellwig

Make sure mkfs doesn't create unmountable file systems and instead rounds down the RT subvolume size to a multiple of the zone size.

Two passes: one with a device that is not aligned, and one for an explicitly specified unaligned RT device size.

---
 tests/xfs/653     | 66 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/653.out |  3 +++
 2 files changed, 69 insertions(+)
 create mode 100755 tests/xfs/653
 create mode 100644 tests/xfs/653.out
tests/xfs/653 new file +66 -0
new file mode 100755
index 000000000000..12d606c436f0
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2025 Christoph Hellwig.
+#
+# FS QA Test No. 653
+#
+# Tests that mkfs for a zoned file system rounds realtime subvolume sizes up to
+# the zone size to create mountable file systems.
+#
+. ./common/preamble
+_begin_fstest auto quick realtime growfs zone
+
+. ./common/filter
+. ./common/zoned
+
+_cleanup()
+{
+	_unmount $LOOP_MNT 2>/dev/null
+	[ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
+	rm -rf $LOOP_IMG $LOOP_MNT
+	cd /
+	rm -f $tmp.*
+}
+
+_require_test
+_require_loop
+_require_xfs_io_command "truncate"
+
+fsbsize=4096
+aligned_size=$((3 * 1024 * 1024 * 1024))
+unaligned_size=$((2 * 1024 * 1024 * 1024 + fsbsize * 13))
+
+_require_fs_space $TEST_DIR $((aligned_size / 1024))
+
+LOOP_IMG=$TEST_DIR/$seq.dev
+LOOP_MNT=$TEST_DIR/$seq.mnt
+rm -rf $LOOP_IMG $LOOP_MNT
+mkdir -p $LOOP_MNT
+
+# try to create an unaligned RT volume by manually specifying the RT device size
+$XFS_IO_PROG -f -c "truncate ${aligned_size}" $LOOP_IMG
+loop_dev=$(_create_loop_device $LOOP_IMG)
+
+echo "Formatting file system (unaligned specified size)"
+_try_mkfs_dev -b size=4k -r zoned=1,size=$((unaligned_size / fsbsize))b $loop_dev \
+		>> $seqres.full 2>&1 ||\
+	_notrun "cannot mkfs zoned filesystem"
+_mount $loop_dev $LOOP_MNT
+umount $LOOP_MNT
+_destroy_loop_device $loop_dev
+rm -rf $LOOP_IMG
+
+# try to create an unaligned RT volume on on an oddly sized device
+$XFS_IO_PROG -f -c "truncate ${unaligned_size}" $LOOP_IMG
+loop_dev=$(_create_loop_device $LOOP_IMG)
+
+echo "Formatting file system (unaligned device)"
+_try_mkfs_dev -b size=4k -r zoned=1 $loop_dev \
+		>> $seqres.full 2>&1 ||\
+	_notrun "cannot mkfs zoned filesystem"
+_mount $loop_dev $LOOP_MNT
+umount $LOOP_MNT
+
+# success, all done
+status=0
+exit
tests/xfs/653.out new file +3 -0
new file mode 100644
index 000000000000..96158d93f55c
@@ -0,0 +1,3 @@
+QA output created by 653
+Formatting file system (unaligned specified size)
+Formatting file system (unaligned device)
Signature · 1 line
2.47.3
Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] xfs: test that mkfs creates zone-aligned RT devices

Quoted 7 lines · Christoph Hellwig

Make sure mkfs doesn't create unmountable file systems and instead rounds down the RT subvolume size to a multiple of the zone size.

Two passes: one with a device that is not aligned, and one for an explicitly specified unaligned RT device size.

Looks good to me,

--D

Quoted 92 lines
---
 tests/xfs/653     | 66 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/653.out |  3 +++
 2 files changed, 69 insertions(+)
 create mode 100755 tests/xfs/653
 create mode 100644 tests/xfs/653.out
tests/xfs/653 new file +66 -0
new file mode 100755
index 000000000000..12d606c436f0
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2025 Christoph Hellwig.
+#
+# FS QA Test No. 653
+#
+# Tests that mkfs for a zoned file system rounds realtime subvolume sizes up to
+# the zone size to create mountable file systems.
+#
+. ./common/preamble
+_begin_fstest auto quick realtime growfs zone
+
+. ./common/filter
+. ./common/zoned
+
+_cleanup()
+{
+	_unmount $LOOP_MNT 2>/dev/null
+	[ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
+	rm -rf $LOOP_IMG $LOOP_MNT
+	cd /
+	rm -f $tmp.*
+}
+
+_require_test
+_require_loop
+_require_xfs_io_command "truncate"
+
+fsbsize=4096
+aligned_size=$((3 * 1024 * 1024 * 1024))
+unaligned_size=$((2 * 1024 * 1024 * 1024 + fsbsize * 13))
+
+_require_fs_space $TEST_DIR $((aligned_size / 1024))
+
+LOOP_IMG=$TEST_DIR/$seq.dev
+LOOP_MNT=$TEST_DIR/$seq.mnt
+rm -rf $LOOP_IMG $LOOP_MNT
+mkdir -p $LOOP_MNT
+
+# try to create an unaligned RT volume by manually specifying the RT device size
+$XFS_IO_PROG -f -c "truncate ${aligned_size}" $LOOP_IMG
+loop_dev=$(_create_loop_device $LOOP_IMG)
+
+echo "Formatting file system (unaligned specified size)"
+_try_mkfs_dev -b size=4k -r zoned=1,size=$((unaligned_size / fsbsize))b $loop_dev \
+		>> $seqres.full 2>&1 ||\
+	_notrun "cannot mkfs zoned filesystem"
+_mount $loop_dev $LOOP_MNT
+umount $LOOP_MNT
+_destroy_loop_device $loop_dev
+rm -rf $LOOP_IMG
+
+# try to create an unaligned RT volume on on an oddly sized device
+$XFS_IO_PROG -f -c "truncate ${unaligned_size}" $LOOP_IMG
+loop_dev=$(_create_loop_device $LOOP_IMG)
+
+echo "Formatting file system (unaligned device)"
+_try_mkfs_dev -b size=4k -r zoned=1 $loop_dev \
+		>> $seqres.full 2>&1 ||\
+	_notrun "cannot mkfs zoned filesystem"
+_mount $loop_dev $LOOP_MNT
+umount $LOOP_MNT
+
+# success, all done
+status=0
+exit
tests/xfs/653.out new file +3 -0
new file mode 100644
index 000000000000..96158d93f55c
@@ -0,0 +1,3 @@
+QA output created by 653
+Formatting file system (unaligned specified size)
+Formatting file system (unaligned device)
Signature · 1 line
2.47.3