]> Git Repo - linux.git/commit
btrfs: do not hold the extent lock for entire read
authorJosef Bacik <[email protected]>
Fri, 16 Aug 2024 19:16:24 +0000 (15:16 -0400)
committerDavid Sterba <[email protected]>
Tue, 10 Sep 2024 14:51:20 +0000 (16:51 +0200)
commitac325fc2aad513072722387a71bf857c938aae4e
treef00b90af5f961b99f3dc2b4af9b28af2d752e5b1
parent07d399cb4e1881bba39910bcb4de68a5bd633e03
btrfs: do not hold the extent lock for entire read

Historically we've held the extent lock throughout the entire read.
There's been a few reasons for this, but it's mostly just caused us
problems.  For example, this prevents us from allowing page faults
during direct io reads, because we could deadlock.  This has forced us
to only allow 4k reads at a time for io_uring NOWAIT requests because we
have no idea if we'll be forced to page fault and thus have to do a
whole lot of work.

On the buffered side we are protected by the page lock, as long as we're
reading things like buffered writes, punch hole, and even direct IO to a
certain degree will get hung up on the page lock while the page is in
flight.

On the direct side we have the dio extent lock, which acts much like the
way the extent lock worked previously to this patch, however just for
direct reads.  This protects direct reads from concurrent direct writes,
while we're protected from buffered writes via the inode lock.

Now that we're protected in all cases, narrow the extent lock to the
part where we're getting the extent map to submit the reads, no longer
holding the extent lock for the entire read operation.  Push the extent
lock down into do_readpage() so that we're only grabbing it when looking
up the extent map.  This portion was contributed by Goldwyn.

Co-developed-by: Goldwyn Rodrigues <[email protected]>
Reviewed-by: Goldwyn Rodrigues <[email protected]>
Signed-off-by: Josef Bacik <[email protected]>
Signed-off-by: David Sterba <[email protected]>
fs/btrfs/compression.c
fs/btrfs/direct-io.c
fs/btrfs/extent_io.c
This page took 0.052097 seconds and 4 git commands to generate.