]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit013d5599d58a06f2d0c0760817c8e5ce0bda3238
tree4510aaec28a8faffbe622624a0caa4b55708928c
parentc2105687b40a0c3f3bd7e3138d02569611a0ff2b
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