[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 32/32] block/nbd: safer transition to receiving request
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v4 32/32] block/nbd: safer transition to receiving request |
Date: |
Thu, 10 Jun 2021 13:08:02 +0300 |
req->receiving is a flag of request being in one concrete yield point
in nbd_co_do_receive_one_chunk().
Such kind of boolean flag is always better to unset before scheduling
the coroutine, to avoid double scheduling. So, let's be more careful.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
block/nbd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/nbd.c b/block/nbd.c
index 5cfb749e08..3cbee762de 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -150,6 +150,7 @@ static void nbd_recv_coroutines_wake_all(BDRVNBDState *s)
NBDClientRequest *req = &s->requests[i];
if (req->coroutine && req->receiving) {
+ req->receiving = false;
aio_co_wake(req->coroutine);
}
}
@@ -548,6 +549,7 @@ static coroutine_fn void nbd_connection_entry(void *opaque)
* connection_co happens through a bottom half, which can only
* run after we yield.
*/
+ s->requests[i].receiving = false;
aio_co_wake(s->requests[i].coroutine);
qemu_coroutine_yield();
}
@@ -934,7 +936,7 @@ static coroutine_fn int nbd_co_do_receive_one_chunk(
/* Wait until we're woken up by nbd_connection_entry. */
s->requests[i].receiving = true;
qemu_coroutine_yield();
- s->requests[i].receiving = false;
+ assert(!s->requests[i].receiving);
if (!nbd_client_connected(s)) {
error_setg(errp, "Connection closed");
return -EIO;
--
2.29.2
- [PATCH v4 28/32] block/nbd: split nbd_co_do_establish_connection out of nbd_reconnect_attempt, (continued)
- [PATCH v4 28/32] block/nbd: split nbd_co_do_establish_connection out of nbd_reconnect_attempt, Vladimir Sementsov-Ogievskiy, 2021/06/10
- [PATCH v4 23/32] block/nbd: use negotiation of NBDClientConnection, Vladimir Sementsov-Ogievskiy, 2021/06/10
- [PATCH v4 22/32] block/nbd: split nbd_handle_updated_info out of nbd_client_handshake(), Vladimir Sementsov-Ogievskiy, 2021/06/10
- [PATCH v4 14/32] block/nbd: rename NBDConnectThread to NBDClientConnection, Vladimir Sementsov-Ogievskiy, 2021/06/10
- [PATCH v4 26/32] nbd/client-connection: return only one io channel, Vladimir Sementsov-Ogievskiy, 2021/06/10
- [PATCH v4 31/32] block/nbd: add nbd_client_connected() helper, Vladimir Sementsov-Ogievskiy, 2021/06/10
- [PATCH v4 24/32] block/nbd: don't touch s->sioc in nbd_teardown_connection(), Vladimir Sementsov-Ogievskiy, 2021/06/10
- [PATCH v4 29/32] nbd/client-connection: add option for non-blocking connection attempt, Vladimir Sementsov-Ogievskiy, 2021/06/10
- [PATCH v4 30/32] block/nbd: reuse nbd_co_do_establish_connection() in nbd_open(), Vladimir Sementsov-Ogievskiy, 2021/06/10
- [PATCH v4 32/32] block/nbd: safer transition to receiving request,
Vladimir Sementsov-Ogievskiy <=
- Re: [PATCH v4 00/32] block/nbd: rework client connection, Eric Blake, 2021/06/11