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

btrfs: factor out release_block_group()

Factor out release_block_group() from find_free_extent(). This function
is called when it gives up an allocation from a block group. Each
allocation policy should reset its information for an allocation in
the next block group.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.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 897cae79
...@@ -3693,6 +3693,24 @@ static int do_allocation(struct btrfs_block_group *block_group, ...@@ -3693,6 +3693,24 @@ static int do_allocation(struct btrfs_block_group *block_group,
} }
} }
static void release_block_group(struct btrfs_block_group *block_group,
struct find_free_extent_ctl *ffe_ctl,
int delalloc)
{
switch (ffe_ctl->policy) {
case BTRFS_EXTENT_ALLOC_CLUSTERED:
ffe_ctl->retry_clustered = false;
ffe_ctl->retry_unclustered = false;
break;
default:
BUG();
}
BUG_ON(btrfs_bg_flags_to_raid_index(block_group->flags) !=
ffe_ctl->index);
btrfs_release_block_group(block_group, delalloc);
}
/* /*
* Return >0 means caller needs to re-search for free extent * Return >0 means caller needs to re-search for free extent
* Return 0 means we have the needed free extent. * Return 0 means we have the needed free extent.
...@@ -4069,11 +4087,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, ...@@ -4069,11 +4087,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
btrfs_release_block_group(block_group, delalloc); btrfs_release_block_group(block_group, delalloc);
break; break;
loop: loop:
ffe_ctl.retry_clustered = false; release_block_group(block_group, &ffe_ctl, delalloc);
ffe_ctl.retry_unclustered = false;
BUG_ON(btrfs_bg_flags_to_raid_index(block_group->flags) !=
ffe_ctl.index);
btrfs_release_block_group(block_group, delalloc);
cond_resched(); cond_resched();
} }
up_read(&space_info->groups_sem); up_read(&space_info->groups_sem);
......
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