FS/XFS testing framework
 help / color / mirror / Atom feed
* [PATCH 1/2] common/zoned: allow setting the zloop device capacity and extra parameters
@ 2026-11-09 17:51 Johannes Thumshirn
  2026-11-09 17:51 ` [PATCH 2/2] btrfs: test active zone reservation with metadata on conventional zones Johannes Thumshirn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2026-11-09 17:51 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Christoph Hellwig, Naohiro Aota, linux-btrfs, fstests,
	Johannes Thumshirn

Add optional fourth and fifth arguments to _create_zloop() so tests can
size the backing device, which matters when the backing files share a
filesystem with the test data, and pass additional zloop parameters.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 common/zoned | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/zoned b/common/zoned
index 89d0a061..7fe794f9 100644
--- a/common/zoned
+++ b/common/zoned
@@ -81,9 +81,17 @@ _create_zloop()
         local conv_zones=",conv_zones=$3"
     fi
 
+    if [ -n "$4" ]; then
+        local capacity=",capacity_mb=$4"
+    fi
+
+    if [ -n "$5" ]; then
+        local extra=",$5"
+    fi
+
     mkdir -p "$zloop_base/$id"
 
-    local zloop_args="add id=$id,base_dir=$zloop_base$zone_size$conv_zones"
+    local zloop_args="add id=$id,base_dir=$zloop_base$zone_size$conv_zones$capacity$extra"
 
     echo "$zloop_args" > /dev/zloop-control || \
         _fail "cannot create zloop device"
-- 
2.56.0


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

* [PATCH 2/2] btrfs: test active zone reservation with metadata on conventional zones
  2026-11-09 17:51 [PATCH 1/2] common/zoned: allow setting the zloop device capacity and extra parameters Johannes Thumshirn
@ 2026-11-09 17:51 ` Johannes Thumshirn
  2026-11-11 10:18 ` [PATCH 1/2] common/zoned: allow setting the zloop device capacity and extra parameters Carlos Maiolino
  2026-11-11 16:40 ` Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2026-11-09 17:51 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Christoph Hellwig, Naohiro Aota, linux-btrfs, fstests,
	Johannes Thumshirn

On a zoned filesystem, metadata and system block-groups on conventional
zones used up the active zone reservation for metadata at mount time.
Once data and the tree-log took all active zones, activating a
sequential metadata block-group failed and the transaction commit
aborted with -EAGAIN.

Create a zloop device with conventional zones, take all active zones
with data and the tree-log, and churn metadata until it moves to a
sequential block-group.

Assisted-by: LLM
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 tests/btrfs/362     | 120 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/362.out |   2 +
 2 files changed, 122 insertions(+)
 create mode 100755 tests/btrfs/362
 create mode 100644 tests/btrfs/362.out

diff --git a/tests/btrfs/362 b/tests/btrfs/362
new file mode 100755
index 00000000..d1ec3843
--- /dev/null
+++ b/tests/btrfs/362
@@ -0,0 +1,120 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Western Digital Corporation.  All Rights Reserved.
+#
+# FS QA Test 362
+#
+# Test that metadata and system block-groups on conventional zones don't
+# consume the active zone reservation for metadata on a zoned filesystem.
+#
+. ./common/preamble
+_begin_fstest auto zone
+
+_cleanup()
+{
+	cd /
+	[ -n "$mnt" ] && _unmount $mnt 2>/dev/null
+	_destroy_zloop $zloop
+	rm -r -f $tmp.*
+}
+
+. ./common/zoned
+
+_fixed_by_kernel_commit XXXXXXXXXXXX \
+	"btrfs: zoned: don't release active zone reservations for conventional zones"
+
+_require_scratch_size $((8 * 1024 * 1024)) # kB
+_require_block_device $SCRATCH_DEV
+_require_zloop
+_require_command "$BLKZONE_PROG" blkzone
+_require_btrfs_command inspect-internal dump-tree
+_require_btrfs_command filesystem sync
+
+zone_mb=64
+nr_conv=4
+zone_bytes=$((zone_mb << 20))
+
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+
+mnt=$SCRATCH_MNT/mnt
+mkdir -p $mnt
+zloop=$(_create_zloop $SCRATCH_MNT/zloop $zone_mb $nr_conv 4096 \
+	"max_open_zones=12")
+
+$MKFS_BTRFS_PROG -f -d single -m single $zloop >> $seqres.full 2>&1 || \
+	_notrun "cannot mkfs zoned btrfs on $zloop"
+_mount $zloop $mnt
+
+# Print "logical physical" of all metadata chunks.
+meta_chunks()
+{
+	$BTRFS_UTIL_PROG inspect-internal dump-tree -t CHUNK $zloop | \
+		$AWK_PROG '/CHUNK_ITEM/ { logical = $6; sub(/\)/, "", logical) }
+			/type METADATA/ { meta = 1 }
+			/stripe 0 / { if (meta) print logical, $6; meta = 0 }'
+}
+
+# The metadata block-group created by mkfs must be on a conventional zone.
+meta_chunks > $tmp.meta
+cat $tmp.meta >> $seqres.full
+while read logical phys; do
+	[ $phys -lt $((nr_conv * zone_bytes)) ] || \
+		_notrun "metadata not on a conventional zone"
+done < $tmp.meta
+
+# Activate the tree-log block-group.
+$XFS_IO_PROG -f -c "pwrite -q 0 1k" -c fsync $mnt/log >> $seqres.full
+
+# Take as many active zones for data as possible. Leaving 4k free keeps the
+# data block-groups active, as the next 1m allocation doesn't fit in there.
+for i in $(seq 16); do
+	$XFS_IO_PROG -f -d -c "pwrite -q -b 1m 0 $((zone_bytes - 4096))" \
+		$mnt/fill$i >> $seqres.full 2>&1 || break
+	$BTRFS_UTIL_PROG filesystem sync $mnt
+done
+$BLKZONE_PROG report $zloop | grep -E 'oi|oe|cl' >> $seqres.full
+meta_chunks > $tmp.meta
+
+# Has metadata been written to a block-group allocated after the fill?
+new_meta_written()
+{
+	local logical phys
+
+	meta_chunks | while read logical phys; do
+		grep -q "^$logical " $tmp.meta && continue
+		$BLKZONE_PROG report -o $((phys >> 9)) -c 1 $zloop | \
+			grep -q 'wptr 0x000000 ' || echo $logical
+	done | grep -q .
+}
+
+# Churn metadata with inline files until it moves to a new block-group.
+moved=0
+for r in $(seq 100); do
+	mkdir -p $mnt/d$r
+	for i in $(seq 2000); do
+		echo -n "$r-$i" > $mnt/d$r/$i || break 2
+	done
+	rm -rf $mnt/d$((r - 1))
+	$BTRFS_UTIL_PROG filesystem sync $mnt || break
+	if [ $moved -gt 0 ]; then
+		moved=$((moved + 1))
+		[ $moved -gt 3 ] && break
+	elif new_meta_written; then
+		echo "metadata moved to a new block-group in round $r" >> $seqres.full
+		moved=1
+	fi
+done
+meta_chunks >> $seqres.full
+[ $moved -gt 0 ] || echo "metadata did not move to a new block-group"
+
+# The filesystem must still be writable.
+$XFS_IO_PROG -f -c "pwrite -q 0 1k" -c fsync $mnt/last
+
+_unmount $mnt
+_check_btrfs_filesystem $zloop
+
+echo "Silence is golden"
+
+# success, all done
+_exit 0
diff --git a/tests/btrfs/362.out b/tests/btrfs/362.out
new file mode 100644
index 00000000..0ff40905
--- /dev/null
+++ b/tests/btrfs/362.out
@@ -0,0 +1,2 @@
+QA output created by 362
+Silence is golden
-- 
2.56.0


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

