From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, edgar.kaziakhmedov@virtuozzo.com,
vsementsov@virtuozzo.com, Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH 4/4] nbd/server: Support requests of additional block sizing info
Date: Tue, 1 May 2018 16:13:36 -0500 [thread overview]
Message-ID: <20180501211336.986372-5-eblake@redhat.com> (raw)
In-Reply-To: <20180501211336.986372-1-eblake@redhat.com>
The NBD spec is clarifying [1] that a server may want to advertise
different limits for READ/WRITE (in our case, 32M) than for
TRIM/ZERO (in our case, nearly 4G). Implement the server
side support for these alternate limits, by always advertising
the new information (a compliant client must ignore a gratuitous
advertisement if it is unknown).
[1] https://lists.debian.org/nbd/2018/03/msg00048.html
Signed-off-by: Eric Blake <eblake@redhat.com>
---
The given URL for the NBD spec was v3; it will change to be a v4
version of that patch in part to point back to this qemu commit
as a proof of implementation.
---
nbd/server.c | 30 ++++++++++++++++++++++++++++++
nbd/trace-events | 2 ++
2 files changed, 32 insertions(+)
diff --git a/nbd/server.c b/nbd/server.c
index 9e1f2271784..39502b58446 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -617,6 +617,36 @@ static int nbd_negotiate_handle_info(NBDClient *client, uint16_t myflags,
return rc;
}
+ /* Send NBD_INFO_TRIM_SIZE always. */
+ /* minimum - Hard-code to 4096 for now, matching preferred block.
+ * TODO: consult blk_bs(blk)->bl.pdiscard_alignment? */
+ sizes[0] = 4096;
+ /* maximum - < 2G (then block layer fragments to bl.max_pdiscard). */
+ sizes[1] = QEMU_ALIGN_DOWN(BDRV_REQUEST_MAX_BYTES, sizes[0]);
+ trace_nbd_negotiate_handle_info_trim_size(sizes[0], sizes[1]);
+ cpu_to_be32s(&sizes[0]);
+ cpu_to_be32s(&sizes[1]);
+ rc = nbd_negotiate_send_info(client, NBD_INFO_TRIM_SIZE,
+ 2 * sizeof(sizes[0]), sizes, errp);
+ if (rc < 0) {
+ return rc;
+ }
+
+ /* Send NBD_INFO_ZERO_SIZE always. */
+ /* minimum - Hard-code to 4096 for now, matching preferred block.
+ * TODO: consult blk_bs(blk)->bl.pwrite_zeroes_alignment? */
+ sizes[0] = 4096;
+ /* maximum - < 2G (then block layer fragments to bl.max_pwrite_zeroes). */
+ sizes[1] = QEMU_ALIGN_DOWN(BDRV_REQUEST_MAX_BYTES, sizes[0]);
+ trace_nbd_negotiate_handle_info_zero_size(sizes[0], sizes[1]);
+ cpu_to_be32s(&sizes[0]);
+ cpu_to_be32s(&sizes[1]);
+ rc = nbd_negotiate_send_info(client, NBD_INFO_ZERO_SIZE,
+ 2 * sizeof(sizes[0]), sizes, errp);
+ if (rc < 0) {
+ return rc;
+ }
+
/* Send NBD_INFO_EXPORT always */
trace_nbd_negotiate_new_style_size_flags(exp->size,
exp->nbdflags | myflags);
diff --git a/nbd/trace-events b/nbd/trace-events
index ddb9d0a2b3e..d8849c43b21 100644
--- a/nbd/trace-events
+++ b/nbd/trace-events
@@ -46,6 +46,8 @@ nbd_negotiate_send_info(int info, const char *name, uint32_t length) "Sending NB
nbd_negotiate_handle_info_requests(int requests) "Client requested %d items of info"
nbd_negotiate_handle_info_request(int request, const char *name) "Client requested info %d (%s)"
nbd_negotiate_handle_info_block_size(uint32_t minimum, uint32_t preferred, uint32_t maximum) "advertising minimum 0x%" PRIx32 ", preferred 0x%" PRIx32 ", maximum 0x%" PRIx32
+nbd_negotiate_handle_info_trim_size(uint32_t minimum, uint32_t maximum) "advertising minimum 0x%" PRIx32 ", maximum 0x%" PRIx32
+nbd_negotiate_handle_info_zero_size(uint32_t minimum, uint32_t maximum) "advertising minimum 0x%" PRIx32 ", maximum 0x%" PRIx32
nbd_negotiate_handle_starttls(void) "Setting up TLS"
nbd_negotiate_handle_starttls_handshake(void) "Starting TLS handshake"
nbd_negotiate_meta_context(const char *optname, const char *export, uint32_t queries) "Client requested %s for export %s, with %" PRIu32 " queries"
--
2.14.3
prev parent reply other threads:[~2018-05-01 21:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-01 21:13 [Qemu-devel] [PATCH 0/4] Support larger NBD_CMD_WRITE_ZEROES Eric Blake
2018-05-01 21:13 ` [Qemu-devel] [PATCH 1/4] nbd: Prepare for additional block sizing info Eric Blake
2018-05-03 8:20 ` Vladimir Sementsov-Ogievskiy
2018-05-01 21:13 ` [Qemu-devel] [PATCH 2/4] nbd/client: Refactor in preparation for more limits Eric Blake
2018-05-03 8:29 ` Vladimir Sementsov-Ogievskiy
2018-05-01 21:13 ` [Qemu-devel] [PATCH 3/4] nbd/client: Support requests of additional block sizing info Eric Blake
2018-05-03 9:17 ` Vladimir Sementsov-Ogievskiy
2018-05-03 14:49 ` Eric Blake
2018-05-03 15:51 ` Vladimir Sementsov-Ogievskiy
2018-05-22 15:33 ` Vladimir Sementsov-Ogievskiy
2018-05-23 15:40 ` Eric Blake
2018-05-01 21:13 ` Eric Blake [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180501211336.986372-5-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=edgar.kaziakhmedov@virtuozzo.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).