• Qu Wenruo's avatar
    btrfs: subpage: pack all subpage bitmaps into a larger bitmap · 72a69cd0
    Qu Wenruo authored
    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: default avatarQu Wenruo <wqu@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    72a69cd0
subpage.c 20.2 KB