* Re: [PATCH 1/2] common/zoned: allow setting the zloop device capacity and extra parameters
  2026-11-09 17:51 [PATCH 1/2] common/zoned: allow setting the zloop device capacity and extra parameters Johannes Thumshirn
  2026-11-09 17:51 ` [PATCH 2/2] btrfs: test active zone reservation with metadata on conventional zones Johannes Thumshirn
@ 2026-11-11 10:18 ` Carlos Maiolino
  2026-11-11 16:40 ` Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Carlos Maiolino @ 2026-11-11 10:18 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Zorro Lang, Christoph Hellwig, Naohiro Aota, linux-btrfs, fstests

On Mon, Nov 09, 2026 at 06:51:45PM +0100, Johannes Thumshirn wrote:
> Add optional fourth and fifth arguments to _create_zloop() so tests can
> size the backing device, which matters when the backing files share a
> filesystem with the test data, and pass additional zloop parameters.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  common/zoned | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/common/zoned b/common/zoned
> index 89d0a061..7fe794f9 100644
> --- a/common/zoned
> +++ b/common/zoned
> @@ -81,9 +81,17 @@ _create_zloop()
>          local conv_zones=",conv_zones=$3"
>      fi
>  
> +    if [ -n "$4" ]; then
> +        local capacity=",capacity_mb=$4"
> +    fi
> +
> +    if [ -n "$5" ]; then
> +        local extra=",$5"
> +    fi
> +
>      mkdir -p "$zloop_base/$id"
>  
> -    local zloop_args="add id=$id,base_dir=$zloop_base$zone_size$conv_zones"
> +    local zloop_args="add id=$id,base_dir=$zloop_base$zone_size$conv_zones$capacity$extra"

Looks good.

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

>  
>      echo "$zloop_args" > /dev/zloop-control || \
>          _fail "cannot create zloop device"
> -- 
> 2.56.0
> 
> 

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

* Re: [PATCH 1/2] common/zoned: allow setting the zloop device capacity and extra parameters
  2026-11-09 17:51 [PATCH 1/2] common/zoned: allow setting the zloop device capacity and extra parameters Johannes Thumshirn
  2026-11-09 17:51 ` [PATCH 2/2] btrfs: test active zone reservation with metadata on conventional zones Johannes Thumshirn
  2026-11-11 10:18 ` [PATCH 1/2] common/zoned: allow setting the zloop device capacity and extra parameters Carlos Maiolino
@ 2026-11-11 16:40 ` Christoph Hellwig
  2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-11-11 16:40 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Zorro Lang, Christoph Hellwig, Naohiro Aota, linux-btrfs, fstests

Looks good:

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

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 17:51 [PATCH 1/2] common/zoned: allow setting the zloop device capacity and extra parameters Johannes Thumshirn
2026-11-09 17:51 ` [PATCH 2/2] btrfs: test active zone reservation with metadata on conventional zones Johannes Thumshirn
2026-11-11 10:18 ` [PATCH 1/2] common/zoned: allow setting the zloop device capacity and extra parameters Carlos Maiolino
2026-11-11 16:40 ` Christoph Hellwig

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