xfs: add a test for number of open zones on conventional devices
PATCH 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.
--- tests/xfs/4201 | 65 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/4201.out | 1 + 2 files changed, 66 insertions(+) create mode 100755 tests/xfs/4201 create mode 100644 tests/xfs/4201.out
tests/xfs/4201 new file +65 -0
@@ -0,0 +1,65 @@ +#! /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} + +_require_fs_sysfs 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 + +rm $SCRATCH_MNT/4 +rm $SCRATCH_MNT/5 +rm $SCRATCH_MNT/6 +rm $SCRATCH_MNT/7 + +_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
@@ -0,0 +1 @@ +QA output created by 4201
Signature · 1 line
2.47.3
Quoted 54 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.
Signed-off-by Christoph Hellwig <[email protected]>--- tests/xfs/4201 | 65 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/4201.out | 1 + 2 files changed, 66 insertions(+) create mode 100755 tests/xfs/4201 create mode 100644 tests/xfs/4201.outtests/xfs/4201 new file +36
-0@@ -0,0 +1,65 @@ +#! /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} + +_require_fs_sysfs zoned/nr_open_zones
tests/xfs/4201 line 46
Quoted 10 lines
tests/xfs/4201 new file +10
-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 + +rm $SCRATCH_MNT/4 +rm $SCRATCH_MNT/5 +rm $SCRATCH_MNT/6 +rm $SCRATCH_MNT/7
Hmmm. I think you should delete odd numbered files only since they are going to be written at the end of a zone. Otherwise, you make the zone empty, and it will thus not be considered as open.
Something like:
for (( i=0; i<$nr_files; i=$(( i + 2 )) )); do
rm $SCRATCH_MNT/$(( i + 1))
done
should generate enough open zones.
Quoted 26 lines
tests/xfs/4201 new file +19
-0+ +_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 +exittests/xfs/4201.out new file +1
-0@@ -0,0 +1 @@ +QA output created by 4201
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 3 lines · Damien Le Moal
Hmmm. I think you should delete odd numbered files only since they are going to be written at the end of a zone. Otherwise, you make the zone empty, and it will thus not be considered as open.
Yes, but due to the unevent number I did reproduce the bug even with this version. I tried your loop and this overshoots the open zone limit even more without the fix, so I'll switch to that.