Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/810259/?format=api
{ "id": 810259, "url": "http://patchwork.ozlabs.org/api/patches/810259/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170905191114.5959-4-eblake@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170905191114.5959-4-eblake@redhat.com>", "list_archive_url": null, "date": "2017-09-05T19:11:14", "name": "[3/3] nbd: Use new qio_channel_*_all() functions", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ebc00073f12f517d258bd35ac90a6e4f7a59539e", "submitter": { "id": 6591, "url": "http://patchwork.ozlabs.org/api/people/6591/?format=api", "name": "Eric Blake", "email": "eblake@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170905191114.5959-4-eblake@redhat.com/mbox/", "series": [ { "id": 1634, "url": "http://patchwork.ozlabs.org/api/series/1634/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1634", "date": "2017-09-05T19:11:12", "name": "nbd: Use common read/write-all qio functions", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/1634/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/810259/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/810259/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com" ], "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xmxJ91Y4sz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 6 Sep 2017 05:15:36 +1000 (AEST)", "from localhost ([::1]:60952 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dpJJu-000347-KG\n\tfor incoming@patchwork.ozlabs.org; Tue, 05 Sep 2017 15:15:34 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:33294)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dpJGA-0000Yd-Gk\n\tfor qemu-devel@nongnu.org; Tue, 05 Sep 2017 15:11:47 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dpJG4-0005cF-Qd\n\tfor qemu-devel@nongnu.org; Tue, 05 Sep 2017 15:11:42 -0400", "from mx1.redhat.com ([209.132.183.28]:21393)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1dpJFt-0005Us-VP; Tue, 05 Sep 2017 15:11:26 -0400", "from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 13B18C08A42E;\n\tTue, 5 Sep 2017 19:11:25 +0000 (UTC)", "from red.redhat.com (ovpn-120-228.rdu2.redhat.com [10.10.120.228])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 70FB27EF81;\n\tTue, 5 Sep 2017 19:11:20 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 13B18C08A42E", "From": "Eric Blake <eblake@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Tue, 5 Sep 2017 14:11:14 -0500", "Message-Id": "<20170905191114.5959-4-eblake@redhat.com>", "In-Reply-To": "<20170905191114.5959-1-eblake@redhat.com>", "References": "<20170905191114.5959-1-eblake@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.13", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tTue, 05 Sep 2017 19:11:25 +0000 (UTC)", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]", "X-Received-From": "209.132.183.28", "Subject": "[Qemu-devel] [PATCH 3/3] nbd: Use new qio_channel_*_all() functions", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "Kevin Wolf <kwolf@redhat.com>, pbonzini@redhat.com, qemu-block@nongnu.org,\n\tMax Reitz <mreitz@redhat.com>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "Rather than open-coding our own read/write-all functions, we\ncan make use of the recently-added qio code. It slightly\nchanges the error message in one of the iotests.\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\n---\n include/block/nbd.h | 2 --\n nbd/nbd-internal.h | 41 +++++++----------------------------------\n block/nbd-client.c | 15 +++++++--------\n nbd/common.c | 45 ---------------------------------------------\n tests/qemu-iotests/083.out | 8 ++++----\n 5 files changed, 18 insertions(+), 93 deletions(-)", "diff": "diff --git a/include/block/nbd.h b/include/block/nbd.h\nindex 040cdd2e60..707fd37575 100644\n--- a/include/block/nbd.h\n+++ b/include/block/nbd.h\n@@ -155,8 +155,6 @@ struct NBDExportInfo {\n };\n typedef struct NBDExportInfo NBDExportInfo;\n\n-ssize_t nbd_rwv(QIOChannel *ioc, struct iovec *iov, size_t niov, size_t length,\n- bool do_read, Error **errp);\n int nbd_receive_negotiate(QIOChannel *ioc, const char *name,\n QCryptoTLSCreds *tlscreds, const char *hostname,\n QIOChannel **outioc, NBDExportInfo *info,\ndiff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h\nindex 03549e3f39..8a609a227f 100644\n--- a/nbd/nbd-internal.h\n+++ b/nbd/nbd-internal.h\n@@ -85,28 +85,14 @@\n static inline int nbd_read_eof(QIOChannel *ioc, void *buffer, size_t size,\n Error **errp)\n {\n- struct iovec iov = { .iov_base = buffer, .iov_len = size };\n- ssize_t ret;\n-\n- /* Sockets are kept in blocking mode in the negotiation phase. After\n- * that, a non-readable socket simply means that another thread stole\n- * our request/reply. Synchronization is done with recv_coroutine, so\n- * that this is coroutine-safe.\n- */\n+ int ret;\n\n assert(size);\n-\n- ret = nbd_rwv(ioc, &iov, 1, size, true, errp);\n- if (ret <= 0) {\n- return ret;\n+ ret = qio_channel_read_all_eof(ioc, buffer, size, errp);\n+ if (ret < 0) {\n+ ret = -EIO;\n }\n-\n- if (ret != size) {\n- error_setg(errp, \"End of file\");\n- return -EINVAL;\n- }\n-\n- return 1;\n+ return ret;\n }\n\n /* nbd_read\n@@ -115,14 +101,7 @@ static inline int nbd_read_eof(QIOChannel *ioc, void *buffer, size_t size,\n static inline int nbd_read(QIOChannel *ioc, void *buffer, size_t size,\n Error **errp)\n {\n- int ret = nbd_read_eof(ioc, buffer, size, errp);\n-\n- if (ret == 0) {\n- ret = -EINVAL;\n- error_setg(errp, \"End of file\");\n- }\n-\n- return ret < 0 ? ret : 0;\n+ return qio_channel_read_all(ioc, buffer, size, errp) < 0 ? -EIO : 0;\n }\n\n /* nbd_write\n@@ -131,13 +110,7 @@ static inline int nbd_read(QIOChannel *ioc, void *buffer, size_t size,\n static inline int nbd_write(QIOChannel *ioc, const void *buffer, size_t size,\n Error **errp)\n {\n- struct iovec iov = { .iov_base = (void *) buffer, .iov_len = size };\n-\n- ssize_t ret = nbd_rwv(ioc, &iov, 1, size, false, errp);\n-\n- assert(ret < 0 || ret == size);\n-\n- return ret < 0 ? ret : 0;\n+ return qio_channel_write_all(ioc, buffer, size, errp) < 0 ? -EIO : 0;\n }\n\n struct NBDTLSHandshakeData {\ndiff --git a/block/nbd-client.c b/block/nbd-client.c\nindex f0dbea24d3..ee7f758e68 100644\n--- a/block/nbd-client.c\n+++ b/block/nbd-client.c\n@@ -121,7 +121,7 @@ static int nbd_co_send_request(BlockDriverState *bs,\n QEMUIOVector *qiov)\n {\n NBDClientSession *s = nbd_get_client_session(bs);\n- int rc, ret, i;\n+ int rc, i;\n\n qemu_co_mutex_lock(&s->send_mutex);\n while (s->in_flight == MAX_NBD_REQUESTS) {\n@@ -156,9 +156,9 @@ static int nbd_co_send_request(BlockDriverState *bs,\n qio_channel_set_cork(s->ioc, true);\n rc = nbd_send_request(s->ioc, request);\n if (rc >= 0 && !s->quit) {\n- ret = nbd_rwv(s->ioc, qiov->iov, qiov->niov, request->len, false,\n- NULL);\n- if (ret != request->len) {\n+ assert(request->len == iov_size(qiov->iov, qiov->niov));\n+ if (qio_channel_writev_all(s->ioc, qiov->iov, qiov->niov,\n+ NULL) < 0) {\n rc = -EIO;\n }\n }\n@@ -184,7 +184,6 @@ static void nbd_co_receive_reply(NBDClientSession *s,\n QEMUIOVector *qiov)\n {\n int i = HANDLE_TO_INDEX(s, request->handle);\n- int ret;\n\n /* Wait until we're woken up by nbd_read_reply_entry. */\n s->requests[i].receiving = true;\n@@ -195,9 +194,9 @@ static void nbd_co_receive_reply(NBDClientSession *s,\n reply->error = EIO;\n } else {\n if (qiov && reply->error == 0) {\n- ret = nbd_rwv(s->ioc, qiov->iov, qiov->niov, request->len, true,\n- NULL);\n- if (ret != request->len) {\n+ assert(request->len == iov_size(qiov->iov, qiov->niov));\n+ if (qio_channel_readv_all(s->ioc, qiov->iov, qiov->niov,\n+ NULL) < 0) {\n reply->error = EIO;\n s->quit = true;\n }\ndiff --git a/nbd/common.c b/nbd/common.c\nindex e288d1b972..59a5316be9 100644\n--- a/nbd/common.c\n+++ b/nbd/common.c\n@@ -20,51 +20,6 @@\n #include \"qapi/error.h\"\n #include \"nbd-internal.h\"\n\n-/* nbd_wr_syncv\n- * The function may be called from coroutine or from non-coroutine context.\n- * When called from non-coroutine context @ioc must be in blocking mode.\n- */\n-ssize_t nbd_rwv(QIOChannel *ioc, struct iovec *iov, size_t niov, size_t length,\n- bool do_read, Error **errp)\n-{\n- ssize_t done = 0;\n- struct iovec *local_iov = g_new(struct iovec, niov);\n- struct iovec *local_iov_head = local_iov;\n- unsigned int nlocal_iov = niov;\n-\n- nlocal_iov = iov_copy(local_iov, nlocal_iov, iov, niov, 0, length);\n-\n- while (nlocal_iov > 0) {\n- ssize_t len;\n- if (do_read) {\n- len = qio_channel_readv(ioc, local_iov, nlocal_iov, errp);\n- } else {\n- len = qio_channel_writev(ioc, local_iov, nlocal_iov, errp);\n- }\n- if (len == QIO_CHANNEL_ERR_BLOCK) {\n- /* errp should not be set */\n- assert(qemu_in_coroutine());\n- qio_channel_yield(ioc, do_read ? G_IO_IN : G_IO_OUT);\n- continue;\n- }\n- if (len < 0) {\n- done = -EIO;\n- goto cleanup;\n- }\n-\n- if (do_read && len == 0) {\n- break;\n- }\n-\n- iov_discard_front(&local_iov, &nlocal_iov, len);\n- done += len;\n- }\n-\n- cleanup:\n- g_free(local_iov_head);\n- return done;\n-}\n-\n /* Discard length bytes from channel. Return -errno on failure and 0 on\n * success */\n int nbd_drop(QIOChannel *ioc, size_t size, Error **errp)\ndiff --git a/tests/qemu-iotests/083.out b/tests/qemu-iotests/083.out\nindex fb71b6f8ad..25dde519e3 100644\n--- a/tests/qemu-iotests/083.out\n+++ b/tests/qemu-iotests/083.out\n@@ -69,12 +69,12 @@ read failed: Input/output error\n\n === Check disconnect 4 reply ===\n\n-End of file\n+Unexpected end-of-file before all bytes were read\n read failed: Input/output error\n\n === Check disconnect 8 reply ===\n\n-End of file\n+Unexpected end-of-file before all bytes were read\n read failed: Input/output error\n\n === Check disconnect before data ===\n@@ -180,12 +180,12 @@ read failed: Input/output error\n\n === Check disconnect 4 reply ===\n\n-End of file\n+Unexpected end-of-file before all bytes were read\n read failed: Input/output error\n\n === Check disconnect 8 reply ===\n\n-End of file\n+Unexpected end-of-file before all bytes were read\n read failed: Input/output error\n\n === Check disconnect before data ===\n", "prefixes": [ "3/3" ] }