diff options
author | Naohiro Aota <naohiro.aota@wdc.com> | 2020-02-25 12:56:21 +0900 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-03-23 17:01:50 +0100 |
commit | baba50624fe57320837cf2aa566769385872d2af (patch) | |
tree | 4d4cb4bf79a7ab1a4ce1b58712d785857d9d75b1 | |
parent | 897cae7948cb06c2f98de3c6f1833e7d8b3daa02 (diff) | |
download | linux-rpi-baba50624fe57320837cf2aa566769385872d2af.tar.gz linux-rpi-baba50624fe57320837cf2aa566769385872d2af.tar.bz2 linux-rpi-baba50624fe57320837cf2aa566769385872d2af.zip |
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: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/extent-tree.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 93d5b5c48185..6d4f53e92833 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -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 we have the needed free extent. @@ -4069,11 +4087,7 @@ have_block_group: btrfs_release_block_group(block_group, delalloc); break; loop: - ffe_ctl.retry_clustered = false; - 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); + release_block_group(block_group, &ffe_ctl, delalloc); cond_resched(); } up_read(&space_info->groups_sem); |