[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 4/7] nbd: Fix struct name for structured reads
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v2 4/7] nbd: Fix struct name for structured reads |
Date: |
Wed, 8 Nov 2017 15:57:00 -0600 |
A closer read of the NBD spec shows that a structured reply chunk
for a hole is not quite identical to the prefix of a data chunk,
because the hole has to also send a 32-bit size field. Although
we do not yet send holes, we should fix the misleading information
in our header and make it easier for a future patch to support
sparse reads.
Signed-off-by: Eric Blake <address@hidden>
---
include/block/nbd.h | 18 +++++++++++++-----
nbd/server.c | 2 +-
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/include/block/nbd.h b/include/block/nbd.h
index 92d1723d7c..113c707a5e 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -86,15 +86,23 @@ typedef union NBDReply {
} QEMU_PACKED;
} NBDReply;
-/* Header of NBD_REPLY_TYPE_OFFSET_DATA, complete NBD_REPLY_TYPE_OFFSET_HOLE */
-typedef struct NBDStructuredRead {
- NBDStructuredReplyChunk h;
+/* Header of chunk for NBD_REPLY_TYPE_OFFSET_DATA */
+typedef struct NBDStructuredReadData {
+ NBDStructuredReplyChunk h; /* h.length >= 9 */
uint64_t offset;
-} QEMU_PACKED NBDStructuredRead;
+ /* At least one byte of data payload follows, calculated from h.length */
+} QEMU_PACKED NBDStructuredReadData;
+
+/* Complete chunk for NBD_REPLY_TYPE_OFFSET_HOLE */
+typedef struct NBDStructuredReadHole {
+ NBDStructuredReplyChunk h; /* h.length == 12 */
+ uint64_t offset;
+ uint32_t length;
+} QEMU_PACKED NBDStructuredReadHole;
/* Header of all NBD_REPLY_TYPE_ERROR* errors */
typedef struct NBDStructuredError {
- NBDStructuredReplyChunk h;
+ NBDStructuredReplyChunk h; /* h.length >= 6 */
uint32_t error;
uint16_t message_length;
} QEMU_PACKED NBDStructuredError;
diff --git a/nbd/server.c b/nbd/server.c
index bcf0cdb47c..6ebb7d9c2e 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1280,7 +1280,7 @@ static int coroutine_fn
nbd_co_send_structured_read(NBDClient *client,
size_t size,
Error **errp)
{
- NBDStructuredRead chunk;
+ NBDStructuredReadData chunk;
struct iovec iov[] = {
{.iov_base = &chunk, .iov_len = sizeof(chunk)},
{.iov_base = data, .iov_len = size}
--
2.13.6
- [Qemu-devel] [PATCH v2 1/7] nbd-client: Fix error message typos, (continued)
- [Qemu-devel] [PATCH v2 1/7] nbd-client: Fix error message typos, Eric Blake, 2017/11/08
- [Qemu-devel] [PATCH v2 3/7] nbd/client: Nicer trace of structured reply, Eric Blake, 2017/11/08
- [Qemu-devel] [PATCH v2 2/7] nbd-client: Refuse read-only client with BDRV_O_RDWR, Eric Blake, 2017/11/08
- [Qemu-devel] [PATCH v2 4/7] nbd: Fix struct name for structured reads,
Eric Blake <=
- [Qemu-devel] [PATCH v2 5/7] nbd-client: Short-circuit 0-length operations, Eric Blake, 2017/11/08
- [Qemu-devel] [PATCH v2 6/7] nbd-client: Stricter enforcing of structured reply spec, Eric Blake, 2017/11/08
- [Qemu-devel] [PATCH v2 7/7] nbd/server: Fix structured read of length 0, Eric Blake, 2017/11/08
- Re: [Qemu-devel] [PATCH v2 0/7] various NBD fixes for 2.11, no-reply, 2017/11/08