All of lore.kernel.org
 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 0/2] btrfs: zoned: unwritten copies of mirrored data writes
Date: Sun, 22 Nov 2026 03:48:23 +0000	[thread overview]
Message-ID: <20261122034826.2333981-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. Two bugs cause it. Both need writes
to one zone to arrive in a different order than they were allocated,
which parallel writers do.

1/2: since 7.0, every copy but the last is a regular write. A regular
write that arrives before an earlier one fails.

2/2: 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.

Tested in QEMU with KASAN on for-next 184fa2c40f5c, with two zoned
null_blk devices (1 GiB, 16 MiB zones, 8 active zones) and RAID1 data
and metadata on the raid stripe tree. 8 direct writers each wrote 4
files of 8 MiB, and 16 buffered writers did the same with fsync. At
least two runs each:

                direct, 8 writers          buffered, 16 writers
  for-next      5 to 8 of 32 writes        writes succeed, but some
                fail with EIO              copies are not written
  with 1/2      writes succeed, but some   no errors
                copies are not written
  with 2/2      writes succeed, but some   writes succeed, but some
                copies are not written     copies are not written
  with both     no errors                  no errors

A copy that is not written shows up as a write error in the device
statistics ("errs: wr").

The series is based on 6b72ea3e75f4, which differs from the tested
commit only in qgroup.c.

On for-next, the next mount failed in 3 of 4 runs with "write pointer
offset mismatch". With both patches, it worked in every run. With the
single data profile, for-next shows no failure in the same tests. A set
of degraded-mount tests and the btrfs self-tests show no new failure
with the patches, also on top of my RAID1 series [1].

Each patch alone leaves the failures of the other, so they are sent
together. They apply to for-next without [1].

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.

FuzzyRAID, a fault-injection tester for RAID that is not public at the
moment, reproduced both bugs on its own and found no error with the
patches. With 1/2 missing, a scrub found the copy on one device corrupt
after the writes had succeeded.

[1] https://lore.kernel.org/linux-btrfs/20261121134550.216217-1-mc@raidlab.org/

Miroslav Cimerman (2):
  btrfs: zoned: use zone append for every copy of a mirrored write
  btrfs: zoned: finish raid stripe tree zones once all data is written

 fs/btrfs/bio.c         |  1 +
 fs/btrfs/block-group.h |  6 ++++++
 fs/btrfs/zoned.c       | 33 +++++++++++++++++++++++++++++----
 3 files changed, 36 insertions(+), 4 deletions(-)


base-commit: 6b72ea3e75f4d20a0ad1e9c95d7f9f1b8f192b92
-- 
2.53.0


             reply	other threads:[~2026-11-22  3:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  3:48 Miroslav Cimerman [this message]
2026-11-22  3:48 ` [PATCH 1/2] btrfs: zoned: use zone append for every copy of a mirrored write Miroslav Cimerman
2026-11-27 10:46   ` Johannes Thumshirn
2026-11-22  3:48 ` [PATCH 2/2] btrfs: zoned: finish raid stripe tree zones once all data is written Miroslav Cimerman
2026-11-27 11:01   ` Johannes Thumshirn
2026-11-30  0:06     ` 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=20261122034826.2333981-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 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.