]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: speed up btrfs_get_##bits helpers
authorDavid Sterba <dsterba@suse.com>
Wed, 29 Apr 2020 14:04:44 +0000 (16:04 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 May 2020 09:25:32 +0000 (11:25 +0200)
commit8ff413391e1c1bf8822ac33247ea36f941a6ed86
tree065cbe47769cdc9858ce9ef171dd03e1f25212ad
parent2c6552073c654f69aa787b3fc29a5fe09ea8d955
btrfs: speed up btrfs_get_##bits helpers

The helpers unconditionally call map_private_extent_buffer to get the
address of page containing the requested offset plus the mapping start
and length. Depending on the return value, the fast path uses unaligned
read to get data within a page, or fall back to read_extent_buffer that
can handle reads spanning more pages.

This is all wasteful. We know the number of bytes to read, 1/2/4/8 and
can find out the page. Then simply check if it's contained or the
fallback is needed.

This saves one function call to map_private_extent_buffer and several
unnecessary temporary variables.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/struct-funcs.c