qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: berrange@redhat.com, mreitz@redhat.com, kwolf@redhat.com,
	eblake@redhat.com, vsementsov@virtuozzo.com, den@openvz.org
Subject: [Qemu-devel] [PATCH 4/4] block/nbd-client: use non-blocking io channel for nbd negotiation
Date: Mon, 11 Feb 2019 15:56:01 +0300	[thread overview]
Message-ID: <20190211125601.86533-5-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20190211125601.86533-1-vsementsov@virtuozzo.com>

Now negotiation is done in coroutine, so to take benefit of it let's
use non-blocking model.

Note that QIOChannel handle synchronous io calls correctly anyway, so
it's not a problem to send final NBD_CMD_DISC to non-blocking channel
but using sync qio interface, even not in coroutine.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/nbd-client.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index f0ad54ce21..79bc6b7e29 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -1029,7 +1029,7 @@ static int nbd_client_connect(BlockDriverState *bs,
 
     /* NBD handshake */
     logout("session init %s\n", export);
-    qio_channel_set_blocking(QIO_CHANNEL(sioc), true, NULL);
+    qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);
 
     client->info.request_sizes = true;
     client->info.structured_reply = true;
@@ -1072,9 +1072,6 @@ static int nbd_client_connect(BlockDriverState *bs,
         object_ref(OBJECT(client->ioc));
     }
 
-    /* Now that we're connected, set the socket to be non-blocking and
-     * kick the reply mechanism.  */
-    qio_channel_set_blocking(QIO_CHANNEL(sioc), false, NULL);
     client->connection_co = qemu_coroutine_create(nbd_connection_entry, client);
     nbd_client_attach_aio_context(bs, bdrv_get_aio_context(bs));
 
@@ -1083,9 +1080,8 @@ static int nbd_client_connect(BlockDriverState *bs,
 
  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 };
-- 
2.18.0

  parent reply	other threads:[~2019-02-11 12:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-11 12:55 [Qemu-devel] [PATCH 0/4] nbd: non-blocking negotiation Vladimir Sementsov-Ogievskiy
2019-02-11 12:55 ` [Qemu-devel] [PATCH 1/4] io/channel: add qio_channel_get_attached_aio_context() Vladimir Sementsov-Ogievskiy
2019-02-11 21:22   ` Eric Blake
2019-02-12 10:33   ` Daniel P. Berrangé
2019-02-19 12:46     ` Vladimir Sementsov-Ogievskiy
2019-02-11 12:55 ` [Qemu-devel] [PATCH 2/4] nbd/client: do negotiation in coroutine Vladimir Sementsov-Ogievskiy
2019-02-11 21:38   ` Eric Blake
2019-02-19 10:37     ` Vladimir Sementsov-Ogievskiy
2019-02-11 12:56 ` [Qemu-devel] [PATCH 3/4] nbd: do qemu_coroutine_yield during tls handshake Vladimir Sementsov-Ogievskiy
2019-02-11 21:55   ` Eric Blake
2019-02-19 10:40     ` Vladimir Sementsov-Ogievskiy
2019-02-11 12:56 ` Vladimir Sementsov-Ogievskiy [this message]
2019-02-11 22:02   ` [Qemu-devel] [PATCH 4/4] block/nbd-client: use non-blocking io channel for nbd negotiation Eric Blake
2019-02-19 13:18     ` Vladimir Sementsov-Ogievskiy
2019-02-25  6:08       ` Vladimir Sementsov-Ogievskiy
2019-03-06 16:11 ` [Qemu-devel] [PATCH 0/4] nbd: non-blocking negotiation Eric Blake
2019-03-06 16:31   ` Vladimir Sementsov-Ogievskiy

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=20190211125601.86533-5-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=berrange@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).