diff options
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 99a8e57da8a1..acf3ed11cfb6 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -10279,22 +10279,25 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) | |||
10279 | block_group = list_first_entry(&fs_info->unused_bgs, | 10279 | block_group = list_first_entry(&fs_info->unused_bgs, |
10280 | struct btrfs_block_group_cache, | 10280 | struct btrfs_block_group_cache, |
10281 | bg_list); | 10281 | bg_list); |
10282 | space_info = block_group->space_info; | ||
10283 | list_del_init(&block_group->bg_list); | 10282 | list_del_init(&block_group->bg_list); |
10283 | |||
10284 | space_info = block_group->space_info; | ||
10285 | |||
10284 | if (ret || btrfs_mixed_space_info(space_info)) { | 10286 | if (ret || btrfs_mixed_space_info(space_info)) { |
10285 | btrfs_put_block_group(block_group); | 10287 | btrfs_put_block_group(block_group); |
10286 | continue; | 10288 | continue; |
10287 | } | 10289 | } |
10288 | spin_unlock(&fs_info->unused_bgs_lock); | 10290 | spin_unlock(&fs_info->unused_bgs_lock); |
10289 | 10291 | ||
10290 | mutex_lock(&root->fs_info->delete_unused_bgs_mutex); | 10292 | mutex_lock(&fs_info->delete_unused_bgs_mutex); |
10291 | 10293 | ||
10292 | /* Don't want to race with allocators so take the groups_sem */ | 10294 | /* Don't want to race with allocators so take the groups_sem */ |
10293 | down_write(&space_info->groups_sem); | 10295 | down_write(&space_info->groups_sem); |
10294 | spin_lock(&block_group->lock); | 10296 | spin_lock(&block_group->lock); |
10295 | if (block_group->reserved || | 10297 | if (block_group->reserved || |
10296 | btrfs_block_group_used(&block_group->item) || | 10298 | btrfs_block_group_used(&block_group->item) || |
10297 | block_group->ro) { | 10299 | block_group->ro || |
10300 | list_is_singular(&block_group->list)) { | ||
10298 | /* | 10301 | /* |
10299 | * We want to bail if we made new allocations or have | 10302 | * We want to bail if we made new allocations or have |
10300 | * outstanding allocations in this block group. We do | 10303 | * outstanding allocations in this block group. We do |
@@ -10410,7 +10413,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) | |||
10410 | end_trans: | 10413 | end_trans: |
10411 | btrfs_end_transaction(trans, root); | 10414 | btrfs_end_transaction(trans, root); |
10412 | next: | 10415 | next: |
10413 | mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); | 10416 | mutex_unlock(&fs_info->delete_unused_bgs_mutex); |
10414 | btrfs_put_block_group(block_group); | 10417 | btrfs_put_block_group(block_group); |
10415 | spin_lock(&fs_info->unused_bgs_lock); | 10418 | spin_lock(&fs_info->unused_bgs_lock); |
10416 | } | 10419 | } |