btrfs: reduce chunk_map lookups in btrfs_map_block()
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Tue, 13 Aug 2024 11:36:40 +0000 (13:36 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 10 Sep 2024 14:51:18 +0000 (16:51 +0200)
commit0ae653fbec2b9fbc72c65a0c99528990bfb2136d
tree30caf7c7d1bd5567f80636972bd551903bd9b797
parent6d752cacae5eb8590c98866effaebf67410a9136
btrfs: reduce chunk_map lookups in btrfs_map_block()

Currently we're calling btrfs_num_copies() before btrfs_get_chunk_map() in
btrfs_map_block(). But btrfs_num_copies() itself does a chunk map lookup
to be able to calculate the number of copies.

So split out the code getting the number of copies from btrfs_num_copies()
into a helper called btrfs_chunk_map_num_copies() and directly call it
from btrfs_map_block() and btrfs_num_copies().

This saves us one rbtree lookup per btrfs_map_block() invocation.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c