[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 15/15] RFC: nbd/server: Send 64-bit hole chunk
From: |
Eric Blake |
Subject: |
[PATCH v2 15/15] RFC: nbd/server: Send 64-bit hole chunk |
Date: |
Mon, 14 Nov 2022 16:48:48 -0600 |
Since we cap NBD_CMD_READ requests to 32M, we never have a reason to
send a 64-bit chunk type for a hole; but it is worth producing these
for interoperability testing of clients that want extended headers.
---
nbd/server.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/nbd/server.c b/nbd/server.c
index cd280f1721..04cb172f97 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -2112,9 +2112,13 @@ static int coroutine_fn
nbd_co_send_sparse_read(NBDClient *client,
if (status & BDRV_BLOCK_ZERO) {
NBDReply hdr;
NBDStructuredReadHole chunk;
+ NBDStructuredReadHoleExt chunk_ext;
struct iovec iov[] = {
{.iov_base = &hdr},
- {.iov_base = &chunk, .iov_len = sizeof(chunk)},
+ {.iov_base = client->extended_headers ? &chunk_ext
+ : (void *) &chunk,
+ .iov_len = client->extended_headers ? sizeof(chunk_ext)
+ : sizeof(chunk)},
};
trace_nbd_co_send_structured_read_hole(request->handle,
@@ -2122,9 +2126,17 @@ static int coroutine_fn
nbd_co_send_sparse_read(NBDClient *client,
pnum);
set_be_chunk(client, &iov[0],
final ? NBD_REPLY_FLAG_DONE : 0,
- NBD_REPLY_TYPE_OFFSET_HOLE, request, iov[1].iov_len);
- stq_be_p(&chunk.offset, offset + progress);
- stl_be_p(&chunk.length, pnum);
+ client->extended_headers
+ ? NBD_REPLY_TYPE_OFFSET_HOLE_EXT
+ : NBD_REPLY_TYPE_OFFSET_HOLE,
+ request, iov[1].iov_len);
+ if (client->extended_headers) {
+ stq_be_p(&chunk_ext.offset, offset + progress);
+ stq_be_p(&chunk_ext.length, pnum);
+ } else {
+ stq_be_p(&chunk.offset, offset + progress);
+ stl_be_p(&chunk.length, pnum);
+ }
ret = nbd_co_send_iov(client, iov, 2, errp);
} else {
ret = blk_pread(exp->common.blk, offset + progress, pnum,
--
2.38.1
- [libnbd PATCH v2 14/23] info: Expose extended-headers support through nbdinfo, (continued)
- [libnbd PATCH v2 14/23] info: Expose extended-headers support through nbdinfo, Eric Blake, 2022/11/14
- [libnbd PATCH v2 08/23] block_status: Track 64-bit extents internally, Eric Blake, 2022/11/14
- [libnbd PATCH v2 01/23] block_status: Refactor array storage, Eric Blake, 2022/11/14
- [libnbd PATCH v2 05/23] states: Prepare to receive 64-bit replies, Eric Blake, 2022/11/14
- [libnbd PATCH v2 18/23] generator: Actually request extended headers, Eric Blake, 2022/11/14
- [libnbd PATCH v2 20/23] interop: Add test of 64-bit block status, Eric Blake, 2022/11/14
- [libnbd PATCH v2 06/23] states: Break deadlock if server goofs on extended replies, Eric Blake, 2022/11/14
- [libnbd PATCH v2 17/23] ocaml: Add example for 64-bit extents, Eric Blake, 2022/11/14
- [libnbd PATCH v2 07/23] generator: Add struct nbd_extent in prep for 64-bit extents, Eric Blake, 2022/11/14
- [PATCH v2 00/15] qemu patches for 64-bit NBD extensions, Eric Blake, 2022/11/14
- [PATCH v2 15/15] RFC: nbd/server: Send 64-bit hole chunk,
Eric Blake <=
- [PATCH v2 14/15] RFC: nbd/client: Accept 64-bit hole chunks, Eric Blake, 2022/11/14
- [PATCH v2 06/15] nbd/server: Refactor to pass full request around, Eric Blake, 2022/11/14
- [PATCH v2 11/15] nbd/client: Request extended headers during negotiation, Eric Blake, 2022/11/14
- [PATCH v2 12/15] nbd/server: Prepare for per-request filtering of BLOCK_STATUS, Eric Blake, 2022/11/14
- [PATCH v2 13/15] nbd/server: Add FLAG_PAYLOAD support to CMD_BLOCK_STATUS, Eric Blake, 2022/11/14
- [PATCH v2 10/15] nbd/client: Accept 64-bit block status chunks, Eric Blake, 2022/11/14
- [PATCH v2 07/15] nbd/server: Initial support for extended headers, Eric Blake, 2022/11/14
- [PATCH v2 03/15] nbd: Prepare for 64-bit request effect lengths, Eric Blake, 2022/11/14
- [PATCH v2 09/15] nbd/client: Initial support for extended headers, Eric Blake, 2022/11/14
- [PATCH v2 05/15] nbd/server: Refactor handling of request payload, Eric Blake, 2022/11/14