Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4434c33c authored by Chris Mason's avatar Chris Mason
Browse files

Btrfs: fix sleep with spinlock held during unmount



The code to free block groups needs to drop the space info spin lock
before calling btrfs_remove_free_space_cache (which can schedule).

This is safe because at unmount time, nobody else is going to play
with the block groups.

Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 2b1f55b0
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -3157,9 +3157,13 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
		block_group = rb_entry(n, struct btrfs_block_group_cache,
		block_group = rb_entry(n, struct btrfs_block_group_cache,
				       cache_node);
				       cache_node);


		spin_unlock(&info->block_group_cache_lock);
		btrfs_remove_free_space_cache(block_group);
		btrfs_remove_free_space_cache(block_group);
		spin_lock(&info->block_group_cache_lock);

		rb_erase(&block_group->cache_node,
		rb_erase(&block_group->cache_node,
			 &info->block_group_cache_tree);
			 &info->block_group_cache_tree);

		spin_lock(&block_group->space_info->lock);
		spin_lock(&block_group->space_info->lock);
		list_del(&block_group->list);
		list_del(&block_group->list);
		spin_unlock(&block_group->space_info->lock);
		spin_unlock(&block_group->space_info->lock);