btrfs: cache folio size and shift in extent_buffer
authorQu Wenruo <wqu@suse.com>
Fri, 5 Jan 2024 05:35:55 +0000 (16:05 +1030)
committerDavid Sterba <dsterba@suse.com>
Mon, 4 Mar 2024 15:24:45 +0000 (16:24 +0100)
commit84cda1a6087d522548b7c8baac886c8e476be152
treee3ea77811e956c32568d549eeaadbf60ac1b09cb
parent4d02b543903f258bec4c8cdcb85ecbbb2a935cb4
btrfs: cache folio size and shift in extent_buffer

After the conversion to folio interfaces (but without the patch to
enable larger folio allocation), there is an LTP report about observable
performance drop on metadata heavy operations.

https://lore.kernel.org/linux-btrfs/202312221750.571925bd-oliver.sang@intel.com/

This drop is caused by the extra code of calculating the
folio_size()/folio_shift(), instead of the old hard coded
PAGE_SIZE/PAGE_SHIFT.

To slightly reduce the overhead, just cache both folio_size and
folio_shift in extent_buffer.

The two new members (u32 folio_size and u8 folio_shift) are stored
inside the holes of extent_buffer. folio_size is shared with len, which
is reduced to u32. The size of eb does not change.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/accessors.c
fs/btrfs/ctree.c
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h