All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: Stefan Hajnoczi <stefanha@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
	Hanna Reitz <hreitz@redhat.com>
Cc: Sam Li <faithilikerun@gmail.com>,
	Damien Le Moal <dlemoal@kernel.org>,
	Niklas Cassel <cassel@kernel.org>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: [PATCH v5 15/15] block: do not use CoroutineIOCompletion to hold a return value
Date: Fri, 18 Sep 2026 19:29:23 +0200	[thread overview]
Message-ID: <20260918172925.2640888-16-cassel@kernel.org> (raw)
In-Reply-To: <20260918172925.2640888-1-cassel@kernel.org>

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 <stefanha@redhat.com>
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
 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



  parent reply	other threads:[~2026-09-18 17:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18 17:29 [PATCH v5 00/15] block: fix the zone write granularity and the zone append limit Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 01/15] block: widen BlockLimits.zone_size to uint64_t Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 02/15] virtio-blk: do not merge requests across a zone boundary Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 03/15] block: add a helper for the index of the zone an offset falls in Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 04/15] block: add a helper to check if a zone is conventional Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 05/15] hw/block: derive the zone write granularity from the block sizes Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 06/15] virtio-blk: check the write granularity of writes to sequential zones Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 07/15] hw/block: reject a zoned device that the block sizes cannot address Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 08/15] block: reject zone appends that are not a multiple of the sector size Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 09/15] block: reject a zone append that is larger than a zone Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 10/15] file-posix: remove the zone append write granularity check Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 11/15] virtio-blk: add a max-append-sectors property Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 12/15] block: remove BlockLimits.max_append_sectors Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 13/15] file-posix: reject a zone append past the device capacity Niklas Cassel
2026-09-18 17:29 ` [PATCH v5 14/15] file-posix: reject a zone append to a full or conventional zone Niklas Cassel
2026-09-18 17:29 ` Niklas Cassel [this message]
2026-09-18 18:09 ` [PATCH v5 00/15] block: fix the zone write granularity and the zone append limit Niklas Cassel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260918172925.2640888-16-cassel@kernel.org \
    --to=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=faithilikerun@gmail.com \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.