Commit ab094670 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: reduce size and overhead of extent_map_block_end()

At extent_map_block_end() we are calling the inline functions
extent_map_block_start() and extent_map_block_len() multiple times, which
results in expanding their code multiple times, increasing the compiled
code size and repeating the computations those functions do.

Improve this by caching their results in local variables.

The size of the module before this change:

   $ size fs/btrfs/btrfs.ko
      text	   data	    bss	    dec	    hex	filename
   1755770	 163800	  16920	1936490	 1d8c6a	fs/btrfs/btrfs.ko

And after this change:

   $ size fs/btrfs/btrfs.ko
      text	   data	    bss	    dec	    hex	filename
   1755656	 163800	  16920	1936376	 1d8bf8	fs/btrfs/btrfs.ko
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 7fa5230b
...@@ -192,10 +192,13 @@ static inline u64 extent_map_block_len(const struct extent_map *em) ...@@ -192,10 +192,13 @@ static inline u64 extent_map_block_len(const struct extent_map *em)
static inline u64 extent_map_block_end(const struct extent_map *em) static inline u64 extent_map_block_end(const struct extent_map *em)
{ {
if (extent_map_block_start(em) + extent_map_block_len(em) < const u64 block_start = extent_map_block_start(em);
extent_map_block_start(em)) const u64 block_end = block_start + extent_map_block_len(em);
if (block_end < block_start)
return (u64)-1; return (u64)-1;
return extent_map_block_start(em) + extent_map_block_len(em);
return block_end;
} }
static bool can_merge_extent_map(const struct extent_map *em) static bool can_merge_extent_map(const struct extent_map *em)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment