Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs: fix possible race between error handling and writeback
@ 2025-07-23 11:21 Qu Wenruo
  2025-07-23 11:21 ` [PATCH 1/3] btrfs: enhance error messages for delalloc range failure Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Qu Wenruo @ 2025-07-23 11:21 UTC (permalink / raw)
  To: linux-btrfs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-25 21:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-23 11:21 [PATCH 0/3] btrfs: fix possible race between error handling and writeback Qu Wenruo
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox