/* This function will sleep at least once waiting for new free space to show up, and then it will check the block group free space numbers for our min num_bytes. Another option is to have it go ahead and look in the rbtree for a free extent of a given size, but this is a good start.  */
static noinline int wait_block_group_cache_progress(struct btrfs_block_group_cache *cache, u64 num_bytes)
/* This function will sleep at least once waiting for new free space to show up, and then it will check the block group free space numbers for our min num_bytes. Another option is to have it go ahead and look in the rbtree for a free extent of a given size, but this is a good start.  */
static noinline int wait_block_group_cache_progress(struct btrfs_block_group_cache *cache, u64 num_bytes)
{
	struct btrfs_caching_control *caching_ctl;
	DEFINE_WAIT(wait);
	caching_ctl = get_caching_control(cache);
	if (!caching_ctl)
		return 0;
	wait_event(caching_ctl->wait, block_group_cache_done(cache) ||
		   (cache->free_space >= num_bytes));
	put_caching_control(caching_ctl);
	return 0;
}