btrfs: subpage: pack all subpage bitmaps into a larger bitmap
authorQu Wenruo <wqu@suse.com>
Tue, 17 Aug 2021 09:38:52 +0000 (17:38 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 26 Oct 2021 17:03:55 +0000 (19:03 +0200)
commit72a69cd030823b0747cbb8fc664cf0c721da0588
treebe17a42b4f58c1488b613bfcb1db37934e6f83a3
parent8481dd80ab1eccbe04334269d668b467e9dfa788
btrfs: subpage: pack all subpage bitmaps into a larger bitmap

Currently we use u16 bitmap to make 4k sectorsize work for 64K page
size.

But this u16 bitmap is not large enough to contain larger page size like
128K, nor is space efficient for 16K page size.

To handle both cases, here we pack all subpage bitmaps into a larger
bitmap, now btrfs_subpage::bitmaps[] will be the ultimate bitmap for
subpage usage.

Each sub-bitmap will has its start bit number recorded in
btrfs_subpage_info::*_start, and its bitmap length will be recorded in
btrfs_subpage_info::bitmap_nr_bits.

All subpage bitmap operations will be converted from using direct u16
operations to bitmap operations, with above *_start calculated.

For 64K page size with 4K sectorsize, this should not cause much
difference.

While for 16K page size, we will only need 1 unsigned long (u32) to
store all the bitmaps, which saves quite some space.

Furthermore, this allows us to support larger page size like 128K and
258K.

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/extent_io.c
fs/btrfs/subpage.c
fs/btrfs/subpage.h