Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/831191/?format=api
{ "id": 831191, "url": "http://patchwork.ozlabs.org/api/1.2/patches/831191/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20171027104037.8319-8-eblake@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.2/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": "<20171027104037.8319-8-eblake@redhat.com>", "list_archive_url": null, "date": "2017-10-27T10:40:32", "name": "[v6,07/12] nbd: Minimal structured read for server", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "d61eedeb8a9e142d656dfa3955d44a9a1e59e9c6", "submitter": { "id": 6591, "url": "http://patchwork.ozlabs.org/api/1.2/people/6591/?format=api", "name": "Eric Blake", "email": "eblake@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20171027104037.8319-8-eblake@redhat.com/mbox/", "series": [ { "id": 10552, "url": "http://patchwork.ozlabs.org/api/1.2/series/10552/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=10552", "date": "2017-10-27T10:40:27", "name": "nbd minimal structured read", "version": 6, "mbox": "http://patchwork.ozlabs.org/series/10552/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/831191/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/831191/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 3yNgXs5Cvcz9t2Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 27 Oct 2017 21:46:37 +1100 (AEDT)", "from localhost ([::1]:56568 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 1e829r-0005eG-S0\n\tfor incoming@patchwork.ozlabs.org; Fri, 27 Oct 2017 06:46:35 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:57429)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1e824W-0001MS-6r\n\tfor qemu-devel@nongnu.org; Fri, 27 Oct 2017 06:41:05 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1e824R-0005eI-Pu\n\tfor qemu-devel@nongnu.org; Fri, 27 Oct 2017 06:41:04 -0400", "from mx1.redhat.com ([209.132.183.28]:42780)\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 1e824O-0005as-HV; Fri, 27 Oct 2017 06:40:56 -0400", "from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\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 84337C04AC43;\n\tFri, 27 Oct 2017 10:40:55 +0000 (UTC)", "from red.redhat.com (ovpn-120-166.rdu2.redhat.com [10.10.120.166])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 374395C549;\n\tFri, 27 Oct 2017 10:40:53 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 84337C04AC43", "From": "Eric Blake <eblake@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Fri, 27 Oct 2017 12:40:32 +0200", "Message-Id": "<20171027104037.8319-8-eblake@redhat.com>", "In-Reply-To": "<20171027104037.8319-1-eblake@redhat.com>", "References": "<20171027104037.8319-1-eblake@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.16", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tFri, 27 Oct 2017 10:40:55 +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 v6 07/12] nbd: Minimal structured read for\n\tserver", "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": "pbonzini@redhat.com, vsementsov@virtuozzo.com, qemu-block@nongnu.org", "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": "From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>\n\nMinimal implementation of structured read: one structured reply chunk,\nno segmentation.\nMinimal structured error implementation: no text message.\nSupport DF flag, but just ignore it, as there is no segmentation any\nway.\n\nSigned-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>\nSigned-off-by: Eric Blake <eblake@redhat.com>\n\n---\nv6: only set structured_reply when replying with ack [Vladimir]\nv5: correct DF flag spelling, include errname in trace, handle any bogus\npayload from option\nv4: better _DF flag handling, convert errno to wire format, add\ncomments and tracing, rework structured error for less churn when adding\ntext message later, don't kill connection on redundant client option\n---\n nbd/server.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++------\n nbd/trace-events | 2 ++\n 2 files changed, 99 insertions(+), 10 deletions(-)", "diff": "diff --git a/nbd/server.c b/nbd/server.c\nindex a98f5622c9..5d6d9a2ddd 100644\n--- a/nbd/server.c\n+++ b/nbd/server.c\n@@ -100,6 +100,8 @@ struct NBDClient {\n QTAILQ_ENTRY(NBDClient) next;\n int nb_requests;\n bool closing;\n+\n+ bool structured_reply;\n };\n\n /* That's all folks */\n@@ -768,6 +770,23 @@ static int nbd_negotiate_options(NBDClient *client, uint16_t myflags,\n \"TLS not configured\");\n }\n break;\n+\n+ case NBD_OPT_STRUCTURED_REPLY:\n+ if (length) {\n+ ret = nbd_reject_length(client, length, option, false,\n+ errp);\n+ } else if (client->structured_reply) {\n+ ret = nbd_negotiate_send_rep_err(\n+ client->ioc, NBD_REP_ERR_INVALID, option, errp,\n+ \"structured reply already negotiated\");\n+ } else {\n+ ret = nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK,\n+ option, errp);\n+ client->structured_reply = true;\n+ myflags |= NBD_FLAG_SEND_DF;\n+ }\n+ break;\n+\n default:\n if (nbd_drop(client->ioc, length, errp) < 0) {\n return -EIO;\n@@ -1242,6 +1261,60 @@ static int nbd_co_send_simple_reply(NBDClient *client,\n return nbd_co_send_iov(client, iov, len ? 2 : 1, errp);\n }\n\n+static inline void set_be_chunk(NBDStructuredReplyChunk *chunk, uint16_t flags,\n+ uint16_t type, uint64_t handle, uint32_t length)\n+{\n+ stl_be_p(&chunk->magic, NBD_STRUCTURED_REPLY_MAGIC);\n+ stw_be_p(&chunk->flags, flags);\n+ stw_be_p(&chunk->type, type);\n+ stq_be_p(&chunk->handle, handle);\n+ stl_be_p(&chunk->length, length);\n+}\n+\n+static int coroutine_fn nbd_co_send_structured_read(NBDClient *client,\n+ uint64_t handle,\n+ uint64_t offset,\n+ void *data,\n+ size_t size,\n+ Error **errp)\n+{\n+ NBDStructuredRead chunk;\n+ struct iovec iov[] = {\n+ {.iov_base = &chunk, .iov_len = sizeof(chunk)},\n+ {.iov_base = data, .iov_len = size}\n+ };\n+\n+ trace_nbd_co_send_structured_read(handle, offset, data, size);\n+ set_be_chunk(&chunk.h, NBD_REPLY_FLAG_DONE, NBD_REPLY_TYPE_OFFSET_DATA,\n+ handle, sizeof(chunk) - sizeof(chunk.h) + size);\n+ stq_be_p(&chunk.offset, offset);\n+\n+ return nbd_co_send_iov(client, iov, 2, errp);\n+}\n+\n+static int coroutine_fn nbd_co_send_structured_error(NBDClient *client,\n+ uint64_t handle,\n+ uint32_t error,\n+ Error **errp)\n+{\n+ NBDStructuredError chunk;\n+ int nbd_err = system_errno_to_nbd_errno(error);\n+ struct iovec iov[] = {\n+ {.iov_base = &chunk, .iov_len = sizeof(chunk)},\n+ /* FIXME: Support human-readable error message */\n+ };\n+\n+ assert(nbd_err);\n+ trace_nbd_co_send_structured_error(handle, nbd_err,\n+ nbd_err_lookup(nbd_err));\n+ set_be_chunk(&chunk.h, NBD_REPLY_FLAG_DONE, NBD_REPLY_TYPE_ERROR, handle,\n+ sizeof(chunk) - sizeof(chunk.h));\n+ stl_be_p(&chunk.error, nbd_err);\n+ stw_be_p(&chunk.message_length, 0);\n+\n+ return nbd_co_send_iov(client, iov, 1, errp);\n+}\n+\n /* nbd_co_receive_request\n * Collect a client request. Return 0 if request looks valid, -EIO to drop\n * connection right away, and any other negative value to report an error to\n@@ -1252,6 +1325,7 @@ static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request,\n Error **errp)\n {\n NBDClient *client = req->client;\n+ int valid_flags;\n\n g_assert(qemu_in_coroutine());\n assert(client->recv_coroutine == qemu_coroutine_self());\n@@ -1313,13 +1387,15 @@ static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request,\n (uint64_t)client->exp->size);\n return request->type == NBD_CMD_WRITE ? -ENOSPC : -EINVAL;\n }\n- if (request->flags & ~(NBD_CMD_FLAG_FUA | NBD_CMD_FLAG_NO_HOLE)) {\n- error_setg(errp, \"unsupported flags (got 0x%x)\", request->flags);\n- return -EINVAL;\n+ valid_flags = NBD_CMD_FLAG_FUA;\n+ if (request->type == NBD_CMD_READ && client->structured_reply) {\n+ valid_flags |= NBD_CMD_FLAG_DF;\n+ } else if (request->type == NBD_CMD_WRITE_ZEROES) {\n+ valid_flags |= NBD_CMD_FLAG_NO_HOLE;\n }\n- if (request->type != NBD_CMD_WRITE_ZEROES &&\n- (request->flags & NBD_CMD_FLAG_NO_HOLE)) {\n- error_setg(errp, \"unexpected flags (got 0x%x)\", request->flags);\n+ if (request->flags & ~valid_flags) {\n+ error_setg(errp, \"unsupported flags for command %s (got 0x%x)\",\n+ nbd_cmd_lookup(request->type), request->flags);\n return -EINVAL;\n }\n\n@@ -1457,10 +1533,21 @@ reply:\n local_err = NULL;\n }\n\n- if (nbd_co_send_simple_reply(req->client, request.handle,\n- ret < 0 ? -ret : 0,\n- req->data, reply_data_len, &local_err) < 0)\n- {\n+ if (client->structured_reply && request.type == NBD_CMD_READ) {\n+ if (ret < 0) {\n+ ret = nbd_co_send_structured_error(req->client, request.handle,\n+ -ret, &local_err);\n+ } else {\n+ ret = nbd_co_send_structured_read(req->client, request.handle,\n+ request.from, req->data,\n+ reply_data_len, &local_err);\n+ }\n+ } else {\n+ ret = nbd_co_send_simple_reply(req->client, request.handle,\n+ ret < 0 ? -ret : 0,\n+ req->data, reply_data_len, &local_err);\n+ }\n+ if (ret < 0) {\n error_prepend(&local_err, \"Failed to send reply: \");\n goto disconnect;\n }\ndiff --git a/nbd/trace-events b/nbd/trace-events\nindex ab3d7dad4f..6894f8bbb4 100644\n--- a/nbd/trace-events\n+++ b/nbd/trace-events\n@@ -56,6 +56,8 @@ nbd_receive_request(uint32_t magic, uint16_t flags, uint16_t type, uint64_t from\n nbd_blk_aio_attached(const char *name, void *ctx) \"Export %s: Attaching clients to AIO context %p\\n\"\n nbd_blk_aio_detach(const char *name, void *ctx) \"Export %s: Detaching clients from AIO context %p\\n\"\n nbd_co_send_simple_reply(uint64_t handle, uint32_t error, const char *errname, int len) \"Send simple reply: handle = %\" PRIu64 \", error = %\" PRIu32 \" (%s), len = %d\"\n+nbd_co_send_structured_read(uint64_t handle, uint64_t offset, void *data, size_t size) \"Send structured read data reply: handle = %\" PRIu64 \", offset = %\" PRIu64 \", data = %p, len = %zu\"\n+nbd_co_send_structured_error(uint64_t handle, int err, const char *errname) \"Send structured error reply: handle = %\" PRIu64 \", error = %d (%s)\"\n nbd_co_receive_request_decode_type(uint64_t handle, uint16_t type, const char *name) \"Decoding type: handle = %\" PRIu64 \", type = %\" PRIu16 \" (%s)\"\n nbd_co_receive_request_payload_received(uint64_t handle, uint32_t len) \"Payload received: handle = %\" PRIu64 \", len = %\" PRIu32\n nbd_co_receive_request_cmd_write(uint32_t len) \"Reading %\" PRIu32 \" byte(s)\"\n", "prefixes": [ "v6", "07/12" ] }