btrfs: use precalculated sectorsize_bits from fs_info
authorDavid Sterba <dsterba@suse.com>
Wed, 1 Jul 2020 18:45:04 +0000 (20:45 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 8 Dec 2020 14:53:57 +0000 (15:53 +0100)
commitab108d992b1248adfb7c13c1136cab59c944a98c
tree3632b276548fe4abb15b73d675bfcf2c27805b2c
parente940e9a7c793e3fffe6cdef4f849d696c57ed3f7
btrfs: use precalculated sectorsize_bits from fs_info

We do a lot of calculations where we divide or multiply by sectorsize.
We also know and make sure that sectorsize is a power of two, so this
means all divisions can be turned to shifts and avoid eg. expensive
u64/u32 divisions.

The type is u32 as it's more register friendly on x86_64 compared to u8
and the resulting assembly is smaller (movzbl vs movl).

There's also superblock s_blocksize_bits but it's usually one more
pointer dereference farther than fs_info.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c
fs/btrfs/file-item.c
fs/btrfs/free-space-tree.c
fs/btrfs/ordered-data.c
fs/btrfs/scrub.c
fs/btrfs/tests/btrfs-tests.c