public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 0/4] btrfs: btrfs: fix possible race between error handling and writeback
Date: Mon, 18 Aug 2025 17:48:12 +0200	[thread overview]
Message-ID: <20250818154812.GO22430@twin.jikos.cz> (raw)
In-Reply-To: <cover.1753687685.git.wqu@suse.com>

On Mon, Jul 28, 2025 at 05:57:53PM +0930, Qu Wenruo wrote:
> [CHANGELOG]
> v2:
> - Add a new patch to explain the error handling better
>   This makes the later nocow_one_range() error handling change easier to explain.
> 
> 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 enhance the error handling of run_delalloc_nocow(), with
> proper comments and charts explaining the cleanup range.
> 
> The second patch is a small enhancement to the error messages, which
> helps debugging.
> 
> The third 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 (4):
>   btrfs: rework the error handling of run_delalloc_nocow()
>   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()

The patches have been in linux-next for some time, feel free to add them
to for-next proper so they can be merged. Related to that, you can
remove the cow fixup code in this development cycle if you want.

  parent reply	other threads:[~2025-08-18 15:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-28  8:27 [PATCH v2 0/4] btrfs: btrfs: fix possible race between error handling and writeback Qu Wenruo
2025-07-28  8:27 ` [PATCH v2 1/4] btrfs: rework the error handling of run_delalloc_nocow() Qu Wenruo
2025-07-28  8:27 ` [PATCH v2 2/4] btrfs: enhance error messages for delalloc range failure Qu Wenruo
2025-07-28  8:27 ` [PATCH v2 3/4] btrfs: make nocow_one_range() to do cleanup on error Qu Wenruo
2025-07-28  8:27 ` [PATCH v2 4/4] btrfs: keep folios locked inside run_delalloc_nocow() Qu Wenruo
2025-08-04 22:36   ` Wang Yugui
2025-08-04 22:53     ` Qu Wenruo
2025-08-18 15:48 ` David Sterba [this message]
2025-08-18 21:47   ` [PATCH v2 0/4] btrfs: btrfs: fix possible race between error handling and writeback Qu Wenruo
2025-08-21 13:52     ` David Sterba

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=20250818154812.GO22430@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.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