btrfs: enable large data folio support under CONFIG_BTRFS_EXPERIMENTAL
authorQu Wenruo <wqu@suse.com>
Wed, 23 Apr 2025 08:58:02 +0000 (18:28 +0930)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:53:30 +0000 (23:53 +0200)
commitcc38d178ff33543cdb0bd58cfbb9a7c41372ff75
tree3dd037f6cb3db0a76c51914d2375e1f017bdeb66
parentb769777d927af168b1389388392bfd7dc4e38399
btrfs: enable large data folio support under CONFIG_BTRFS_EXPERIMENTAL

With all the preparation patches already merged, it's pretty easy to
enable large data folios:

- Remove the ASSERT() on folio size in btrfs_end_repair_bio()

- Add a helper to properly set the max folio order
  Currently due to several call sites that are fetching the bitmap
  content directly into an unsigned long, we can only support
  BITS_PER_LONG blocks for each bitmap.

- Call the helper when reading/creating an inode

The support has the following limitations:

- No large folios for data reloc inode
  The relocation code still requires page sized folio.
  But it's not that hot nor common compared to regular buffered ios.

  Will be improved in the future.

- Requires CONFIG_BTRFS_EXPERIMENTAL

- Will require all folio related operations to check if it needs the
  extra btrfs_subpage structure
  Now any folio larger than block size will need btrfs_subpage structure
  handling.

Unfortunately I do not have a physical machine for performance test, but
if everything goes like XFS/EXT4, it should mostly bring single digits
percentage performance improvement in the real world.

Although I believe there are still quite some optimizations to be done,
let's focus on testing the current large data folio support first.

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/Kconfig
fs/btrfs/bio.c
fs/btrfs/btrfs_inode.h
fs/btrfs/inode.c
fs/btrfs/subpage.h