mbox series

[0/3] btrfs: no longer hold the extent lock for the entire read

Message ID cover.1724255475.git.josef@toxicpanda.com (mailing list archive)
Headers show
Series btrfs: no longer hold the extent lock for the entire read | expand

Message

Josef Bacik Aug. 21, 2024, 4:01 p.m. UTC
Hello,

One of the biggest obstacles to switching to iomap is that our extent locking is
a bit wonky.  We've made a lot of progress on the write side to drastically
narrow the scope of the extent lock, but the read side is arguably the most
problematic in that we hold it until the readpage is completed.

This patch series addresses this by no longer holding the lock for the entire
IO.  This is safe on the buffered side because we are protected by the page lock
and the checks for ordered extents when we start the write.

The direct io side is the more problematic side, since we could now end up with
overlapping and concurrent direct writes in direct read ranges.  To solve this
problem I'm introducing a new extent io bit to do range locking for direct IO.
This will work basically the same as the extent lock did before, but only for
direct IO.  We are saved by the normal inode lock and page cache in the mixed
buffered and direct case, so this shouldn't carry the same iomap+locking
reloated woes that the extent lock did.

This will also allow us to remove the page fault restrictions in the direct IO
case, which will be done in a followup series.

I've run this through the CI and a lot of local testing, I'm keeping it small
and targeted because this is a pretty big logical shift for us, so I want to
make sure we get good testing on it before I go doing the other larger projects.
Thanks,

Josef

Josef Bacik (3):
  btrfs: introduce EXTENT_DIO_LOCKED
  btrfs: take the dio extent lock during O_DIRECT operations
  btrfs: do not hold the extent lock for entire read

 fs/btrfs/compression.c    |  2 +-
 fs/btrfs/direct-io.c      | 72 ++++++++++++++++++++------------
 fs/btrfs/extent-io-tree.c | 52 +++++++++++------------
 fs/btrfs/extent-io-tree.h | 38 +++++++++++++++--
 fs/btrfs/extent_io.c      | 88 +++------------------------------------
 5 files changed, 111 insertions(+), 141 deletions(-)