Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH v2 0/3] reduce reflink src inode lock contention
Date: Thu, 10 Sep 2026 17:26:16 -0700	[thread overview]
Message-ID: <cover.1789085863.git.boris@bur.io> (raw)

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.

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     | 72 ++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 83 insertions(+), 2 deletions(-)

-- 
2.55.0


             reply	other threads:[~2026-09-11  0:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  0:26 Boris Burkov [this message]
2026-09-11  0:26 ` [PATCH v2 1/3] btrfs: pre-flush reflink source before taking inode locks Boris Burkov
2026-09-11  9:17   ` Filipe Manana
2026-09-11 21:51     ` Boris Burkov
2026-09-11  0:26 ` [PATCH v2 2/3] btrfs: skip unlocked reflink source flush if the inode has writers Boris Burkov
2026-09-11  0:26 ` [PATCH v2 3/3] btrfs: downgrade the reflink source inode lock for tree walking Boris Burkov

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.1789085863.git.boris@bur.io \
    --to=boris@bur.io \
    --cc=kernel-team@fb.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