OSDN Git Service

btrfs: cache the failed state when locking extents
authorJosef Bacik <josef@toxicpanda.com>
Fri, 30 Sep 2022 20:45:12 +0000 (16:45 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Dec 2022 17:00:36 +0000 (18:00 +0100)
commit123a7f008c9e2b25b451c116620f1f6c77bd6b2b
tree6049c62d83b5b119bda4b499fdca79188584dfe3
parent9c5c9604631ae5fcdc5124c79d01d75f80b5ffd4
btrfs: cache the failed state when locking extents

Currently if we fail to lock a range we'll return the start of the range
that we failed to lock.  We'll then search down to this range and wait
on any extent states in this range.

However we can avoid this search altogether if we simply cache the
extent_state that had the contention.  We can pass this into
wait_extent_bit() and start from that extent_state without doing the
search.  In the most optimistic case we can avoid all searches, more
likely we'll avoid the initial search and have to perform the search
after we wait on the failed state, or worst case we must search both
times which is what currently happens.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-io-tree.c
fs/btrfs/extent-io-tree.h
fs/btrfs/extent_io.c