OSDN Git Service

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)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Dec 2022 17:00:38 +0000 (18:00 +0100)
commitd47704bd1c78c85831561bcf701b90dd66f811b2
tree86015fb9158eaf12581d6c9829a0e255b4a562cf
parent88074c8b1376ac315ef4a294db82d861df074ef2
btrfs: get the next extent map during fiemap/lseek more efficiently

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>
fs/btrfs/extent_map.c
fs/btrfs/extent_map.h
fs/btrfs/file.c