Commit 4273db18 authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by David Sterba
Browse files

btrfs: zoned: re-flow prepare_allocation_zoned()



Re-flow prepare allocation zoned to make it a bit more readable by
returning early and removing unnecessary indentations.

This patch does not change any functionality.

Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3dcdcb71
Loading
Loading
Loading
Loading
+24 −17
Original line number Diff line number Diff line
@@ -4284,18 +4284,26 @@ static int prepare_allocation_zoned(struct btrfs_fs_info *fs_info,
				    struct find_free_extent_ctl *ffe_ctl,
				    struct btrfs_space_info *space_info)
{
	struct btrfs_block_group *block_group;

	if (ffe_ctl->for_treelog) {
		spin_lock(&fs_info->treelog_bg_lock);
		if (fs_info->treelog_bg)
			ffe_ctl->hint_byte = fs_info->treelog_bg;
		spin_unlock(&fs_info->treelog_bg_lock);
	} else if (ffe_ctl->for_data_reloc) {
		return 0;
	}

	if (ffe_ctl->for_data_reloc) {
		spin_lock(&fs_info->relocation_bg_lock);
		if (fs_info->data_reloc_bg)
			ffe_ctl->hint_byte = fs_info->data_reloc_bg;
		spin_unlock(&fs_info->relocation_bg_lock);
	} else if (ffe_ctl->flags & BTRFS_BLOCK_GROUP_DATA) {
		struct btrfs_block_group *block_group;
		return 0;
	}

	if (!(ffe_ctl->flags & BTRFS_BLOCK_GROUP_DATA))
		return 0;

	spin_lock(&fs_info->zone_active_bgs_lock);
	list_for_each_entry(block_group, &fs_info->zone_active_bgs, active_bg_list) {
@@ -4313,7 +4321,6 @@ static int prepare_allocation_zoned(struct btrfs_fs_info *fs_info,
		}
	}
	spin_unlock(&fs_info->zone_active_bgs_lock);
	}

	return 0;
}