[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 32/33] block/nbd: safer transition to receiving request
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v3 32/33] block/nbd: safer transition to receiving request |
Date: |
Fri, 16 Apr 2021 11:09:10 +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>
---
block/nbd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index 6cc563e13d..03391bb231 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -152,6 +152,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);
}
}
@@ -552,6 +553,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();
}
@@ -614,7 +616,7 @@ static int nbd_co_send_request(BlockDriverState *bs,
if (qiov) {
qio_channel_set_cork(s->ioc, true);
rc = nbd_send_request(s->ioc, request);
- if (nbd_clinet_connected(s) && rc >= 0) {
+ if (nbd_client_connected(s) && rc >= 0) {
if (qio_channel_writev_all(s->ioc, qiov->iov, qiov->niov,
NULL) < 0) {
rc = -EIO;
@@ -938,7 +940,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
- Re: [PATCH v3 21/33] qemu-socket: pass monitor link to socket_get_fd directly, (continued)
- [PATCH v3 26/33] block-coroutine-wrapper: allow non bdrv_ prefix, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 29/33] nbd/client-connection: add option for non-blocking connection attempt, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 22/33] block/nbd: pass monitor directly to connection thread, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 30/33] block/nbd: reuse nbd_co_do_establish_connection() in nbd_open(), Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 20/33] block/nbd: use negotiation of NBDClientConnection, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 25/33] nbd/client-connection: return only one io channel, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 33/33] block/nbd: drop connection_co, Vladimir Sementsov-Ogievskiy, 2021/04/16
- [PATCH v3 32/33] block/nbd: safer transition to receiving request,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v3 31/33] block/nbd: add nbd_clinent_connected() helper, Vladimir Sementsov-Ogievskiy, 2021/04/16