The Linux Kernel Mailing List
 help / color / mirror / Atom feed
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 0/3] btrfs: zoned: unwritten copies of mirrored data writes
Date: Sun, 29 Nov 2026 23:52:23 +0000	[thread overview]
Message-ID: <20261129235226.459661-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.

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 1adb6f14ca90 as in v1 [1], with 8 active zones per
device. With 1/3 alone, zone append writes failed in 10 of 10 runs with
8 direct writers. With the series, 31 runs showed no failed write. A
test-only print showed the work waiting for other writes before 82 of
160 zone finishes. With a test-only delay in the work, an unmount right
after the writes hit an assertion in 9 of 9 runs without 2/3 and in
none of 6 runs with it.

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] https://lore.kernel.org/linux-btrfs/20261122034826.2333981-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 unmount
  btrfs: zoned: finish raid stripe tree zones once all data is written

 fs/btrfs/bio.c         |  1 +
 fs/btrfs/block-group.c | 16 ++++++++--
 fs/btrfs/disk-io.c     |  7 +++++
 fs/btrfs/inode.c       |  3 ++
 fs/btrfs/zoned.c       | 71 ++++++++++++++++++++++++++++++++++++++++--
 fs/btrfs/zoned.h       |  3 ++
 6 files changed, 96 insertions(+), 5 deletions(-)


base-commit: 1adb6f14ca90851ae4a8279ee90442589c312ba3
-- 
2.53.0


             reply	other threads:[~2026-11-29 23:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 23:52 Miroslav Cimerman [this message]
2026-11-29 23:52 ` [PATCH v2 1/3] btrfs: zoned: use zone append for every copy of a mirrored write Miroslav Cimerman
2026-11-29 23:52 ` [PATCH v2 2/3] btrfs: zoned: wait for zone finish works at unmount Miroslav Cimerman
2026-11-29 23:52 ` [PATCH v2 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=20261129235226.459661-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox