From: Miroslav Cimerman <mc@raidlab.org>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>,
Naohiro Aota <naohiro.aota@wdc.com>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Qu Wenruo <wqu@suse.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/3] btrfs: zoned: use zone append for every copy of a mirrored write
Date: Sun, 29 Nov 2026 23:52:24 +0000 [thread overview]
Message-ID: <20261129235226.459661-2-mc@raidlab.org> (raw)
In-Reply-To: <20261129235226.459661-1-mc@raidlab.org>
Since commit b39b26e017c7 ("btrfs: zoned: don't zone append to
conventional zone"), btrfs_submit_dev_bio() uses zone append only if
can_use_append is set in the btrfs_bio. For a mirrored write,
btrfs_submit_mirrored_bio() sends the original bio to the last stripe
and a clone to every other stripe. The clone is set up with
btrfs_bio_init(), which clears can_use_append. So on a zoned filesystem,
every copy of a mirrored data write but the last is a regular write at
the allocated address.
A regular write to a sequential zone has to arrive at the zone's write
pointer. Writes to one zone can arrive in a different order than they
were allocated, for example from two writers. The copy that arrives too
early then fails:
extent A at offset 0, extent B at offset 64K of one zone
last stripe (zone append): B, then A: both written
stripe 0 (regular write): B fails, the write pointer is still at 0
A RAID1 write succeeds with one failed copy. A buffered write then
completes with one copy less. Only the device's write error counter and
its "errs: wr" log line show it. The failed write also leaves the write
pointer of that zone behind, so every later regular write to the zone
fails too.
Copy can_use_append to the clone, as commit c757edbef980 ("btrfs: fix
copying the flags of btrfs_bio after split") does for split bios.
Fixes: b39b26e017c7 ("btrfs: zoned: don't zone append to conventional zone")
CC: stable@vger.kernel.org # 6.18+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Miroslav Cimerman <mc@raidlab.org>
---
fs/btrfs/bio.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index b90ca97c9c4d..2573f980de99 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -521,6 +521,7 @@ static void btrfs_submit_mirrored_bio(struct btrfs_io_context *bioc, int dev_nr)
bio_inc_remaining(orig_bio);
btrfs_bio_init(btrfs_bio(bio), orig_bbio->inode,
orig_bbio->file_offset, NULL, NULL);
+ btrfs_bio(bio)->can_use_append = orig_bbio->can_use_append;
bio->bi_end_io = btrfs_clone_write_end_io;
}
--
2.53.0
next prev parent reply other threads:[~2026-11-29 23:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 23:52 [PATCH v2 0/3] btrfs: zoned: unwritten copies of mirrored data writes Miroslav Cimerman
2026-11-29 23:52 ` Miroslav Cimerman [this message]
2026-11-29 23:52 ` [PATCH v2 2/3] btrfs: zoned: wait for zone finish works at unmount Miroslav Cimerman
2026-11-30 10:27 ` Johannes Thumshirn
2026-11-30 11:07 ` Miroslav Cimerman
2026-11-30 14:04 ` Johannes Thumshirn
2026-11-29 23:52 ` [PATCH v2 3/3] btrfs: zoned: finish raid stripe tree zones once all data is written Miroslav Cimerman
2026-11-30 14:31 ` Johannes Thumshirn
2026-11-30 16:55 ` 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=20261129235226.459661-2-mc@raidlab.org \
--to=mc@raidlab.org \
--cc=dsterba@suse.com \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@kernel.org \
--cc=naohiro.aota@wdc.com \
--cc=wqu@suse.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.