Skip to contentSkip to conversation

xfs: add a test for number of open zones on conventional devices

PATCH Superseded Christoph Hellwig 3 participants 8 messages Mar 31 – Apr 7

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xfs: add a test for number of open zones on conventional devices

Test that mounts of zoned file systems on conventional devices don't create more open zones than allowed when the last blocks in one or more zones have been invalidated.

---

- delete odd files
- fix the sysfs attr check to be on the scratch and not the test fs

 tests/xfs/4201     | 66 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4201.out |  1 +
 2 files changed, 67 insertions(+)
 create mode 100755 tests/xfs/4201
 create mode 100644 tests/xfs/4201.out
tests/xfs/4201 new file +66 -0
new file mode 100755
index 000000000000..150978a9deda
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Christoph Hellwig.
+#
+# FS QA Test No. 4201
+#
+# Test that mounts of zoned file systems on conventional devices don't create
+# more open zones than allowed when the last blocks in one or more zones have
+# been invalidated.
+#
+
+. ./common/preamble
+_begin_fstest auto quick zone
+
+_require_scratch
+_require_odirect
+_require_non_zoned_device $SCRATCH_DEV
+_require_non_zoned_device $SCRATCH_RTDEV
+
+open_zones=5
+blocks=65536
+bsize=4096
+
+zone_size_mib=$((blocks * bsize / 1024 / 1024))
+file_size_mib=$((zone_size_mib / 2))
+nr_files=$((open_zones * 3 - 1))
+
+echo "zone size: $zone_size_mib" >>$seqres.full
+echo "file size: $file_size_mib" >>$seqres.full
+echo "nr files: $nr_files" >>$seqres.full
+
+_scratch_mkfs -b size=${bsize} -r zoned=1,rgsize=${blocks}b \
+	> "$seqres.full" 2>&1
+_scratch_mount -o max_open_zones=${open_zones}
+
+_has_fs_sysfs_attr $SCRATCH_DEV zoned/nr_open_zones || \
+	_notrun "This test requires /sys/fs/${FSTYP}/$SCRATCH_DEV/zoned/nr_open_zones"
+
+for i in $(seq 1 $nr_files); do
+	dd if=/dev/zero of=$SCRATCH_MNT/$i bs=1M count=$file_size_mib \
+		 oflag=direct > /dev/null 2>&1
+done
+
+# delete odd numbered files as they should be at the end of the zones
+for ((i = 0; i < $nr_files; i = $((i + 2)))); do
+	rm $SCRATCH_MNT/$((i + 1))
+done
+
+_scratch_unmount
+_scratch_mount -o max_open_zones=${open_zones}
+
+max_open=$(_get_fs_sysfs_attr $SCRATCH_DEV zoned/max_open_zones)
+nr_open=$(_get_fs_sysfs_attr $SCRATCH_DEV zoned/nr_open_zones)
+
+if [ ${max_open} -ne $((open_zones - 1)) ]; then
+	_fail "Test needs adjustments for multiple open GC zones"
+fi
+
+if [ ${nr_open} -gt ${max_open} ]; then
+	_fail "Too many open zones: $nr_open/$max_open"
+fi
+
+_scratch_unmount
+
+status=0
+exit
tests/xfs/4201.out new file +1 -0
new file mode 100644
index 000000000000..32e395dd4d6d
@@ -0,0 +1 @@
+QA output created by 4201
Signature · 1 line
2.47.3
#2 lore raw
In reply to Christoph Hellwig
Quoted 45 lines · Christoph Hellwig

Test that mounts of zoned file systems on conventional devices don't create more open zones than allowed when the last blocks in one or more zones have been invalidated.

---

- delete odd files
- fix the sysfs attr check to be on the scratch and not the test fs

 tests/xfs/4201     | 66 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4201.out |  1 +
 2 files changed, 67 insertions(+)
 create mode 100755 tests/xfs/4201
 create mode 100644 tests/xfs/4201.out
tests/xfs/4201 new file +23 -0
new file mode 100755
index 000000000000..150978a9deda
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Christoph Hellwig.
+#
+# FS QA Test No. 4201
+#
+# Test that mounts of zoned file systems on conventional devices don't create
+# more open zones than allowed when the last blocks in one or more zones have
+# been invalidated.
+#
+
+. ./common/preamble
+_begin_fstest auto quick zone
+
+_require_scratch
+_require_odirect
+_require_non_zoned_device $SCRATCH_DEV
+_require_non_zoned_device $SCRATCH_RTDEV
+
+open_zones=5
+blocks=65536
+bsize=4096
+

