Commit b271fee9 authored by Naohiro Aota's avatar Naohiro Aota Committed by David Sterba

btrfs: zoned: factor out prepare_allocation_zoned()

Factor out prepare_allocation_zoned() for further extension. While at
it, optimize the if-branch a bit.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent e94dfb7a
...@@ -4298,29 +4298,35 @@ static int prepare_allocation_clustered(struct btrfs_fs_info *fs_info, ...@@ -4298,29 +4298,35 @@ static int prepare_allocation_clustered(struct btrfs_fs_info *fs_info,
return 0; return 0;
} }
static int prepare_allocation(struct btrfs_fs_info *fs_info, static int prepare_allocation_zoned(struct btrfs_fs_info *fs_info,
struct find_free_extent_ctl *ffe_ctl, struct find_free_extent_ctl *ffe_ctl)
struct btrfs_space_info *space_info,
struct btrfs_key *ins)
{ {
switch (ffe_ctl->policy) {
case BTRFS_EXTENT_ALLOC_CLUSTERED:
return prepare_allocation_clustered(fs_info, ffe_ctl,
space_info, ins);
case BTRFS_EXTENT_ALLOC_ZONED:
if (ffe_ctl->for_treelog) { if (ffe_ctl->for_treelog) {
spin_lock(&fs_info->treelog_bg_lock); spin_lock(&fs_info->treelog_bg_lock);
if (fs_info->treelog_bg) if (fs_info->treelog_bg)
ffe_ctl->hint_byte = fs_info->treelog_bg; ffe_ctl->hint_byte = fs_info->treelog_bg;
spin_unlock(&fs_info->treelog_bg_lock); spin_unlock(&fs_info->treelog_bg_lock);
} } else if (ffe_ctl->for_data_reloc) {
if (ffe_ctl->for_data_reloc) {
spin_lock(&fs_info->relocation_bg_lock); spin_lock(&fs_info->relocation_bg_lock);
if (fs_info->data_reloc_bg) if (fs_info->data_reloc_bg)
ffe_ctl->hint_byte = fs_info->data_reloc_bg; ffe_ctl->hint_byte = fs_info->data_reloc_bg;
spin_unlock(&fs_info->relocation_bg_lock); spin_unlock(&fs_info->relocation_bg_lock);
} }
return 0; return 0;
}
static int prepare_allocation(struct btrfs_fs_info *fs_info,
struct find_free_extent_ctl *ffe_ctl,
struct btrfs_space_info *space_info,
struct btrfs_key *ins)
{
switch (ffe_ctl->policy) {
case BTRFS_EXTENT_ALLOC_CLUSTERED:
return prepare_allocation_clustered(fs_info, ffe_ctl,
space_info, ins);
case BTRFS_EXTENT_ALLOC_ZONED:
return prepare_allocation_zoned(fs_info, ffe_ctl);
default: default:
BUG(); BUG();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment