From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 0/3] btrfs: fix possible race between error handling and writeback
Date: Wed, 23 Jul 2025 20:51:21 +0930 [thread overview]
Message-ID: <cover.1753269601.git.wqu@suse.com> (raw)
There are some rare kernel warning for experimental btrfs builds that
the DEBUG_WARN() can be triggered from btrfs_writepage_cow_fixup(),
mostly after some delalloc range failure.
The root cause is explained the the last patch, the TL;DR is we
shouldn't call btrfs_cleanup_ordered_extents() on folios that are
already unlocked.
Those unlocked folios can be under writeback, and if we cleared the
order flag just before the writeback thread entering
btrfs_writepage_cow_fixup(), we will trigger the warning.
The first patch is a small enhancement to the error messages, which
helps debugging.
The second patch is to make nocow_one_range() to do proper cleanup,
aligning itself to cow_file_range().
The last one is to fix the race window by keep folios of successful
ranges locked, so that we either unlock them manually at the end of
run_delalloc_nocow(), or get btrfs_cleanup_ordered_extents() called on
locked folios for error handling.
Qu Wenruo (3):
btrfs: enhance error messages for delalloc range failure
btrfs: make nocow_one_range() to do cleanup on error
btrfs: keep folios locked inside run_delalloc_nocow()
fs/btrfs/inode.c | 131 +++++++++++++++++++++--------------------------
1 file changed, 58 insertions(+), 73 deletions(-)
--
2.50.0
next reply other threads:[~2025-07-23 11:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 11:21 Qu Wenruo [this message]
2025-07-23 11:21 ` [PATCH 1/3] btrfs: enhance error messages for delalloc range failure Qu Wenruo
2025-07-25 18:37 ` Boris Burkov
2025-07-23 11:21 ` [PATCH 2/3] btrfs: make nocow_one_range() to do cleanup on error Qu Wenruo
2025-07-25 18:37 ` Boris Burkov
2025-07-25 21:20 ` Qu Wenruo
2025-07-23 11:21 ` [PATCH 3/3] btrfs: keep folios locked inside run_delalloc_nocow() 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=cover.1753269601.git.wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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