From: Miroslav Cimerman <mc@raidlab.org>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Naohiro Aota <naohiro.aota@wdc.com>
Subject: [PATCH v3 0/3] btrfs: zoned: unwritten copies of mirrored data writes
Date: Fri, 4 Dec 2026 18:59:54 +0000 [thread overview]
Message-ID: <20261204185957.313982-1-mc@raidlab.org> (raw)
On a zoned filesystem, a mirrored data write can lose a copy, or fail,
without any problem on the devices. The bugs fixed by 1/3 and 3/3 need
writes to one zone to arrive out of allocation order, which parallel
writers do.
1/3: since 7.0, every copy but the last is a regular write. A regular
write that arrives before an earlier one fails.
2/3: since 5.19, unmount does not wait for the work that finishes the
zones of a full metadata block group. 3/3 uses that work for data too.
3/3: since 6.7, with the raid stripe tree, the zones of a block group
are finished when the extent at its end completes. Zone append writes of
other extents that are still queued then fail.
3/3 relies on alloc_offset of a full block group not moving back. [2]
fixes the zoned allocator, which could move it back.
Changes in v3:
- 1/3: unchanged.
- 2/3: also wait in btrfs_remove_block_group(). A block group removed
before unmount is no longer in the tree that unmount walks (Sashiko
on v2 [1]). Reviewed-by from Johannes.
- 3/3: split the assertion into ASSERT()s with messages, and assert that
delalloc_bytes does not underflow (Johannes). The data relocation
block group on RAID0/RAID10 has an older problem of its own
(Sashiko). I will send a fix.
- Rebased on for-next.
Changes in v2:
- 1/3: Reviewed-by from Johannes. Stable tag 6.18+: the fixed commit
is in 6.18.y too. Rebased on for-next.
- 2/3: new.
- 3/3: no new field in btrfs_block_group (Johannes). zone_finish_work
finishes the zones once every extent that zone append writes to the
block group is written or freed. Rebased on for-next.
Tested on for-next d7a35bfad47f with [2] applied, btrfs-progs 7.3 and 8
active zones per device. Without the series, 8 direct writers on RAID1
with the raid stripe tree hit zone append errors in 2 of 2 runs. With
the series, 13 runs showed no failed write and no assertion, and
unmount waited for every zone finish work.
Found by an LLM while testing a fix on zoned RAID1. The analysis, the
fixes and the tests were done with the help of an LLM. I reviewed
everything.
[1] v2: https://lore.kernel.org/linux-btrfs/20261129235226.459661-1-mc@raidlab.org/
[2] https://lore.kernel.org/linux-btrfs/20261130163800.175298-1-mc@raidlab.org/
Miroslav Cimerman (3):
btrfs: zoned: use zone append for every copy of a mirrored write
btrfs: zoned: wait for zone finish works at removal and unmount
btrfs: zoned: finish raid stripe tree zones once all data is written
fs/btrfs/bio.c | 1 +
fs/btrfs/block-group.c | 30 ++++++++++++++++--
fs/btrfs/disk-io.c | 7 +++++
fs/btrfs/inode.c | 6 ++++
fs/btrfs/zoned.c | 71 ++++++++++++++++++++++++++++++++++++++++--
fs/btrfs/zoned.h | 3 ++
6 files changed, 113 insertions(+), 5 deletions(-)
base-commit: d7a35bfad47f033380f6f6d42d186adc1d9fe406
--
2.53.0
next reply other threads:[~2026-12-04 19:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:59 Miroslav Cimerman [this message]
2026-12-04 18:59 ` [PATCH v3 1/3] btrfs: zoned: use zone append for every copy of a mirrored write Miroslav Cimerman
2026-12-04 18:59 ` [PATCH v3 2/3] btrfs: zoned: wait for zone finish works at removal and unmount Miroslav Cimerman
2026-12-04 18:59 ` [PATCH v3 3/3] btrfs: zoned: finish raid stripe tree zones once all data is written Miroslav Cimerman
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=20261204185957.313982-1-mc@raidlab.org \
--to=mc@raidlab.org \
--cc=dsterba@suse.com \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=mason@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.