tests/xfs/4201 line 33

Quoted 10 lines
tests/xfs/4201 new file +10 -0
+zone_size_mib=$((blocks * bsize / 1024 / 1024))
+file_size_mib=$((zone_size_mib / 2))
+nr_files=$((open_zones * 3 - 1))
+
+echo "zone size: $zone_size_mib" >>$seqres.full
+echo "file size: $file_size_mib" >>$seqres.full
+echo "nr files: $nr_files" >>$seqres.full
+
+_scratch_mkfs -b size=${bsize} -r zoned=1,rgsize=${blocks}b \
+	> "$seqres.full" 2>&1

I usually tack on "|| _fail 'mkfs failed'" after _scratch_mount if it's using extra options. That way, we'll know for sure if the mkfs actually failed.

tests/xfs/4201 line 37

Quoted 4 lines
tests/xfs/4201 new file +4 -0
+_scratch_mount -o max_open_zones=${open_zones}
+
+_has_fs_sysfs_attr $SCRATCH_DEV zoned/nr_open_zones || \
+	_notrun "This test requires /sys/fs/${FSTYP}/$SCRATCH_DEV/zoned/nr_open_zones"

Can this be replaced with "_require_fs_sysfs_attr" ? _require_fs_sysfs_attr also can help to get the real path to the sysfs directory for the fs on a device.

Thanks,
Zorro

Quoted 16 lines
tests/xfs/4201 new file +16 -0
+
+for i in $(seq 1 $nr_files); do
+	dd if=/dev/zero of=$SCRATCH_MNT/$i bs=1M count=$file_size_mib \
+		 oflag=direct > /dev/null 2>&1
+done
+
+# delete odd numbered files as they should be at the end of the zones
+for ((i = 0; i < $nr_files; i = $((i + 2)))); do
+	rm $SCRATCH_MNT/$((i + 1))
+done
+
+_scratch_unmount
+_scratch_mount -o max_open_zones=${open_zones}
+
+max_open=$(_get_fs_sysfs_attr $SCRATCH_DEV zoned/max_open_zones)
+nr_open=$(_get_fs_sysfs_attr $SCRATCH_DEV zoned/nr_open_zones)

tests/xfs/4201 line 63

Quoted 10 lines
tests/xfs/4201 new file +10 -0
+
+if [ ${max_open} -ne $((open_zones - 1)) ]; then
+	_fail "Test needs adjustments for multiple open GC zones"
+fi
+
+if [ ${nr_open} -gt ${max_open} ]; then
+	_fail "Too many open zones: $nr_open/$max_open"
+fi
+
+_scratch_unmount

Is this line part of the test?

Thanks,
Zorro

Quoted 14 lines
tests/xfs/4201 new file +3 -0
+
+status=0
+exit
tests/xfs/4201.out new file +1 -0
new file mode 100644
index 000000000000..32e395dd4d6d
@@ -0,0 +1 @@
+QA output created by 4201
Signature · 1 line
2.47.3
#3 lore raw
Quoted 7 lines · Zorro Lang

tests/xfs/4201 line 33

Quoted 3 lines
tests/xfs/4201 new file +3 -0
+
+_scratch_mkfs -b size=${bsize} -r zoned=1,rgsize=${blocks}b \
+	> "$seqres.full" 2>&1

I usually tack on "|| _fail 'mkfs failed'" after _scratch_mount if it's using extra options. That way, we'll know for sure if the mkfs actually failed.

Yes, that is useful here, especially if we want to support older kernels before the zoned device support or !CONFIG_XFS_RT kernels.

Quoted 5 lines

tests/xfs/4201 line 37

Quoted 2 lines
tests/xfs/4201 new file +2 -0
+_has_fs_sysfs_attr $SCRATCH_DEV zoned/nr_open_zones || \
+	_notrun "This test requires /sys/fs/${FSTYP}/$SCRATCH_DEV/zoned/nr_open_zones"

Can this be replaced with "_require_fs_sysfs_attr" ? _require_fs_sysfs_attr also can help to get the real path to the sysfs directory for the fs on a device.

No, this must happen on the scratch file system where we force the zoned allocator, as the attribute only exists for those.

#4 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 7 lines · Zorro Lang

tests/xfs/4201 line 33

