From nobody Tue Feb 10 16:58:07 2026 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.zohomail.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 1505743528656241.57025383191444; Mon, 18 Sep 2017 07:05:28 -0700 (PDT) Received: from localhost ([::1]:36804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtwfv-0006Og-0q for importer@patchew.org; Mon, 18 Sep 2017 10:05:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtwaW-0001nk-Dz for qemu-devel@nongnu.org; Mon, 18 Sep 2017 09:59:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtwaS-0001TY-IF for qemu-devel@nongnu.org; Mon, 18 Sep 2017 09:59:52 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:2677 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 1dtwaS-0001SD-6o for qemu-devel@nongnu.org; Mon, 18 Sep 2017 09:59:48 -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 v8IDxZdY022049; Mon, 18 Sep 2017 16:59:37 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 16:59:32 +0300 Message-Id: <20170918135935.255591-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170918135935.255591-1-vsementsov@virtuozzo.com> References: <20170918135935.255591-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH v2 4/7] block/nbd-client: drop reply field from NBDClientSession 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: kwolf@redhat.com, vsementsov@virtuozzo.com, mreitz@redhat.com, den@openvz.org, 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" Drop 'reply' from NBDClientSession. It's used to only deliver request return code to receiving coroutine. Instead introduce per-request ret variable to simplify the scheme and make further refactoring possible. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/nbd-client.h | 2 +- block/nbd-client.c | 22 +++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/block/nbd-client.h b/block/nbd-client.h index 3f97d31013..4bc8fe3993 100644 --- a/block/nbd-client.h +++ b/block/nbd-client.h @@ -22,6 +22,7 @@ typedef struct { bool receiving; /* waiting for read_reply_co? */ NBDRequest *request; QEMUIOVector *qiov; + int ret; } NBDClientRequest; =20 typedef struct NBDClientSession { @@ -35,7 +36,6 @@ typedef struct NBDClientSession { int in_flight; =20 NBDClientRequest requests[MAX_NBD_REQUESTS]; - NBDReply reply; bool quit; } NBDClientSession; =20 diff --git a/block/nbd-client.c b/block/nbd-client.c index f7b642f079..f331f08a9a 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -74,10 +74,10 @@ static coroutine_fn void nbd_read_reply_entry(void *opa= que) uint64_t i; int ret =3D 0; Error *local_err =3D NULL; + NBDReply reply; =20 while (!s->quit) { - assert(s->reply.handle =3D=3D 0); - ret =3D nbd_receive_reply(s->ioc, &s->reply, &local_err); + ret =3D nbd_receive_reply(s->ioc, &reply, &local_err); if (ret < 0) { error_report_err(local_err); } @@ -89,18 +89,18 @@ static coroutine_fn void nbd_read_reply_entry(void *opa= que) * handler acts as a synchronization point and ensures that only * one coroutine is called until the reply finishes. */ - i =3D HANDLE_TO_INDEX(s, s->reply.handle); + i =3D HANDLE_TO_INDEX(s, reply.handle); if (i >=3D MAX_NBD_REQUESTS || !s->requests[i].coroutine || !s->requests[i].receiving || - s->reply.handle !=3D s->requests[i].request->handle) + reply.handle !=3D s->requests[i].request->handle) { break; } =20 - if (s->reply.error =3D=3D 0 && - s->requests[i].request->type =3D=3D NBD_CMD_READ) - { + s->requests[i].ret =3D -reply.error; + + if (reply.error =3D=3D 0 && s->requests[i].request->type =3D=3D NB= D_CMD_READ) { QEMUIOVector *qiov =3D s->requests[i].qiov; assert(qiov !=3D NULL); assert(s->requests[i].request->len =3D=3D @@ -108,7 +108,7 @@ static coroutine_fn void nbd_read_reply_entry(void *opa= que) if (qio_channel_readv_all(s->ioc, qiov->iov, qiov->niov, NULL) < 0) { - s->reply.error =3D EIO; + s->requests[i].ret =3D -EIO; break; } } @@ -211,11 +211,7 @@ static int nbd_co_receive_reply(NBDClientSession *s, N= BDRequest *request) if (!s->ioc || s->quit) { ret =3D -EIO; } else { - assert(s->reply.handle =3D=3D request->handle); - ret =3D -s->reply.error; - - /* Tell the read handler to read another header. */ - s->reply.handle =3D 0; + ret =3D s->requests[i].ret; } =20 s->requests[i].coroutine =3D NULL; --=20 2.11.1