bdrv_co_zone_report(), bdrv_co_zone_mgmt() and bdrv_co_zone_append() each declare a CoroutineIOCompletion in order to use its ret field, and never touch the coroutine field that the rest of the structure exists for.
That structure is for a request which completes through bdrv_co_io_em_complete(), where the callback has to store the result somewhere and wake the coroutine that is waiting for it. These three call into the driver directly and are already running in the coroutine that wants the result, so there is nothing to wake and nowhere else for the value to live. Use a plain int. bdrv_co_zone_append() already has one. Suggested-by: Stefan Hajnoczi <[email protected]> Signed-off-by: Niklas Cassel <[email protected]> --- block/io.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/block/io.c b/block/io.c index a4fb56f799..c62c3764d3 100644 --- a/block/io.c +++ b/block/io.c @@ -3303,40 +3303,36 @@ int coroutine_fn bdrv_co_zone_report(BlockDriverState *bs, int64_t offset, BlockZoneDescriptor *zones) { BlockDriver *drv = bs->drv; - CoroutineIOCompletion co = { - .coroutine = qemu_coroutine_self(), - }; + int ret; IO_CODE(); bdrv_inc_in_flight(bs); if (!drv || !drv->bdrv_co_zone_report || bs->bl.zoned == BLK_Z_NONE) { - co.ret = -ENOTSUP; + ret = -ENOTSUP; goto out; } - co.ret = drv->bdrv_co_zone_report(bs, offset, nr_zones, zones); + ret = drv->bdrv_co_zone_report(bs, offset, nr_zones, zones); out: bdrv_dec_in_flight(bs); - return co.ret; + return ret; } int coroutine_fn bdrv_co_zone_mgmt(BlockDriverState *bs, BlockZoneOp op, int64_t offset, int64_t len) { BlockDriver *drv = bs->drv; - CoroutineIOCompletion co = { - .coroutine = qemu_coroutine_self(), - }; + int ret; IO_CODE(); bdrv_inc_in_flight(bs); if (!drv || !drv->bdrv_co_zone_mgmt || bs->bl.zoned == BLK_Z_NONE) { - co.ret = -ENOTSUP; + ret = -ENOTSUP; goto out; } - co.ret = drv->bdrv_co_zone_mgmt(bs, op, offset, len); + ret = drv->bdrv_co_zone_mgmt(bs, op, offset, len); out: bdrv_dec_in_flight(bs); - return co.ret; + return ret; } int coroutine_fn bdrv_co_zone_append(BlockDriverState *bs, int64_t *offset, @@ -3345,9 +3341,6 @@ int coroutine_fn bdrv_co_zone_append(BlockDriverState *bs, int64_t *offset, { int ret; BlockDriver *drv = bs->drv; - CoroutineIOCompletion co = { - .coroutine = qemu_coroutine_self(), - }; IO_CODE(); ret = bdrv_check_qiov_request(*offset, qiov->size, qiov, 0, NULL); @@ -3379,13 +3372,13 @@ int coroutine_fn bdrv_co_zone_append(BlockDriverState *bs, int64_t *offset, bdrv_inc_in_flight(bs); if (!drv || !drv->bdrv_co_zone_append || bs->bl.zoned == BLK_Z_NONE) { - co.ret = -ENOTSUP; + ret = -ENOTSUP; goto out; } - co.ret = drv->bdrv_co_zone_append(bs, offset, qiov, flags); + ret = drv->bdrv_co_zone_append(bs, offset, qiov, flags); out: bdrv_dec_in_flight(bs); - return co.ret; + return ret; } uint32_t bdrv_zone_index(BlockDriverState *bs, uint64_t offset) -- 2.55.0