Quoted 3 lines
tests/xfs/4201 new file +3 -0
+
+_scratch_mkfs -b size=${bsize} -r zoned=1,rgsize=${blocks}b \
+	> "$seqres.full" 2>&1

I usually tack on "|| _fail 'mkfs failed'" after _scratch_mount if it's using extra options. That way, we'll know for sure if the mkfs actually failed.

Yes, that is useful here, especially if we want to support older kernels before the zoned device support or !CONFIG_XFS_RT kernels.

Oh, if so, we might need _require_realtime. But that's still not enough to check mkfs.xfs and mount.xfs on old system (then notrun), we might need more _require_* helpers for this test. What do you think?

Thanks,
Zorro

Quoted 10 lines
Quoted 6 lines

tests/xfs/4201 line 37

Quoted 3 lines
tests/xfs/4201 new file +2 -0
+_has_fs_sysfs_attr $SCRATCH_DEV zoned/nr_open_zones || \
+	_notrun "This test requires /sys/fs/${FSTYP}/$SCRATCH_DEV/zoned/nr_open_zones"

Can this be replaced with "_require_fs_sysfs_attr" ? _require_fs_sysfs_attr also can help to get the real path to the sysfs directory for the fs on a device.

No, this must happen on the scratch file system where we force the zoned allocator, as the attribute only exists for those.

#5 lore raw
Quoted 7 lines · Zorro Lang
Quoted 7 lines
Quoted 6 lines

tests/xfs/4201 line 33

Quoted 2 lines
tests/xfs/4201 new file +2 -0
+_scratch_mkfs -b size=${bsize} -r zoned=1,rgsize=${blocks}b \
+	> "$seqres.full" 2>&1

I usually tack on "|| _fail 'mkfs failed'" after _scratch_mount if it's using extra options. That way, we'll know for sure if the mkfs actually failed.

Quoted 6 lines
Quoted 2 lines

Yes, that is useful here, especially if we want to support older kernels before the zoned device support or !CONFIG_XFS_RT kernels.

Oh, if so, we might need _require_realtime. But that's still not enough to check mkfs.xfs and mount.xfs on old system (then notrun), we might need more _require_* helpers for this test. What do you think?

I think _notrun if mkfs or the initial mount fails might be easier and better here.

#6 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Zorro Lang
Quoted 9 lines
Quoted 6 lines

tests/xfs/4201 line 33

Quoted 2 lines
tests/xfs/4201 new file +2 -0
+_scratch_mkfs -b size=${bsize} -r zoned=1,rgsize=${blocks}b \
+	> "$seqres.full" 2>&1

I usually tack on "|| _fail 'mkfs failed'" after _scratch_mount if it's using extra options. That way, we'll know for sure if the mkfs actually failed.

Yes, that is useful here, especially if we want to support older kernels before the zoned device support or !CONFIG_XFS_RT kernels.

Quoted 7 lines
Quoted 3 lines

Oh, if so, we might need _require_realtime. But that's still not enough to check mkfs.xfs and mount.xfs on old system (then notrun), we might need more _require_* helpers for this test. What do you think?

I think _notrun if mkfs or the initial mount fails might be easier and better here.

How about a _require_xfs_mkfs_zoned ?

And about _scratch_mount -o max_open_zones=${open_zones}, if max_open_zones mount option isn't supported, _scratch_mount will fail directly. So how about

  _try_scratch_mount -o max_open_zones=${open_zones} || \
          _notrun "max_open_zones option is not supported"

Or we can have a helper for that, as xfs/642~644 and xfs/668 also need that.

Thanks,
Zorro

Quoted 1 line
#7 lore raw
Quoted 6 lines · Zorro Lang
Quoted 3 lines

I think _notrun if mkfs or the initial mount fails might be easier and better here.

How about a _require_xfs_mkfs_zoned ?

Quoted 7 lines

And about _scratch_mount -o max_open_zones=${open_zones}, if max_open_zones mount option isn't supported, _scratch_mount will fail directly. So how about

  _try_scratch_mount -o max_open_zones=${open_zones} || \
          _notrun "max_open_zones option is not supported"

Or we can have a helper for that, as xfs/642~644 and xfs/668 also need that.

I'll take a look. max_open_zones is always supported for zoned xfs file systems - the notrun is intended to cover the case where the kernel can't mount zoned file systems - either because it is too old, or because XFS_RT is not enabled.