[PATCH 1/2] btrfs: zoned: use zone append for every copy of a mirrored write
From: Miroslav Cimerman
Date: Sat Nov 21 2026 - 22:48:50 EST
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. At write time, only the device's write
error counter and its "errs: wr" log line show it. The failed write also
leaves a gap in that zone. Every regular write allocated behind the gap
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@xxxxxxxxxxxxxxx # 7.0+
Signed-off-by: Miroslav Cimerman <mc@xxxxxxxxxxx>
---
During a device replace, writes to block groups that were already copied
are sent to the target through the same function. With this patch the
source copy is a zone append write again, as before 7.0. I did not test
a replace.
fs/btrfs/bio.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index efbce4d549ff..8aac4afa30ee 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -519,6 +519,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