From patchwork Mon Jun 20 23:39:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9189031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8EC836075F for ; Mon, 20 Jun 2016 23:40:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E9B527CDF for ; Mon, 20 Jun 2016 23:40:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7377E27E66; Mon, 20 Jun 2016 23:40:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E060727E63 for ; Mon, 20 Jun 2016 23:40:32 +0000 (UTC) Received: from localhost ([::1]:47086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF8nv-0006gj-Qy for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Jun 2016 19:40:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF8nD-0006Uf-Jq for qemu-devel@nongnu.org; Mon, 20 Jun 2016 19:39:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF8n3-0002Uk-OP for qemu-devel@nongnu.org; Mon, 20 Jun 2016 19:39:47 -0400 Received: from resqmta-po-06v.sys.comcast.net ([2001:558:fe16:19:96:114:154:165]:34645) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF8n3-0002UV-Hn for qemu-devel@nongnu.org; Mon, 20 Jun 2016 19:39:37 -0400 Received: from resomta-po-10v.sys.comcast.net ([96.114.154.234]) by resqmta-po-06v.sys.comcast.net with SMTP id F8mUbRRt2BNj9F8n2bMTjQ; Mon, 20 Jun 2016 23:39:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1466465976; bh=G5DhIvmpfQvlbdWiwynhK12smO+ZTOOMKgors4XG5eg=; h=Received:Received:From:To:Subject:Date:Message-Id; b=B7slZi88jcrB6jQNHmnkt50OJwcADaQWB1n8Nmn934b9hYuq9i2kg8INL+FKiMBlC NMS1Xp4nFWdBsu6AqTc1Jte4BRa/1DUacYMhIcVXAJHTo8u1FJsKGtK+uZEhU0rLfr z8E2WyQkLBncFF+nLtYOt3/dA2o2PYxFepZdxGKK1Yn5UwtRKD+oZbLJ4gVobKrIZh Jlo/+lo5jLes6U4C7jVAuF041b2J4W2aqw9+ysh2Toq9UAKOUuABCh+1emnuyHsClh /2VhAzaYhXP2j0rb585TJJPu3NABfWmKprVE3ZaopQI5zqcpLAMDwuiuF6tw8q7ktJ wCg55S9wfJWBQ== Received: from red.redhat.com ([24.10.254.122]) by resomta-po-10v.sys.comcast.net with comcast id 9BfW1t0022fD5rL01BfcaN; Mon, 20 Jun 2016 23:39:36 +0000 From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 20 Jun 2016 17:39:29 -0600 Message-Id: <1466465969-25315-6-git-send-email-eblake@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466465969-25315-1-git-send-email-eblake@redhat.com> References: <1466465969-25315-1-git-send-email-eblake@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:558:fe16:19:96:114:154:165 Subject: [Qemu-devel] [PATCH 5/5] nbd: Drop unused offset parameter 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, Paolo Bonzini , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that NBD relies on the block layer to fragment things, we no longer need to track an offset argument for which fragment of a request we are actually servicing. While at it, use true and false instead of 0 and 1 for a bool parameter. Signed-off-by: Eric Blake --- include/block/nbd.h | 1 - nbd/nbd-internal.h | 4 ++-- block/nbd-client.c | 31 ++++++++++++++++--------------- nbd/common.c | 3 +-- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/include/block/nbd.h b/include/block/nbd.h index eeda3eb..503f514 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -89,7 +89,6 @@ enum { ssize_t nbd_wr_syncv(QIOChannel *ioc, struct iovec *iov, size_t niov, - size_t offset, size_t length, bool do_read); int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags, diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h index 26a9f4d..93a6ca8 100644 --- a/nbd/nbd-internal.h +++ b/nbd/nbd-internal.h @@ -101,14 +101,14 @@ static inline ssize_t read_sync(QIOChannel *ioc, void *buffer, size_t size) * our request/reply. Synchronization is done with recv_coroutine, so * that this is coroutine-safe. */ - return nbd_wr_syncv(ioc, &iov, 1, 0, size, true); + return nbd_wr_syncv(ioc, &iov, 1, size, true); } static inline ssize_t write_sync(QIOChannel *ioc, void *buffer, size_t size) { struct iovec iov = { .iov_base = buffer, .iov_len = size }; - return nbd_wr_syncv(ioc, &iov, 1, 0, size, false); + return nbd_wr_syncv(ioc, &iov, 1, size, false); } struct NBDTLSHandshakeData { diff --git a/block/nbd-client.c b/block/nbd-client.c index 9f023f8..5841a32 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -116,7 +116,7 @@ static void nbd_restart_write(void *opaque) static int nbd_co_send_request(BlockDriverState *bs, struct nbd_request *request, - QEMUIOVector *qiov, int offset) + QEMUIOVector *qiov) { NbdClientSession *s = nbd_get_client_session(bs); AioContext *aio_context; @@ -149,8 +149,8 @@ static int nbd_co_send_request(BlockDriverState *bs, qio_channel_set_cork(s->ioc, true); rc = nbd_send_request(s->ioc, request); if (rc >= 0) { - ret = nbd_wr_syncv(s->ioc, qiov->iov, qiov->niov, - offset, request->len, 0); + ret = nbd_wr_syncv(s->ioc, qiov->iov, qiov->niov, request->len, + false); if (ret != request->len) { rc = -EIO; } @@ -167,8 +167,9 @@ static int nbd_co_send_request(BlockDriverState *bs, } static void nbd_co_receive_reply(NbdClientSession *s, - struct nbd_request *request, struct nbd_reply *reply, - QEMUIOVector *qiov, int offset) + struct nbd_request *request, + struct nbd_reply *reply, + QEMUIOVector *qiov) { int ret; @@ -181,8 +182,8 @@ static void nbd_co_receive_reply(NbdClientSession *s, reply->error = EIO; } else { if (qiov && reply->error == 0) { - ret = nbd_wr_syncv(s->ioc, qiov->iov, qiov->niov, - offset, request->len, 1); + ret = nbd_wr_syncv(s->ioc, qiov->iov, qiov->niov, request->len, + true); if (ret != request->len) { reply->error = EIO; } @@ -230,11 +231,11 @@ int nbd_client_co_readv(BlockDriverState *bs, int64_t sector_num, request.len = nb_sectors * 512; nbd_coroutine_start(client, &request); - ret = nbd_co_send_request(bs, &request, NULL, 0); + ret = nbd_co_send_request(bs, &request, NULL); if (ret < 0) { reply.error = -ret; } else { - nbd_co_receive_reply(client, &request, &reply, qiov, 0); + nbd_co_receive_reply(client, &request, &reply, qiov); } nbd_coroutine_end(client, &request); return -reply.error; @@ -259,11 +260,11 @@ int nbd_client_co_writev(BlockDriverState *bs, int64_t sector_num, request.len = nb_sectors * 512; nbd_coroutine_start(client, &request); - ret = nbd_co_send_request(bs, &request, qiov, 0); + ret = nbd_co_send_request(bs, &request, qiov); if (ret < 0) { reply.error = -ret; } else { - nbd_co_receive_reply(client, &request, &reply, NULL, 0); + nbd_co_receive_reply(client, &request, &reply, NULL); } nbd_coroutine_end(client, &request); return -reply.error; @@ -284,11 +285,11 @@ int nbd_client_co_flush(BlockDriverState *bs) request.len = 0; nbd_coroutine_start(client, &request); - ret = nbd_co_send_request(bs, &request, NULL, 0); + ret = nbd_co_send_request(bs, &request, NULL); if (ret < 0) { reply.error = -ret; } else { - nbd_co_receive_reply(client, &request, &reply, NULL, 0); + nbd_co_receive_reply(client, &request, &reply, NULL); } nbd_coroutine_end(client, &request); return -reply.error; @@ -309,11 +310,11 @@ int nbd_client_co_discard(BlockDriverState *bs, int64_t sector_num, request.len = nb_sectors * 512; nbd_coroutine_start(client, &request); - ret = nbd_co_send_request(bs, &request, NULL, 0); + ret = nbd_co_send_request(bs, &request, NULL); if (ret < 0) { reply.error = -ret; } else { - nbd_co_receive_reply(client, &request, &reply, NULL, 0); + nbd_co_receive_reply(client, &request, &reply, NULL); } nbd_coroutine_end(client, &request); return -reply.error; diff --git a/nbd/common.c b/nbd/common.c index 8ddb2dd..4d8e211 100644 --- a/nbd/common.c +++ b/nbd/common.c @@ -23,7 +23,6 @@ ssize_t nbd_wr_syncv(QIOChannel *ioc, struct iovec *iov, size_t niov, - size_t offset, size_t length, bool do_read) { @@ -35,7 +34,7 @@ ssize_t nbd_wr_syncv(QIOChannel *ioc, nlocal_iov = iov_copy(local_iov, nlocal_iov, iov, niov, - offset, length); + 0, length); while (nlocal_iov > 0) { ssize_t len;