FS/XFS testing framework
 help / color / mirror / Atom feed
* [PATCH] btrfs: test that fsync on zoned doesn't fail with -EAGAIN
@ 2026-11-10  9:59 Johannes Thumshirn
  2026-11-11 15:34 ` Christoph Hellwig
  2026-11-14 16:02 ` Zorro Lang
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2026-11-10  9:59 UTC (permalink / raw)
  To: Zorro Lang; +Cc: fstests, linux-btrfs, Naohiro Aota, Johannes Thumshirn

On a zoned filesystem, btrfs_start_transaction() forces a transaction
commit when the delayed refs reservation exceeds its zoned cap. If the
cap is still exceeded after the commit, it returned -EAGAIN, which
fsync passed on to user space.

Run parallel writers creating, overwriting and deleting small files with
an fsync after every write on a zoned device with a limited number of
active zones, and check that no fsync fails.

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

diff --git a/tests/btrfs/364 b/tests/btrfs/364
new file mode 100755
index 00000000..39b0141e
--- /dev/null
+++ b/tests/btrfs/364
@@ -0,0 +1,76 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Western Digital Corporation.  All Rights Reserved.
+#
+# FS QA Test 364
+#
+. ./common/preamble
+_begin_fstest auto quick zone
+
+_cleanup()
+{
+	cd /
+	[ -n "$pids" ] && kill $pids &> /dev/null
+	wait
+	rm -r -f $tmp.*
+}
+
+. ./common/zoned
+
+_fixed_by_kernel_commit XXXXXXXXXXXX \
+	"btrfs: zoned: don't fail start_transaction() after a forced commit"
+
+_require_scratch_size $((4 * 1024 * 1024)) # kB
+_require_zoned_device "$SCRATCH_DEV"
+_require_limited_active_zones "$SCRATCH_DEV"
+
+nr_writers=$((8 * LOAD_FACTOR))
+nr_files=250
+nr_rounds=$((4 * TIME_FACTOR))
+
+_scratch_mkfs -d single -m single >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+# Every other file is deleted per round to churn data and metadata.
+writer()
+{
+	local dir=$SCRATCH_MNT/w$1
+	local r i sz
+
+	mkdir -p $dir
+	for r in $(seq $nr_rounds); do
+		for i in $(seq $nr_files); do
+			# 4K - 256K
+			sz=$(( ((i + r + $1) % 64 + 1) * 4096 ))
+			$XFS_IO_PROG -f -c "pwrite -q -S $i -b 64k 0 $sz" \
+				-c fsync $dir/$i || return 1
+		done
+		for i in $(seq 1 2 $nr_files); do
+			rm -f $dir/$i
+		done
+	done
+}
+
+pids=""
+for w in $(seq $nr_writers); do
+	writer $w > $tmp.writer.$w 2>&1 &
+	pids="$pids $!"
+done
+
+ret=0
+for p in $pids; do
+	wait $p || ret=1
+done
+unset pids
+cat $tmp.writer.* >> $seqres.full
+[ $ret -eq 0 ] || echo "writer failed, see $seqres.full"
+
+find $SCRATCH_MNT -type f | sort | xargs md5sum > $tmp.md5.before
+_scratch_cycle_mount
+find $SCRATCH_MNT -type f | sort | xargs md5sum > $tmp.md5.after
+diff -q $tmp.md5.before $tmp.md5.after > /dev/null || echo "data mismatch"
+
+echo "Silence is golden"
+
+# success, all done
+_exit 0
diff --git a/tests/btrfs/364.out b/tests/btrfs/364.out
new file mode 100644
index 00000000..6bc54ae6
--- /dev/null
+++ b/tests/btrfs/364.out
@@ -0,0 +1,2 @@
+QA output created by 364
+Silence is golden
-- 
2.56.0


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

* Re: [PATCH] btrfs: test that fsync on zoned doesn't fail with -EAGAIN
  2026-11-10  9:59 [PATCH] btrfs: test that fsync on zoned doesn't fail with -EAGAIN Johannes Thumshirn
@ 2026-11-11 15:34 ` Christoph Hellwig
  2026-11-13 14:42   ` Johannes Thumshirn
  2026-11-14 16:02 ` Zorro Lang
  1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2026-11-11 15:34 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: Zorro Lang, fstests, linux-btrfs, Naohiro Aota

On Tue, Nov 10, 2026 at 10:59:11AM +0100, Johannes Thumshirn wrote:
> On a zoned filesystem, btrfs_start_transaction() forces a transaction
> commit when the delayed refs reservation exceeds its zoned cap. If the
> cap is still exceeded after the commit, it returned -EAGAIN, which
> fsync passed on to user space.
> 
> Run parallel writers creating, overwriting and deleting small files with
> an fsync after every write on a zoned device with a limited number of
> active zones, and check that no fsync fails.

Should this be a generic test?


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

* Re: [PATCH] btrfs: test that fsync on zoned doesn't fail with -EAGAIN
  2026-11-11 15:34 ` Christoph Hellwig
@ 2026-11-13 14:42   ` Johannes Thumshirn
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2026-11-13 14:42 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Zorro Lang, fstests, linux-btrfs, Naohiro Aota

On 11/11/26 4:34 PM, Christoph Hellwig wrote:
> On Tue, Nov 10, 2026 at 10:59:11AM +0100, Johannes Thumshirn wrote:
>> On a zoned filesystem, btrfs_start_transaction() forces a transaction
>> commit when the delayed refs reservation exceeds its zoned cap. If the
>> cap is still exceeded after the commit, it returned -EAGAIN, which
>> fsync passed on to user space.
>>
>> Run parallel writers creating, overwriting and deleting small files with
>> an fsync after every write on a zoned device with a limited number of
>> active zones, and check that no fsync fails.
> Should this be a generic test?

Sure I can make it a generic test.


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

* Re: [PATCH] btrfs: test that fsync on zoned doesn't fail with -EAGAIN
  2026-11-10  9:59 [PATCH] btrfs: test that fsync on zoned doesn't fail with -EAGAIN Johannes Thumshirn
  2026-11-11 15:34 ` Christoph Hellwig
