Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH v3 0/3] btrfs: zoned: unwritten copies of mirrored data writes
@ 2026-12-04 18:59 Miroslav Cimerman
  2026-12-04 18:59 ` [PATCH v3 1/3] btrfs: zoned: use zone append for every copy of a mirrored write Miroslav Cimerman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Miroslav Cimerman @ 2026-12-04 18:59 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba, Chris Mason, Johannes Thumshirn, Naohiro Aota

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


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

end of thread, other threads:[~2026-12-04 19:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 18:59 [PATCH v3 0/3] btrfs: zoned: unwritten copies of mirrored data writes Miroslav Cimerman
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

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