All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] reduce reflink src inode lock contention
@ 2026-09-15 17:58 Boris Burkov
  2026-09-15 17:58 ` [PATCH v3 1/3] btrfs: pre-flush reflink source before taking inode locks Boris Burkov
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Boris Burkov @ 2026-09-15 17:58 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

We currently take the src and dst inode i_rwsem exclusive for the
entirety of a reflink which includes writing back all of both files and
walking all the src extents and duplicating them to dst. This results in
contention on those locks which I think can be reduced.

The basic strategy is:
1. try to do obvious easy src writeback outside the lock.
2. downgrade the src lock to shared where it is safe.

Changelog:
v3:
- use btrfs_wait_ordered_range() instead of the misguided custom walk.
- add a helper to unify range computations.
v2:
- introduce unlocked wb pre-flush instead of a downgrade of src inode lock
  for the whole reflink.
- add the "has writers" pessimization.
- still downgrade after done with wb.

Boris Burkov (3):
  btrfs: pre-flush reflink source before taking inode locks
  btrfs: skip unlocked reflink source flush if the inode has writers
  btrfs: downgrade the reflink source inode lock for tree walking

 fs/btrfs/btrfs_inode.h |  6 +++++
 fs/btrfs/direct-io.c   |  7 ++++++
 fs/btrfs/reflink.c     | 51 +++++++++++++++++++++++++++++++++++++-----
 3 files changed, 58 insertions(+), 6 deletions(-)

-- 
2.55.0


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

end of thread, other threads:[~2026-09-17 16:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15 17:58 [PATCH v3 0/3] reduce reflink src inode lock contention Boris Burkov
2026-09-15 17:58 ` [PATCH v3 1/3] btrfs: pre-flush reflink source before taking inode locks Boris Burkov
2026-09-17 16:46   ` Filipe Manana
2026-09-15 17:58 ` [PATCH v3 2/3] btrfs: skip unlocked reflink source flush if the inode has writers Boris Burkov
2026-09-17 16:48   ` Filipe Manana
2026-09-15 17:58 ` [PATCH v3 3/3] btrfs: downgrade the reflink source inode lock for tree walking Boris Burkov
2026-09-17 16:54   ` Filipe Manana

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.