From: Zorro Lang <zlang@kernel.org>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org,
Naohiro Aota <naohiro.aota@wdc.com>
Subject: Re: [PATCH] btrfs: test that fsync on zoned doesn't fail with -EAGAIN
Date: Sun, 15 Nov 2026 00:02:52 +0800 [thread overview]
Message-ID: <aviB404o-v7VT09w@zlang-mailbox> (raw)
In-Reply-To: <20261110095911.2013053-1-johannes.thumshirn@wdc.com>
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
>
prev parent reply other threads:[~2026-11-14 16:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aviB404o-v7VT09w@zlang-mailbox \
--to=zlang@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.