@ 2026-11-14 16:02 ` Zorro Lang
  1 sibling, 0 replies; 4+ messages in thread
From: Zorro Lang @ 2026-11-14 16:02 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: fstests, linux-btrfs, Naohiro Aota

On Tue, Nov 10, 2026 at 10:59:11AM +0100, Johannes Thumshirn wrote:
> On a zoned filesystem, btrfs_start_transaction() forces a transaction
> commit when the delayed refs reservation exceeds its zoned cap. If the
> cap is still exceeded after the commit, it returned -EAGAIN, which
> fsync passed on to user space.
> 
> Run parallel writers creating, overwriting and deleting small files with
> an fsync after every write on a zoned device with a limited number of
> active zones, and check that no fsync fails.
> 
> Assisted-by: LLM
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  tests/btrfs/364     | 76 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/364.out |  2 ++
>  2 files changed, 78 insertions(+)
>  create mode 100755 tests/btrfs/364
>  create mode 100644 tests/btrfs/364.out
> 
> diff --git a/tests/btrfs/364 b/tests/btrfs/364
> new file mode 100755
> index 00000000..39b0141e
> --- /dev/null
> +++ b/tests/btrfs/364
> @@ -0,0 +1,76 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2026 Western Digital Corporation.  All Rights Reserved.
> +#
> +# FS QA Test 364
> +#
> +. ./common/preamble
> +_begin_fstest auto quick zone
> +
> +_cleanup()
> +{
> +	cd /
> +	[ -n "$pids" ] && kill $pids &> /dev/null
> +	wait
> +	rm -r -f $tmp.*
> +}
> +
> +. ./common/zoned
> +
> +_fixed_by_kernel_commit XXXXXXXXXXXX \
> +	"btrfs: zoned: don't fail start_transaction() after a forced commit"
> +
> +_require_scratch_size $((4 * 1024 * 1024)) # kB
> +_require_zoned_device "$SCRATCH_DEV"
> +_require_limited_active_zones "$SCRATCH_DEV"
> +
> +nr_writers=$((8 * LOAD_FACTOR))
> +nr_files=250
> +nr_rounds=$((4 * TIME_FACTOR))
> +
> +_scratch_mkfs -d single -m single >> $seqres.full 2>&1 || _fail "mkfs failed"

Is -d single -m single strictly necessary here? I think mkfs.btrfs defaults to
single for both data and metadata on zoned devices (right?), and hardcoding it
overrides user-provided MKFS_OPTIONS.

In fact, once -d single -m single is dropped, there is nothing btrfs-specific
left in this test at all, then it can be a  generic case. Moving it to
generic/ would let other zoned-capable filesystems (e.g., f2fs, xfs) benefit
from this stress test as well.

> +_scratch_mount
> +
> +# Every other file is deleted per round to churn data and metadata.
> +writer()
> +{
> +	local dir=$SCRATCH_MNT/w$1
> +	local r i sz
> +
> +	mkdir -p $dir
> +	for r in $(seq $nr_rounds); do
> +		for i in $(seq $nr_files); do
> +			# 4K - 256K
> +			sz=$(( ((i + r + $1) % 64 + 1) * 4096 ))
> +			$XFS_IO_PROG -f -c "pwrite -q -S $i -b 64k 0 $sz" \
> +				-c fsync $dir/$i || return 1
> +		done
> +		for i in $(seq 1 2 $nr_files); do
> +			rm -f $dir/$i
> +		done
> +	done
> +}
> +
> +pids=""
> +for w in $(seq $nr_writers); do
> +	writer $w > $tmp.writer.$w 2>&1 &
> +	pids="$pids $!"
> +done
> +
> +ret=0
> +for p in $pids; do
> +	wait $p || ret=1
> +done
> +unset pids
> +cat $tmp.writer.* >> $seqres.full
> +[ $ret -eq 0 ] || echo "writer failed, see $seqres.full"
> +
> +find $SCRATCH_MNT -type f | sort | xargs md5sum > $tmp.md5.before

A minor nitpick: if `find` happens to produce no output for some unexpected
reason, `xargs md5sum` could hang waiting on stdin. Passing -r
(--no-run-if-empty) to xargs would help to avoid that.

> +_scratch_cycle_mount
> +find $SCRATCH_MNT -type f | sort | xargs md5sum > $tmp.md5.after

Thanks,
Zorro

> +diff -q $tmp.md5.before $tmp.md5.after > /dev/null || echo "data mismatch"
> +
> +echo "Silence is golden"
> +
> +# success, all done
> +_exit 0
> diff --git a/tests/btrfs/364.out b/tests/btrfs/364.out
> new file mode 100644
> index 00000000..6bc54ae6
> --- /dev/null
> +++ b/tests/btrfs/364.out
> @@ -0,0 +1,2 @@
> +QA output created by 364
> +Silence is golden
> -- 
> 2.56.0
> 

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10  9:59 [PATCH] btrfs: test that fsync on zoned doesn't fail with -EAGAIN Johannes Thumshirn
2026-11-11 15:34 ` Christoph Hellwig
2026-11-13 14:42   ` Johannes Thumshirn
2026-11-14 16:02 ` Zorro Lang

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