public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] xfs: add a test for number of open zones on conventional devices
@ 2026-04-14  7:55 Christoph Hellwig
  2026-04-14 18:59 ` Darrick J. Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2026-04-14  7:55 UTC (permalink / raw)
  To: zlang; +Cc: djwong, dlemoal, hans.holmberg, fstests, linux-xfs

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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---

Changes since v2:
 - use raw mkfs to avoid injecting a real RT device
 - _notrun with a useful message when the mkfs or mount fails due to lack
   of RT device or zoned block device support

 tests/xfs/4201     | 69 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4201.out |  1 +
 2 files changed, 70 insertions(+)
 create mode 100755 tests/xfs/4201
 create mode 100644 tests/xfs/4201.out

diff --git a/tests/xfs/4201 b/tests/xfs/4201
new file mode 100755
index 000000000000..56084bca41c0
--- /dev/null
+++ b/tests/xfs/4201
@@ -0,0 +1,69 @@
+#! /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_nocheck
+_require_odirect
+_require_non_zoned_device $SCRATCH_DEV
+_require_non_zoned_device $SCRATCH_RTDEV
+
+open_zones=5
+blocks=16384
+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
+
+# don't use _scratch_mkfs/_scratch_mount to avoid injection a real RT device
+$MKFS_XFS_PROG -b size=${bsize} -r zoned=1,rgsize=${blocks}b \
+	$SCRATCH_DEV > "$seqres.full" 2>&1 || \
+		_notrun "Zoned mkfs not supported"
+_mount $SCRATCH_DEV $SCRATCH_MNT -o max_open_zones=${open_zones} || \
+	_notrun "Zoned allocator not supported"
+
+_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
+_mount $SCRATCH_DEV $SCRATCH_MNT -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
diff --git a/tests/xfs/4201.out b/tests/xfs/4201.out
new file mode 100644
index 000000000000..32e395dd4d6d
--- /dev/null
+++ b/tests/xfs/4201.out
@@ -0,0 +1 @@
+QA output created by 4201
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] xfs: add a test for number of open zones on conventional devices
  2026-04-14  7:55 [PATCH v3] xfs: add a test for number of open zones on conventional devices Christoph Hellwig
@ 2026-04-14 18:59 ` Darrick J. Wong
  2026-04-15  5:22   ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2026-04-14 18:59 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: zlang, dlemoal, hans.holmberg, fstests, linux-xfs

On Tue, Apr 14, 2026 at 09:55:47AM +0200, Christoph Hellwig wrote:
> 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.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 
> Changes since v2:
>  - use raw mkfs to avoid injecting a real RT device
>  - _notrun with a useful message when the mkfs or mount fails due to lack
>    of RT device or zoned block device support
> 
>  tests/xfs/4201     | 69 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/4201.out |  1 +
>  2 files changed, 70 insertions(+)
>  create mode 100755 tests/xfs/4201
>  create mode 100644 tests/xfs/4201.out
> 
> diff --git a/tests/xfs/4201 b/tests/xfs/4201
> new file mode 100755
> index 000000000000..56084bca41c0
> --- /dev/null
> +++ b/tests/xfs/4201
> @@ -0,0 +1,69 @@
> +#! /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_nocheck
> +_require_odirect
> +_require_non_zoned_device $SCRATCH_DEV
> +_require_non_zoned_device $SCRATCH_RTDEV

Seems fine to me still, though I wonder if you still need to check
SCRATCH_RTDEV if you're opencoding the mkfs/mount calls?

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> +
> +open_zones=5
> +blocks=16384
> +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
> +
> +# don't use _scratch_mkfs/_scratch_mount to avoid injection a real RT device
> +$MKFS_XFS_PROG -b size=${bsize} -r zoned=1,rgsize=${blocks}b \
> +	$SCRATCH_DEV > "$seqres.full" 2>&1 || \
> +		_notrun "Zoned mkfs not supported"
> +_mount $SCRATCH_DEV $SCRATCH_MNT -o max_open_zones=${open_zones} || \
> +	_notrun "Zoned allocator not supported"
> +
> +_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
> +_mount $SCRATCH_DEV $SCRATCH_MNT -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
> diff --git a/tests/xfs/4201.out b/tests/xfs/4201.out
> new file mode 100644
> index 000000000000..32e395dd4d6d
> --- /dev/null
> +++ b/tests/xfs/4201.out
> @@ -0,0 +1 @@
> +QA output created by 4201
> -- 
> 2.53.0
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] xfs: add a test for number of open zones on conventional devices
  2026-04-14 18:59 ` Darrick J. Wong
@ 2026-04-15  5:22   ` Christoph Hellwig
  2026-04-16 16:54     ` Zorro Lang
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2026-04-15  5:22 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Christoph Hellwig, zlang, dlemoal, hans.holmberg, fstests,
	linux-xfs

On Tue, Apr 14, 2026 at 11:59:14AM -0700, Darrick J. Wong wrote:
> > +_require_scratch_nocheck
> > +_require_odirect
> > +_require_non_zoned_device $SCRATCH_DEV
> > +_require_non_zoned_device $SCRATCH_RTDEV
> 
> Seems fine to me still, though I wonder if you still need to check
> SCRATCH_RTDEV if you're opencoding the mkfs/mount calls?

This can be dropped now, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] xfs: add a test for number of open zones on conventional devices
  2026-04-15  5:22   ` Christoph Hellwig
@ 2026-04-16 16:54     ` Zorro Lang
  0 siblings, 0 replies; 4+ messages in thread
From: Zorro Lang @ 2026-04-16 16:54 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Darrick J. Wong, dlemoal, hans.holmberg, fstests, linux-xfs

On Wed, Apr 15, 2026 at 07:22:39AM +0200, Christoph Hellwig wrote:
> On Tue, Apr 14, 2026 at 11:59:14AM -0700, Darrick J. Wong wrote:
> > > +_require_scratch_nocheck
> > > +_require_odirect
> > > +_require_non_zoned_device $SCRATCH_DEV
> > > +_require_non_zoned_device $SCRATCH_RTDEV
> > 
> > Seems fine to me still, though I wonder if you still need to check
> > SCRATCH_RTDEV if you're opencoding the mkfs/mount calls?
> 
> This can be dropped now, thanks!

Will remove it when I merge it. Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-16 16:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14  7:55 [PATCH v3] xfs: add a test for number of open zones on conventional devices Christoph Hellwig
2026-04-14 18:59 ` Darrick J. Wong
2026-04-15  5:22   ` Christoph Hellwig
2026-04-16 16:54     ` Zorro Lang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox