From nobody Tue Feb 10 09:25:02 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 1505743470811228.37341692387236; Mon, 18 Sep 2017 07:04:30 -0700 (PDT) Received: from localhost ([::1]:36802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtwez-0005dR-SY for importer@patchew.org; Mon, 18 Sep 2017 10:04:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtwaR-0001iL-A0 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 09:59:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtwaN-0001QQ-Ms for qemu-devel@nongnu.org; Mon, 18 Sep 2017 09:59:47 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:37069 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 1dtwaN-0001P3-B3 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 09:59:43 -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 v8IDxZdV022049; 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:29 +0300 Message-Id: <20170918135935.255591-2-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 1/7] block/nbd-client: refactor nbd_co_receive_reply 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" "NBDReply *reply" parameter of nbd_co_receive_reply is used only to pass return value for nbd_co_request (reply.error). Remove it and use function return value instead. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- block/nbd-client.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/block/nbd-client.c b/block/nbd-client.c index ee7f758e68..acd8e5d007 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -178,26 +178,26 @@ err: return rc; } =20 -static void nbd_co_receive_reply(NBDClientSession *s, - NBDRequest *request, - NBDReply *reply, - QEMUIOVector *qiov) +static int nbd_co_receive_reply(NBDClientSession *s, + NBDRequest *request, + QEMUIOVector *qiov) { + int ret; int i =3D HANDLE_TO_INDEX(s, request->handle); =20 /* Wait until we're woken up by nbd_read_reply_entry. */ s->requests[i].receiving =3D true; qemu_coroutine_yield(); s->requests[i].receiving =3D false; - *reply =3D s->reply; - if (reply->handle !=3D request->handle || !s->ioc || s->quit) { - reply->error =3D EIO; + if (s->reply.handle !=3D request->handle || !s->ioc || s->quit) { + ret =3D -EIO; } else { - if (qiov && reply->error =3D=3D 0) { + ret =3D -s->reply.error; + if (qiov && s->reply.error =3D=3D 0) { assert(request->len =3D=3D iov_size(qiov->iov, qiov->niov)); if (qio_channel_readv_all(s->ioc, qiov->iov, qiov->niov, NULL) < 0) { - reply->error =3D EIO; + ret =3D -EIO; s->quit =3D true; } } @@ -217,6 +217,8 @@ static void nbd_co_receive_reply(NBDClientSession *s, s->in_flight--; qemu_co_queue_next(&s->free_sema); qemu_co_mutex_unlock(&s->send_mutex); + + return ret; } =20 static int nbd_co_request(BlockDriverState *bs, @@ -224,7 +226,6 @@ static int nbd_co_request(BlockDriverState *bs, QEMUIOVector *qiov) { NBDClientSession *client =3D nbd_get_client_session(bs); - NBDReply reply; int ret; =20 assert(!qiov || request->type =3D=3D NBD_CMD_WRITE || @@ -232,12 +233,11 @@ static int nbd_co_request(BlockDriverState *bs, ret =3D nbd_co_send_request(bs, request, request->type =3D=3D NBD_CMD_WRITE ? qiov : = NULL); if (ret < 0) { - reply.error =3D -ret; - } else { - nbd_co_receive_reply(client, request, &reply, - request->type =3D=3D NBD_CMD_READ ? qiov : NU= LL); + return ret; } - return -reply.error; + + return nbd_co_receive_reply(client, request, + request->type =3D=3D NBD_CMD_READ ? qiov := NULL); } =20 int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset, --=20 2.11.1