Re: [PATCH v3 2/3] btrfs: block-group: Refactor btrfs_read_block_groups()

Anand Jain
2019-10-10T02:52:34Z

On 10/10/19 10:39 AM, Qu Wenruo wrote:
> Refactor the work inside the loop of btrfs_read_block_groups() into one
> separate function, read_one_block_group().
>
> This allows read_one_block_group to be reused for later BG_TREE feature.
>
> The refactor does the following extra fix:
> - Use btrfs_fs_incompat() to replace open-coded feature check
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
> Reviewed-by: Anand Jain <anand.jain@oracle.com>
> ---
> fs/btrfs/block-group.c | 215 +++++++++++++++++++++--------------------
> 1 file changed, 108 insertions(+), 107 deletions(-)
>
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index c906a2b6c2cf..0c5eef0610fa 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -1687,6 +1687,109 @@ static int check_chunk_block_group_mappings(struct btrfs_fs_info *fs_info)
> return ret;
> }
>
> +static int read_one_block_group(struct btrfs_fs_info *info,
> + struct btrfs_path *path,
> + int need_clear)
> +{
> + struct extent_buffer *leaf = path->nodes[0];
> + struct btrfs_block_group_cache *cache;
> + struct btrfs_space_info *space_info;
> + struct btrfs_key key;
> + int mixed = btrfs_fs_incompat(info, MIXED_GROUPS);

nit: mixed can be bool. (David can change while integrating.)

Thanks, Anand