btrfs: get the next extent map during fiemap/lseek more efficiently
authorFilipe Manana <fdmanana@suse.com>
Tue, 11 Oct 2022 12:16:54 +0000 (13:16 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Apr 2023 12:28:38 +0000 (14:28 +0200)
commite19ebc5f9a711fb97835068660fd0bc43aad0f92
tree2cfd33f45ea988801d0250d77c3e88e7340c4ced
parentb28def6ed97045b2f6606940cb3d575b52aea76c
btrfs: get the next extent map during fiemap/lseek more efficiently

commit d47704bd1c78c85831561bcf701b90dd66f811b2 upstream.

At find_delalloc_subrange(), when we need to get the next extent map, we
do a full search on the extent map tree (a red black tree). This is fine
but it's a lot more efficient to simply use rb_next(), which typically
requires iterating over less nodes of the tree and never needs to compare
the ranges of nodes with the one we are looking for.

So add a public helper to extent_map.{h,c} to get the extent map that
immediately follows another extent map, using rb_next(), and use that
helper at find_delalloc_subrange().

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/extent_map.c
fs/btrfs/extent_map.h
fs/btrfs/file.c