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: mreitz@redhat.com, kwolf@redhat.com, pbonzini@redhat.com,
	den@openvz.org, vsementsov@virtuozzo.com
Subject: [Qemu-devel] [PATCH 1/5] nbd: strict nbd_wr_syncv
Date: Tue, 16 May 2017 12:45:29 +0300	[thread overview]
Message-ID: <20170516094533.6160-2-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20170516094533.6160-1-vsementsov@virtuozzo.com>

nbd_wr_syncv is called either from coroutine or from client negotiation
code, when socket is in blocking mode. So, -EAGAIN is impossible.

Furthermore, EAGAIN is confusing, as, what to read/write again? With
EAGAIN as a return code we don't know how much data is already
read or written by the function, so in case of EAGAIN the whole
communication is broken.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 nbd/common.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/nbd/common.c b/nbd/common.c
index dccbb8e9de..4db45b3ede 100644
--- a/nbd/common.c
+++ b/nbd/common.c
@@ -20,6 +20,10 @@
 #include "qapi/error.h"
 #include "nbd-internal.h"
 
+/* nbd_wr_syncv
+ * The function may be called from coroutine or from non-coroutine context.
+ * When called from non-coroutine context @ioc must be in blocking mode.
+ */
 ssize_t nbd_wr_syncv(QIOChannel *ioc,
                      struct iovec *iov,
                      size_t niov,
@@ -42,11 +46,8 @@ ssize_t nbd_wr_syncv(QIOChannel *ioc,
             len = qio_channel_writev(ioc, local_iov, nlocal_iov, &local_err);
         }
         if (len == QIO_CHANNEL_ERR_BLOCK) {
-            if (qemu_in_coroutine()) {
-                qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT);
-            } else {
-                return -EAGAIN;
-            }
+            assert(qemu_in_coroutine());
+            qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT);
             continue;
         }
         if (len < 0) {
-- 
2.11.1

  reply	other threads:[~2017-05-16  9:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-16  9:45 [Qemu-devel] [PATCH 0/5] nbd: error path refactoring Vladimir Sementsov-Ogievskiy
2017-05-16  9:45 ` Vladimir Sementsov-Ogievskiy [this message]
2017-05-16  9:45 ` [Qemu-devel] [PATCH 2/5] nbd: read_sync and friends: return 0 on success Vladimir Sementsov-Ogievskiy
2017-05-16  9:45 ` [Qemu-devel] [PATCH 3/5] nbd: add errp parameter to nbd_wr_syncv() Vladimir Sementsov-Ogievskiy
2017-05-16  9:45 ` [Qemu-devel] [PATCH 4/5] nbd: add errp to read_sync, write_sync and drop_sync Vladimir Sementsov-Ogievskiy
2017-05-16  9:45 ` [Qemu-devel] [PATCH 5/5] nbd/client.c: use errp instead of LOG Vladimir Sementsov-Ogievskiy
2017-05-16 11:09   ` [Qemu-devel] [PATCH v2] " Vladimir Sementsov-Ogievskiy
2017-05-16 10:00 ` [Qemu-devel] [PATCH 0/5] nbd: error path refactoring Paolo Bonzini
2017-05-16 11:15   ` Vladimir Sementsov-Ogievskiy
2017-05-16 10:17 ` no-reply

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=20170516094533.6160-2-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@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).