From: Breno Leitao <leitao@debian.org>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>,
Qu Wenruo <wqu@suse.com>,
linux-kernel@vger.kernel.org, boris@bur.io, jlayton@kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: btrfs: bug report: reflink racing with async compression forces read-only
Date: Wed, 4 Nov 2026 04:10:53 -0800 [thread overview]
Message-ID: <ause7k_HjzUWT3D-@gmail.com> (raw)
Hi,
We are seeing btrfs go read-only on arm64 production hosts (64K pages,
4K blocks, compress-force=zstd:3), on 6.16-based kernels and up, still
being reproduced in linux-next as of today:
BTRFS warning (device nvme0n1p2): no extent map found for inode ...
when unpinning extent range [20480, 24576), generation ...
BTRFS: error (device nvme0n1p2 state A) in btrfs_finish_one_ordered:3200:
errno=-2 No such entry
BTRFS info (device nvme0n1p2 state EA): forced readonly
A quick bissection seems to point to commit 1d2fbb7f1f9e ("btrfs: allow
compression even if the range is not page aligned")
I've able to come up with a reproducer that hits the issue within
seconds with 64K pages:
https://github.com/leitao/btrfs-reflink-async-compress
My robot identified this as the root cause, but I am not smart enough to
understand:
A reflink into a range that is still being compressed does not wait
for it:
1. Another part of the same folio starts writeback first, which clears
the folio's dirty tag.
2. The second filemap_fdatawrite_range() in btrfs_fdatawrite_range()
finds folios by that tag, so btrfs_wait_ordered_range() returns
before the async extent has an ordered extent.
3. btrfs_clone() drops or splits the extent map pinned for that extent,
and the transaction aborts when it completes. If the clone wins the
race instead, the compressed write lands after it and the cloned data
is silently lost.
Thanks,
--breno
next reply other threads:[~2026-11-04 12:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 12:10 Breno Leitao [this message]
2026-11-04 21:02 ` Qu Wenruo
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=ause7k_HjzUWT3D-@gmail.com \
--to=leitao@debian.org \
--cc=boris@bur.io \
--cc=dsterba@suse.com \
--cc=jlayton@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@kernel.org \
--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
all inboxes | Powered by JetHome®