• Qu Wenruo's avatar
    btrfs: block-group: refactor how we read one block group item · 9afc6649
    Qu Wenruo authored
    Structure btrfs_block_group has the following members which are
    currently read from on-disk block group item and key:
    
    - length - from item key
    - used
    - flags - from block group item
    
    However for incoming skinny block group tree, we are going to read those
    members from different sources.
    
    This patch will refactor such read by:
    
    - Don't initialize btrfs_block_group::length at allocation
      Caller should initialize them manually.
      Also to avoid possible (well, only two callers) missing
      initialization, add extra ASSERT() in btrfs_add_block_group_cache().
    
    - Refactor length/used/flags initialization into one function
      The new function, fill_one_block_group() will handle the
      initialization of such members.
    
    - Use btrfs_block_group::length to replace key::offset
      Since skinny block group item would have a different meaning for its
      key offset.
    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>
    9afc6649
block-group.c 96.5 KB