From nobody Thu May 2 10:56:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14945986980022.884995703868867; Fri, 12 May 2017 07:18:18 -0700 (PDT) Received: from localhost ([::1]:53986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9BOX-0006d7-5f for importer@patchew.org; Fri, 12 May 2017 10:18:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9BNW-0005xG-UU for qemu-devel@nongnu.org; Fri, 12 May 2017 10:17:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9BNT-000191-Qu for qemu-devel@nongnu.org; Fri, 12 May 2017 10:17:10 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:48875 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d9BNT-000172-EQ for qemu-devel@nongnu.org; Fri, 12 May 2017 10:17:07 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4CEH2Wg030602; Fri, 12 May 2017 17:17:03 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 17:17:02 +0300 Message-Id: <20170512141702.12423-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH] nbd: strict nbd_wr_syncv X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: den@openvz.org, vsementsov@virtuozzo.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- Hi all! If I understand right, nbd_wr_syncv is called either from coroutine or from client negotiation code, when socket is in blocking mode. So, some thoughts 1. let's establish this with an assert, because returning EAGAIN is confusing (see above) 2. should we in case of non-coroutine context start this coroutine in=20 nbd_wr_syncv, like in bdrv_prwv_co, and use non-blocking mode? 3. is there any problems or disadvantages of moving client negotiation to coroutine too? 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" =20 +/* 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 =3D qio_channel_writev(ioc, local_iov, nlocal_iov, &local_= err); } if (len =3D=3D 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) { --=20 2.11.1