Re: [PATCH] btrfs: fix deadlocks with transaction commit when cloning inline extents

From: Qu Wenruo

Date: Sun Aug 30 2026 - 18:35:39 EST




在 2026/8/30 20:12, Melon Liu 写道:
On Sat, Aug 29, 2026 at 06:25:11PM +0930, Qu Wenruo wrote:


在 2026/8/29 17:09, Melon Liu 写道:
Commits b48c980b6a7e ("btrfs: fix deadlock between reflink and transaction
commit when using flushoncommit") and 532085d00eb5 ("btrfs: fix deadlock
cloning inline extent when using flushoncommit") moved the destination
i_size update before btrfs_start_transaction() to prevent
extent_writepage() from invalidating a folio beyond EOF. However, two
deadlock windows remain.

First, after the folio is dirtied but before i_size is updated,
extent_writepage() can still see the folio beyond EOF. It calls
folio_invalidate(), and btrfs_invalidate_folio() waits for the destination
extent range lock held by the clone task.

Second, if extent_writepage() sees the folio within EOF, it proceeds to
writepage_delalloc(), which also waits for the destination extent range
lock.

What about letting the agent to create a reproducer, trigger it and paste
the lockdep/hang calltrace?

Also an ASCII chart showing the window between involved threads?

[...]
Fixes: 05a5a7621ce6 ("Btrfs: implement full reflink support for inline extents")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Melon Liu <melon1335@xxxxxxx>

And AI disclosure.

Thanks for the review. I'll address your comments and send a v2.

And also check the sashiko review:

https://sashiko.dev/#/patchset/a74ov5nvs5u4nkqhrs5lp2jaj664wewkqqsjxzhuemzazzmzvx%40eeof6sjb3xdc