block: mark another function as coroutine_fns and GRAPH_UNLOCKED

Mark functions as coroutine_fn when they are only called by other coroutine_fns
and they can suspend.  Because this function operates on a BlockBackend, mark it
GRAPH_UNLOCKED.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20230601115145.196465-6-pbonzini@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Paolo Bonzini 2023-06-01 13:51:38 +02:00 committed by Kevin Wolf
parent e7918e9619
commit 84569a7df3

11
block.c
View File

@ -555,8 +555,9 @@ int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filename,
* On success, return @blk's actual length. * On success, return @blk's actual length.
* Otherwise, return -errno. * Otherwise, return -errno.
*/ */
static int64_t create_file_fallback_truncate(BlockBackend *blk, static int64_t coroutine_fn GRAPH_UNLOCKED
int64_t minimum_size, Error **errp) create_file_fallback_truncate(BlockBackend *blk, int64_t minimum_size,
Error **errp)
{ {
Error *local_err = NULL; Error *local_err = NULL;
int64_t size; int64_t size;
@ -564,14 +565,14 @@ static int64_t create_file_fallback_truncate(BlockBackend *blk,
GLOBAL_STATE_CODE(); GLOBAL_STATE_CODE();
ret = blk_truncate(blk, minimum_size, false, PREALLOC_MODE_OFF, 0, ret = blk_co_truncate(blk, minimum_size, false, PREALLOC_MODE_OFF, 0,
&local_err); &local_err);
if (ret < 0 && ret != -ENOTSUP) { if (ret < 0 && ret != -ENOTSUP) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
return ret; return ret;
} }
size = blk_getlength(blk); size = blk_co_getlength(blk);
if (size < 0) { if (size < 0) {
error_free(local_err); error_free(local_err);
error_setg_errno(errp, -size, error_setg_errno(errp, -size,