btrfs: block-group: refactor how we read one block group item
authorQu Wenruo <wqu@suse.com>
Mon, 4 May 2020 23:58:20 +0000 (07:58 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 May 2020 09:25:30 +0000 (11:25 +0200)
commit9afc66498a0b5f76928f9823b58c55c5dfb06ae5
tree4510aaec28a8faffbe622624a0caa4b55708928c
parent83fe9e12b0558eae519351cff00da1e06bc054d2
btrfs: block-group: refactor how we read one block group item

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: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c