* [PATCH v2 1/4] btrfs-progs: tests: output error/warn message to stderr
2025-09-10 5:04 [PATCH v2 0/4] btrfs-progs: tests: add new mkfs test for zoned device Naohiro Aota
@ 2025-09-10 5:04 ` Naohiro Aota
2025-09-10 5:22 ` Qu Wenruo
2025-09-10 5:04 ` [PATCH v2 2/4] btrfs-progs: tests: check nullb index for the error case Naohiro Aota
` (3 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Naohiro Aota @ 2025-09-10 5:04 UTC (permalink / raw)
To: linux-btrfs; +Cc: Naohiro Aota
Outputting these messages to stdout can compromise the functions' output.
Instead, output them to stderr to keep the results clean.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
tests/nullb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/nullb b/tests/nullb
index 457ae0d8354a..f3cdf9c19e16 100755
--- a/tests/nullb
+++ b/tests/nullb
@@ -34,12 +34,12 @@ SYSFS='/sys/kernel/config/nullb'
# setup
function _error() {
- echo "ERROR: $@"
+ echo "ERROR: $@" 1>&2
exit 1
}
function _warn() {
- echo "WARNING: $@"
+ echo "WARNING: $@" 1>&2
}
function _msg() {
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 1/4] btrfs-progs: tests: output error/warn message to stderr
2025-09-10 5:04 ` [PATCH v2 1/4] btrfs-progs: tests: output error/warn message to stderr Naohiro Aota
@ 2025-09-10 5:22 ` Qu Wenruo
0 siblings, 0 replies; 9+ messages in thread
From: Qu Wenruo @ 2025-09-10 5:22 UTC (permalink / raw)
To: Naohiro Aota, linux-btrfs
在 2025/9/10 14:34, Naohiro Aota 写道:
> Outputting these messages to stdout can compromise the functions' output.
> Instead, output them to stderr to keep the results clean.
>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> tests/nullb | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/nullb b/tests/nullb
> index 457ae0d8354a..f3cdf9c19e16 100755
> --- a/tests/nullb
> +++ b/tests/nullb
> @@ -34,12 +34,12 @@ SYSFS='/sys/kernel/config/nullb'
> # setup
>
> function _error() {
> - echo "ERROR: $@"
> + echo "ERROR: $@" 1>&2
> exit 1
> }
>
> function _warn() {
> - echo "WARNING: $@"
> + echo "WARNING: $@" 1>&2
> }
>
> function _msg() {
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 2/4] btrfs-progs: tests: check nullb index for the error case
2025-09-10 5:04 [PATCH v2 0/4] btrfs-progs: tests: add new mkfs test for zoned device Naohiro Aota
2025-09-10 5:04 ` [PATCH v2 1/4] btrfs-progs: tests: output error/warn message to stderr Naohiro Aota
@ 2025-09-10 5:04 ` Naohiro Aota
2025-09-10 5:22 ` Qu Wenruo
2025-09-10 5:04 ` [PATCH v2 3/4] btrfs-progs: tests: add wait_for_nullbdevs Naohiro Aota
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Naohiro Aota @ 2025-09-10 5:04 UTC (permalink / raw)
To: linux-btrfs; +Cc: Naohiro Aota
"_find_free_index" can return "" when an error occur. Check the return
value for the case and fail the test.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
tests/nullb | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/nullb b/tests/nullb
index f3cdf9c19e16..721da8f13f12 100755
--- a/tests/nullb
+++ b/tests/nullb
@@ -146,6 +146,9 @@ fi
if [ "$CMD" = 'create' ]; then
_check_setup
index=$(_find_free_index)
+ if [ -z "$index" ]; then
+ exit 1
+ fi
name="nullb$index"
# size in MB
size=$(_parse_device_size "$@")
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 2/4] btrfs-progs: tests: check nullb index for the error case
2025-09-10 5:04 ` [PATCH v2 2/4] btrfs-progs: tests: check nullb index for the error case Naohiro Aota
@ 2025-09-10 5:22 ` Qu Wenruo
0 siblings, 0 replies; 9+ messages in thread
From: Qu Wenruo @ 2025-09-10 5:22 UTC (permalink / raw)
To: Naohiro Aota, linux-btrfs
在 2025/9/10 14:34, Naohiro Aota 写道:
> "_find_free_index" can return "" when an error occur. Check the return
> value for the case and fail the test.
>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> tests/nullb | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tests/nullb b/tests/nullb
> index f3cdf9c19e16..721da8f13f12 100755
> --- a/tests/nullb
> +++ b/tests/nullb
> @@ -146,6 +146,9 @@ fi
> if [ "$CMD" = 'create' ]; then
> _check_setup
> index=$(_find_free_index)
> + if [ -z "$index" ]; then
> + exit 1
> + fi
> name="nullb$index"
> # size in MB
> size=$(_parse_device_size "$@")
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 3/4] btrfs-progs: tests: add wait_for_nullbdevs
2025-09-10 5:04 [PATCH v2 0/4] btrfs-progs: tests: add new mkfs test for zoned device Naohiro Aota
2025-09-10 5:04 ` [PATCH v2 1/4] btrfs-progs: tests: output error/warn message to stderr Naohiro Aota
2025-09-10 5:04 ` [PATCH v2 2/4] btrfs-progs: tests: check nullb index for the error case Naohiro Aota
@ 2025-09-10 5:04 ` Naohiro Aota
2025-09-10 5:22 ` Qu Wenruo
2025-09-10 5:04 ` [PATCH v2 4/4] btrfs-progs: tests: add new mkfs test for zoned device Naohiro Aota
2025-10-16 17:53 ` [PATCH v2 0/4] " David Sterba
4 siblings, 1 reply; 9+ messages in thread
From: Naohiro Aota @ 2025-09-10 5:04 UTC (permalink / raw)
To: linux-btrfs; +Cc: Naohiro Aota
It is a nullb version of wait_for_loopdevs. It waits for all the nullb
devices are ready to use.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
tests/common | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tests/common b/tests/common
index 2c90acb90cfc..42733c215f96 100644
--- a/tests/common
+++ b/tests/common
@@ -984,6 +984,14 @@ cleanup_nullbdevs()
name=$(basename "$dev")
run_check $SUDO_HELPER "$nullb" rm "$name"
done
+ unset nullb_devs
+}
+
+wait_for_nullbdevs()
+{
+ for dev in ${nullb_devs[@]}; do
+ run_mayfail $SUDO_HELPER "$TOP/btrfs" device ready "$dev"
+ done
}
init_env()
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 3/4] btrfs-progs: tests: add wait_for_nullbdevs
2025-09-10 5:04 ` [PATCH v2 3/4] btrfs-progs: tests: add wait_for_nullbdevs Naohiro Aota
@ 2025-09-10 5:22 ` Qu Wenruo
0 siblings, 0 replies; 9+ messages in thread
From: Qu Wenruo @ 2025-09-10 5:22 UTC (permalink / raw)
To: Naohiro Aota, linux-btrfs
在 2025/9/10 14:34, Naohiro Aota 写道:
> It is a nullb version of wait_for_loopdevs. It waits for all the nullb
> devices are ready to use.
>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> tests/common | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/tests/common b/tests/common
> index 2c90acb90cfc..42733c215f96 100644
> --- a/tests/common
> +++ b/tests/common
> @@ -984,6 +984,14 @@ cleanup_nullbdevs()
> name=$(basename "$dev")
> run_check $SUDO_HELPER "$nullb" rm "$name"
> done
> + unset nullb_devs
> +}
> +
> +wait_for_nullbdevs()
> +{
> + for dev in ${nullb_devs[@]}; do
> + run_mayfail $SUDO_HELPER "$TOP/btrfs" device ready "$dev"
> + done
> }
>
> init_env()
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 4/4] btrfs-progs: tests: add new mkfs test for zoned device
2025-09-10 5:04 [PATCH v2 0/4] btrfs-progs: tests: add new mkfs test for zoned device Naohiro Aota
` (2 preceding siblings ...)
2025-09-10 5:04 ` [PATCH v2 3/4] btrfs-progs: tests: add wait_for_nullbdevs Naohiro Aota
@ 2025-09-10 5:04 ` Naohiro Aota
2025-10-16 17:53 ` [PATCH v2 0/4] " David Sterba
4 siblings, 0 replies; 9+ messages in thread
From: Naohiro Aota @ 2025-09-10 5:04 UTC (permalink / raw)
To: linux-btrfs; +Cc: Naohiro Aota, Qu Wenruo
This new test is based on mkfs-tests/001-basic-profiles, and it goes
through the profiles to mkfs and do some basic checks.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
---
tests/mkfs-tests/039-zoned-profiles/test.sh | 98 +++++++++++++++++++++
1 file changed, 98 insertions(+)
create mode 100755 tests/mkfs-tests/039-zoned-profiles/test.sh
diff --git a/tests/mkfs-tests/039-zoned-profiles/test.sh b/tests/mkfs-tests/039-zoned-profiles/test.sh
new file mode 100755
index 000000000000..2592eb6f9a93
--- /dev/null
+++ b/tests/mkfs-tests/039-zoned-profiles/test.sh
@@ -0,0 +1,98 @@
+#!/bin/bash
+# test various blockgroup profile combinations, use nullb devices as block
+# devices. This test is based on mkfs-tests/001-basic-profiles.
+
+source "$TEST_TOP/common" || exit
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+check_global_prereq blkzone
+
+setup_root_helper
+# Create one 128M device with 4M zones, 32 of them
+setup_nullbdevs 4 128 4
+prepare_nullbdevs
+dev1=${nullb_devs[1]}
+
+test_get_info()
+{
+ local tmp_out
+
+ tmp_out=$(_mktemp mkfs-get-info)
+ run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$dev1"
+ run_check $SUDO_HELPER "$TOP/btrfs" check "$dev1"
+
+ # Work around for kernel bug that will treat SINGLE and single
+ # device RAID0 as the same.
+ # Thus kernel may create new SINGLE chunks, causing extra warning
+ # when testing single device RAID0.
+ wait_for_nullbdevs
+ run_check $SUDO_HELPER mount -o ro "$dev1" "$TEST_MNT"
+ run_check_stdout "$TOP/btrfs" filesystem df "$TEST_MNT" > "$tmp_out"
+ if grep -q "Multiple block group profiles detected" "$tmp_out"; then
+ rm -- "$tmp_out"
+ _fail "temporary chunks are not properly cleaned up"
+ fi
+ rm -- "$tmp_out"
+ run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage "$TEST_MNT"
+ run_check $SUDO_HELPER "$TOP/btrfs" device usage "$TEST_MNT"
+ run_check $SUDO_HELPER umount "$TEST_MNT"
+}
+
+test_do_mkfs()
+{
+ run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$@"
+ if run_check_stdout $SUDO_HELPER "$TOP/btrfs" check "$dev1" | grep -iq warning; then
+ _fail "warnings found in check output"
+ fi
+}
+
+test_mkfs_single()
+{
+ test_do_mkfs "$@" "$dev1"
+ test_get_info
+}
+test_mkfs_multi()
+{
+ test_do_mkfs "$@" "${nullb_devs[@]}"
+ test_get_info
+}
+
+test_mkfs_single
+test_mkfs_single -d single -m single
+test_mkfs_single -d single -m dup
+
+test_mkfs_multi
+test_mkfs_multi -d single -m single
+
+if _test_config "EXPERIMENTAL" && [ -f "/sys/fs/btrfs/features/raid_stripe_tree" ]; then
+ test_mkfs_single -d dup -m single
+ test_mkfs_single -d dup -m dup
+
+ test_mkfs_multi -d raid0 -m raid0
+ test_mkfs_multi -d raid1 -m raid1
+ test_mkfs_multi -d raid10 -m raid10
+ # RAID5/6 are not yet supported.
+ # test_mkfs_multi -d raid5 -m raid5
+ # test_mkfs_multi -d raid6 -m raid6
+ test_mkfs_multi -d dup -m dup
+
+ if [ -f "/sys/fs/btrfs/features/raid1c34" ]; then
+ test_mkfs_multi -d raid1c3 -m raid1c3
+ test_mkfs_multi -d raid1c4 -m raid1c4
+ else
+ _log "skip mount test, missing support for raid1c34"
+ test_do_mkfs -d raid1c3 -m raid1c3 "${nullb_devs[@]}"
+ test_do_mkfs -d raid1c4 -m raid1c4 "${nullb_devs[@]}"
+ fi
+
+ # Non-standard profile/device combinations
+
+ # Single device raid0, two device raid10 (simple mount works on older kernels too)
+ test_do_mkfs -d raid0 -m raid0 "$dev1"
+ test_get_info
+ test_do_mkfs -d raid10 -m raid10 "${nullb_devs[1]}" "${nullb_devs[2]}"
+ test_get_info
+fi
+
+cleanup_nullbdevs
--
2.51.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 0/4] btrfs-progs: tests: add new mkfs test for zoned device
2025-09-10 5:04 [PATCH v2 0/4] btrfs-progs: tests: add new mkfs test for zoned device Naohiro Aota
` (3 preceding siblings ...)
2025-09-10 5:04 ` [PATCH v2 4/4] btrfs-progs: tests: add new mkfs test for zoned device Naohiro Aota
@ 2025-10-16 17:53 ` David Sterba
4 siblings, 0 replies; 9+ messages in thread
From: David Sterba @ 2025-10-16 17:53 UTC (permalink / raw)
To: Naohiro Aota; +Cc: linux-btrfs
On Wed, Sep 10, 2025 at 02:04:08PM +0900, Naohiro Aota wrote:
> This series adds a new mkfs test for zoned device. The test is based on
> mkfs-tests/001-basic-profiles, but uses nullb devices instead of loop
> devices, to set a zoned profile.
>
> Two preparation patches are necessaly for the test case. The first and
> second one fix the error handling of _find_free_index(). And, the third
> one adds wait_for_nullbdevs like the loop device's counterpart.
>
> Changes:
> - v2
> - Refine error/warn helpers not to print the message to stdout.
> - Drop cond_wait_for_nullbdevs.
> - Check if btrfs-progs is build with EXPERIMENTAL in the test.
>
> Naohiro Aota (4):
> btrfs-progs: tests: output error/warn message to stderr
> btrfs-progs: tests: check nullb index for the error case
> btrfs-progs: tests: add wait_for_nullbdevs
> btrfs-progs: tests: add new mkfs test for zoned device
Added to devel, sorry for the delay.
^ permalink raw reply [flat|nested] 9+ messages in thread