Commit 3dfdb934 authored by Yan Zheng's avatar Yan Zheng Committed by Chris Mason

Btrfs: fix locking issue in btrfs_remove_block_group

We should hold the block_group_cache_lock while modifying the
block groups red-black tree. Thank you,
Signed-off-by: default avatarYan Zheng <zheng.yan@oracle.com>
parent c6e30871
......@@ -5952,9 +5952,11 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
path = btrfs_alloc_path();
BUG_ON(!path);
btrfs_remove_free_space_cache(block_group);
spin_lock(&root->fs_info->block_group_cache_lock);
rb_erase(&block_group->cache_node,
&root->fs_info->block_group_cache_tree);
spin_unlock(&root->fs_info->block_group_cache_lock);
btrfs_remove_free_space_cache(block_group);
down_write(&block_group->space_info->groups_sem);
list_del(&block_group->list);
up_write(&block_group->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