aboutsummaryrefslogtreecommitdiff
path: root/block/nbd.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2019-06-18 14:43:21 +0300
committerEric Blake <eblake@redhat.com>2019-08-15 13:22:14 -0500
commita8e2bb6a76c7c661c117327f70f06eb628554230 (patch)
tree6ea29153f1608699a6014101e3e9c10e353dc66d /block/nbd.c
parent962b7b3d4c3aed241ec28ea712ec9079ac98d3ad (diff)
block/nbd: use non-blocking io channel for nbd negotiation
No reason to use blocking channel for negotiation and we'll benefit in further reconnect feature, as qio_channel reads and writes will do qemu_coroutine_yield while waiting for io completion. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190618114328.55249-3-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block/nbd.c')
-rw-r--r--block/nbd.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/block/nbd.c b/block/nbd.c
index c16d02528b..3a243d9de9 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -1175,6 +1175,7 @@ static int nbd_client_connect(BlockDriverState *bs,
Error **errp)
{
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
+ AioContext *aio_context = bdrv_get_aio_context(bs);
int ret;
/*
@@ -1189,15 +1190,16 @@ static int nbd_client_connect(BlockDriverState *bs,
/* NBD handshake */
trace_nbd_client_connect(export);
- qio_channel_set_blocking(QIO_CHANNEL(sioc), true, NULL);
+ qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);
+ qio_channel_attach_aio_context(QIO_CHANNEL(sioc), aio_context);
s->info.request_sizes = true;
s->info.structured_reply = true;
s->info.base_allocation = true;
s->info.x_dirty_bitmap = g_strdup(x_dirty_bitmap);
s->info.name = g_strdup(export ?: "");
- ret = nbd_receive_negotiate(QIO_CHANNEL(sioc), tlscreds, hostname,
- &s->ioc, &s->info, errp);
+ ret = nbd_receive_negotiate(aio_context, QIO_CHANNEL(sioc), tlscreds,
+ hostname, &s->ioc, &s->info, errp);
g_free(s->info.x_dirty_bitmap);
g_free(s->info.name);
if (ret < 0) {
@@ -1231,18 +1233,14 @@ static int nbd_client_connect(BlockDriverState *bs,
object_ref(OBJECT(s->ioc));
}
- qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);
- qio_channel_attach_aio_context(s->ioc, bdrv_get_aio_context(bs));
-
trace_nbd_client_connect_success(export);
return 0;
fail:
/*
- * We have connected, but must fail for other reasons. The
- * connection is still blocking; send NBD_CMD_DISC as a courtesy
- * to the server.
+ * We have connected, but must fail for other reasons.
+ * Send NBD_CMD_DISC as a courtesy to the server.
*/
{
NBDRequest request = { .type = NBD_CMD_DISC };