/* Otherwise, it'll get a reference on the block group pointed to by the cluster and remove the cluster from it.  */
int btrfs_return_cluster_to_free_space(struct btrfs_block_group_cache *block_group, struct btrfs_free_cluster *cluster)
/* Otherwise, it'll get a reference on the block group pointed to by the cluster and remove the cluster from it.  */
int btrfs_return_cluster_to_free_space(struct btrfs_block_group_cache *block_group, struct btrfs_free_cluster *cluster)
{
	int ret;
	spin_lock(&cluster->lock);
	if (!block_group) {
		block_group = cluster->block_group;
		if (!block_group) {
			spin_unlock(&cluster->lock);
			return 0;
		}
	} else if (cluster->block_group != block_group) {
		spin_unlock(&cluster->lock);
		return 0;
	}
	atomic_inc(&block_group->count);
	spin_unlock(&cluster->lock);
	spin_lock(&block_group->tree_lock);
	ret = __btrfs_return_cluster_to_free_space(block_group, cluster);
	spin_unlock(&block_group->tree_lock);
	btrfs_put_block_group(block_group);
	return ret;
}