various tests for zone aligned RT subvolumes
Hi all,
this adds a few tests to make sure zoned RT subvolumes are always aligned to the zone size.
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 | 30 ++++++++++++++++++++++++++++++ tests/xfs/651.out | 2 ++ 2 files changed, 32 insertions(+) create mode 100755 tests/xfs/651 create mode 100644 tests/xfs/651.out
tests/xfs/651 new file +30 -0
@@ -0,0 +1,30 @@ +#! /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 + +_require_scratch_nocheck + +_scratch_mkfs > /dev/null 2>&1 +blocks=$(_scratch_xfs_db -c 'sb 0' -c 'print rblocks' | awk '{print $3}') +blocks=$((blocks - 4096)) +_scratch_xfs_db -x -c 'sb 0' -c "write -d rblocks $blocks" > /dev/null 2>&1 +_scratch_xfs_db -x -c 'sb 0' -c "write -d rextents $blocks" > /dev/null 2>&1 + +if _try_scratch_mount >/dev/null 2>&1; then + # for non-zoned file systems this can succeed just fine + _require_xfs_scratch_non_zoned +fi + +echo "Can't mount rump RTG file system (good)" + +status=0 +exit
tests/xfs/651.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 651 +Can't mount rump RTG file system (good)
Signature · 1 line
2.47.3
Re: [PATCH 1/3] xfs: add a test that zoned file systems with rump RTG can't be mounted
Quoted 30 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.
Signed-off-by Christoph Hellwig <[email protected]>--- tests/xfs/651 | 30 ++++++++++++++++++++++++++++++ tests/xfs/651.out | 2 ++ 2 files changed, 32 insertions(+) create mode 100755 tests/xfs/651 create mode 100644 tests/xfs/651.outtests/xfs/651 new file +10
-0@@ -0,0 +1,30 @@ +#! /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
tests/xfs/651 line 20
Quoted 10 lines
tests/xfs/651 new file +10
-0+ +. ./common/zoned + +_require_scratch_nocheck + +_scratch_mkfs > /dev/null 2>&1 +blocks=$(_scratch_xfs_db -c 'sb 0' -c 'print rblocks' | awk '{print $3}') +blocks=$((blocks - 4096)) +_scratch_xfs_db -x -c 'sb 0' -c "write -d rblocks $blocks" > /dev/null 2>&1 +_scratch_xfs_db -x -c 'sb 0' -c "write -d rextents $blocks" > /dev/null 2>&1
You could put both of the write commands in the same invocation, e.g.
_scratch_xfs_db -x \ -c 'sb 0' \ -c "write -d rblocks $blocks" \ -c "write -d rextents $blocks" > /dev/null 2>&1
For a little bit lower runtime.
tests/xfs/651 line 24
Quoted 4 lines
tests/xfs/651 new file +4
-0+ +if _try_scratch_mount >/dev/null 2>&1; then + # for non-zoned file systems this can succeed just fine + _require_xfs_scratch_non_zoned
The logic in this test looks fine to me, but I wonder: have you (or anyone else) gone to Debian 13 and noticed this:
# mount /dev/sda /mnt # mount /dev/sda /mnt # grep /mnt /proc/mounts /dev/sda /mnt xfs rw,relatime,inode64,logbufs=8,logbsize=32k,noquota 0 0 /dev/sda /mnt xfs rw,relatime,inode64,logbufs=8,logbsize=32k,noquota 0 0
It looks like util-linux switched to the new fsopen mount API between Debian 12 and 13, and whereas the old mount(8) would fail if the fs was already mounted, the new one just creates two mounts, which both then must be unmounted. So now I'm hunting around for unbalanced mount/unmount pairs in fstests. :(
Anyhow the test looks fine, so
--D
Quoted 18 lines
tests/xfs/651 new file +6
-0+fi + +echo "Can't mount rump RTG file system (good)" + +status=0 +exittests/xfs/651.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 651 +Can't mount rump RTG file system (good)Signature · 1 line
2.47.3
Re: [PATCH 1/3] xfs: add a test that zoned file systems with rump RTG can't be mounted
Quoted 8 lines · Darrick J. Wong
tests/xfs/651 line 20
Quoted 5 lines
tests/xfs/651 new file +5
-0+_scratch_mkfs > /dev/null 2>&1 +blocks=$(_scratch_xfs_db -c 'sb 0' -c 'print rblocks' | awk '{print $3}') +blocks=$((blocks - 4096)) +_scratch_xfs_db -x -c 'sb 0' -c "write -d rblocks $blocks" > /dev/null 2>&1 +_scratch_xfs_db -x -c 'sb 0' -c "write -d rextents $blocks" > /dev/null 2>&1You could put both of the write commands in the same invocation, e.g.
Quoted 6 lines
_scratch_xfs_db -x \ -c 'sb 0' \ -c "write -d rblocks $blocks" \ -c "write -d rextents $blocks" > /dev/null 2>&1For a little bit lower runtime.
I can do that, but I doubt it really matters..
Quoted 13 lines
tests/xfs/651 line 24
Quoted 3 lines
tests/xfs/651 new file +3
-0+if _try_scratch_mount >/dev/null 2>&1; then + # for non-zoned file systems this can succeed just fine + _require_xfs_scratch_non_zonedThe logic in this test looks fine to me, but I wonder: have you (or anyone else) gone to Debian 13 and noticed this:
# mount /dev/sda /mnt # mount /dev/sda /mnt # grep /mnt /proc/mounts /dev/sda /mnt xfs rw,relatime,inode64,logbufs=8,logbsize=32k,noquota 0 0 /dev/sda /mnt xfs rw,relatime,inode64,logbufs=8,logbsize=32k,noquota 0 0
Quoted 5 lines
It looks like util-linux switched to the new fsopen mount API between Debian 12 and 13, and whereas the old mount(8) would fail if the fs was already mounted, the new one just creates two mounts, which both then must be unmounted. So now I'm hunting around for unbalanced mount/unmount pairs in fstests. :(
The old mount API also supported that at the syscall level, but it got disable in mount(8), so if mount now does this and previously didn't it seems like an unintended change.
Re: [PATCH 1/3] xfs: add a test that zoned file systems with rump RTG can't be mounted
Quoted 37 lines · Christoph Hellwig
Quoted 8 lines · Darrick J. Wong
tests/xfs/651 line 20
Quoted 5 lines
tests/xfs/651 new file +5
-0+_scratch_mkfs > /dev/null 2>&1 +blocks=$(_scratch_xfs_db -c 'sb 0' -c 'print rblocks' | awk '{print $3}') +blocks=$((blocks - 4096)) +_scratch_xfs_db -x -c 'sb 0' -c "write -d rblocks $blocks" > /dev/null 2>&1 +_scratch_xfs_db -x -c 'sb 0' -c "write -d rextents $blocks" > /dev/null 2>&1You could put both of the write commands in the same invocation, e.g.
Quoted 6 lines
_scratch_xfs_db -x \ -c 'sb 0' \ -c "write -d rblocks $blocks" \ -c "write -d rextents $blocks" > /dev/null 2>&1For a little bit lower runtime.
I can do that, but I doubt it really matters..
Quoted 13 lines
tests/xfs/651 line 24
Quoted 3 lines
tests/xfs/651 new file +3
-0+if _try_scratch_mount >/dev/null 2>&1; then + # for non-zoned file systems this can succeed just fine + _require_xfs_scratch_non_zonedThe logic in this test looks fine to me, but I wonder: have you (or anyone else) gone to Debian 13 and noticed this:
# mount /dev/sda /mnt # mount /dev/sda /mnt # grep /mnt /proc/mounts /dev/sda /mnt xfs rw,relatime,inode64,logbufs=8,logbsize=32k,noquota 0 0 /dev/sda /mnt xfs rw,relatime,inode64,logbufs=8,logbsize=32k,noquota 0 0Quoted 5 lines
It looks like util-linux switched to the new fsopen mount API between Debian 12 and 13, and whereas the old mount(8) would fail if the fs was already mounted, the new one just creates two mounts, which both then must be unmounted. So now I'm hunting around for unbalanced mount/unmount pairs in fstests. :(
Quoted 3 lines
The old mount API also supported that at the syscall level, but it got disable in mount(8), so if mount now does this and previously didn't it seems like an unintended change.
Oh, it's very much an intentional change. Someone complained and the maintainer declined to revert:
https://github.com/util-linux/util-linux/issues/3800
because we can all just add --onlyonce to our scripts if we want the old behavior. Or set LIBMOUNT_FORCE_MOUNT2=always and hope that doesn't go away.
--D
PATCH 2/3 xfs: test that RT growfs not aligned to zone size fails
In reply to Christoph HellwigCheck 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
@@ -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
@@ -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
Re: [PATCH 2/3] xfs: test that RT growfs not aligned to zone size fails
Quoted 6 lines · 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.
Signed-off-by Christoph Hellwig <[email protected]>
It seems to me that this test is creating a 10G zoned volume with a zone size of 256M, and then growfs'ing to (12G + 52K) which is supposed to fail, correct?
If so, then
--D
Quoted 85 lines
--- 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.outtests/xfs/652 new file +58
-0@@ -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 +exittests/xfs/652.out new file +4
-0@@ -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 systemSignature · 1 line
2.47.3
Re: [PATCH 2/3] xfs: test that RT growfs not aligned to zone size fails
Quoted 11 lines · Darrick J. Wong
Quoted 6 lines · 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.
Signed-off-by Christoph Hellwig <[email protected]>It seems to me that this test is creating a 10G zoned volume with a zone size of 256M, and then growfs'ing to (12G + 52K) which is supposed to fail, correct?
Yes. Any way to make this more clear?
PATCH 3/3 xfs: add a test that mkfs round up realtime subvolume sizes to the zone size
In reply to Christoph HellwigMake sure mkfs doesn't create unmountable file systems.
--- tests/xfs/653 | 33 +++++++++++++++++++++++++++++++++ tests/xfs/653.out | 2 ++ 2 files changed, 35 insertions(+) create mode 100755 tests/xfs/653 create mode 100644 tests/xfs/653.out
tests/xfs/653 new file +33 -0
@@ -0,0 +1,33 @@ +#! /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 + +_require_realtime +_require_scratch +_require_scratch_size $((2 * 1024 * 1024)) # 1GiB in kiB units + +fsbsize=4096 +unaligned_size=$((((1 * 1024 * 1024 * 1024) + (fsbsize * 13)) / fsbsize)) + +# Manual mkfs and mount to not inject an existing RT device +echo "Try to format file system" +_try_mkfs_dev -b size=4k -r zoned=1,size=${unaligned_size}b $SCRATCH_DEV \ + >> $seqres.full 2>&1 ||\ + _notrun "cannot mkfs zoned filesystem" +_mount $SCRATCH_DEV $SCRATCH_MNT +umount $SCRATCH_MNT + +# success, all done +status=0 +exit
tests/xfs/653.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 653 +Try to format file system
Signature · 1 line
2.47.3
Re: [PATCH 3/3] xfs: add a test that mkfs round up realtime subvolume sizes to the zone size
Quoted 16 lines · Christoph Hellwig
Make sure mkfs doesn't create unmountable file systems.
Signed-off-by Christoph Hellwig <[email protected]>--- tests/xfs/653 | 33 +++++++++++++++++++++++++++++++++ tests/xfs/653.out | 2 ++ 2 files changed, 35 insertions(+) create mode 100755 tests/xfs/653 create mode 100644 tests/xfs/653.outtests/xfs/653 new file +0
-0
tests/xfs/653 line 8
Quoted 8 lines
tests/xfs/653 new file +8
-0@@ -0,0 +1,33 @@ +#! /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.
What size rt volume does this create? It looks like you're specifying an rt zone size of ... (1GB + 52K)? And testing that mkfs rounds the rt volume size down to some multiple of that? Or is it rounding the *zone* size down to 1G?
<confused>
--D
Quoted 36 lines
tests/xfs/653 new file +24
-0+. ./common/preamble +_begin_fstest auto quick realtime growfs zone + +. ./common/filter +. ./common/zoned + +_require_realtime +_require_scratch +_require_scratch_size $((2 * 1024 * 1024)) # 1GiB in kiB units + +fsbsize=4096 +unaligned_size=$((((1 * 1024 * 1024 * 1024) + (fsbsize * 13)) / fsbsize)) + +# Manual mkfs and mount to not inject an existing RT device +echo "Try to format file system" +_try_mkfs_dev -b size=4k -r zoned=1,size=${unaligned_size}b $SCRATCH_DEV \ + >> $seqres.full 2>&1 ||\ + _notrun "cannot mkfs zoned filesystem" +_mount $SCRATCH_DEV $SCRATCH_MNT +umount $SCRATCH_MNT + +# success, all done +status=0 +exittests/xfs/653.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 653 +Try to format file systemSignature · 1 line
2.47.3
Re: [PATCH 3/3] xfs: add a test that mkfs round up realtime subvolume sizes to the zone size
Quoted 4 lines · Darrick J. Wong
Quoted 1 line
+# the zone size to create mountable file systems.
What size rt volume does this create? It looks like you're specifying an rt zone size of ... (1GB + 52K)?
Yes.
Quoted 3 lines
And testing that mkfs rounds the
rt volume size down to some multiple of that? Or is it rounding the *zone* size down to 1G?
That's it is rounding the RT device sizse down to a multiple of the zone size, for which we default to 256MiB if not specified.