All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, vsementsov@yandex-team.ru
Subject: [PATCH v6 10/17] nbd/server: Enable initial support for extended headers
Date: Tue, 29 Aug 2023 12:58:37 -0500	[thread overview]
Message-ID: <20230829175826.377251-29-eblake@redhat.com> (raw)
In-Reply-To: <20230829175826.377251-19-eblake@redhat.com>

Time to start supporting clients that request extended headers.  Now
we can finally reach the code added across several previous patches.

Even though the NBD spec has been altered to allow us to accept
NBD_CMD_READ larger than the max payload size (provided our response
is a hole or broken up over more than one data chunk), we are not
planning to take advantage of that, and continue to cap NBD_CMD_READ
to 32M regardless of header size.

For NBD_CMD_WRITE_ZEROES and NBD_CMD_TRIM, the block layer already
supports 64-bit operations without any effort on our part.  For
NBD_CMD_BLOCK_STATUS, the client's length is a hint, and the previous
patch took care of implementing the required
NBD_REPLY_TYPE_BLOCK_STATUS_EXT.

We do not yet support clients that want to do request payload
filtering of NBD_CMD_BLOCK_STATUS; that will be added in later
patches, but is not essential for qemu as a client since qemu only
requests the single context base:allocation.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---

v5: add R-b, s/8.1/8.2/

v4: split out parts into earlier patches, rebase to earlier changes,
simplify handling of generic replies, retitle (compare to v3 9/14)
---
 docs/interop/nbd.txt |  1 +
 nbd/server.c         | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/docs/interop/nbd.txt b/docs/interop/nbd.txt
index f5ca25174a6..9aae5e1f294 100644
--- a/docs/interop/nbd.txt
+++ b/docs/interop/nbd.txt
@@ -69,3 +69,4 @@ NBD_CMD_BLOCK_STATUS for "qemu:dirty-bitmap:", NBD_CMD_CACHE
 NBD_CMD_FLAG_FAST_ZERO
 * 5.2: NBD_CMD_BLOCK_STATUS for "qemu:allocation-depth"
 * 7.1: NBD_FLAG_CAN_MULTI_CONN for shareable writable exports
+* 8.2: NBD_OPT_EXTENDED_HEADERS
diff --git a/nbd/server.c b/nbd/server.c
index f5e60b5ab88..c0a5b00b0f0 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -482,6 +482,10 @@ static int nbd_negotiate_handle_export_name(NBDClient *client, bool no_zeroes,
         [10 .. 133]   reserved     (0) [unless no_zeroes]
      */
     trace_nbd_negotiate_handle_export_name();
+    if (client->mode >= NBD_MODE_EXTENDED) {
+        error_setg(errp, "Extended headers already negotiated");
+        return -EINVAL;
+    }
     if (client->optlen > NBD_MAX_STRING_SIZE) {
         error_setg(errp, "Bad length received");
         return -EINVAL;
@@ -1264,6 +1268,10 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
             case NBD_OPT_STRUCTURED_REPLY:
                 if (length) {
                     ret = nbd_reject_length(client, false, errp);
+                } else if (client->mode >= NBD_MODE_EXTENDED) {
+                    ret = nbd_negotiate_send_rep_err(
+                        client, NBD_REP_ERR_EXT_HEADER_REQD, errp,
+                        "extended headers already negotiated");
                 } else if (client->mode >= NBD_MODE_STRUCTURED) {
                     ret = nbd_negotiate_send_rep_err(
                         client, NBD_REP_ERR_INVALID, errp,
@@ -1280,6 +1288,19 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
                                                  errp);
                 break;

+            case NBD_OPT_EXTENDED_HEADERS:
+                if (length) {
+                    ret = nbd_reject_length(client, false, errp);
+                } else if (client->mode >= NBD_MODE_EXTENDED) {
+                    ret = nbd_negotiate_send_rep_err(
+                        client, NBD_REP_ERR_INVALID, errp,
+                        "extended headers already negotiated");
+                } else {
+                    ret = nbd_negotiate_send_rep(client, NBD_REP_ACK, errp);
+                    client->mode = NBD_MODE_EXTENDED;
+                }
+                break;
+
             default:
                 ret = nbd_opt_drop(client, NBD_REP_ERR_UNSUP, errp,
                                    "Unsupported option %" PRIu32 " (%s)",
-- 
2.41.0



  parent reply	other threads:[~2023-08-29 18:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 17:58 [PATCH v6 00/17] qemu patches for 64-bit NBD extensions Eric Blake
2023-08-29 17:58 ` [PATCH v6 01/17] nbd: Replace bool structured_reply with mode enum Eric Blake
2023-09-04 15:23   ` Vladimir Sementsov-Ogievskiy
2023-08-29 17:58 ` [PATCH v6 02/17] nbd/client: Pass mode through to nbd_send_request Eric Blake
2023-08-29 17:58 ` [PATCH v6 03/17] nbd: Add types for extended headers Eric Blake
2023-08-29 17:58 ` [PATCH v6 04/17] nbd: Prepare for 64-bit request effect lengths Eric Blake
2023-09-04 16:15   ` Vladimir Sementsov-Ogievskiy
2023-09-05 14:24     ` Eric Blake
2023-09-05 14:41       ` Vladimir Sementsov-Ogievskiy
2023-09-06 17:18         ` Eric Blake
2023-08-29 17:58 ` [PATCH v6 05/17] nbd/server: Refactor handling of command sanity checks Eric Blake
2023-09-04 16:53   ` Vladimir Sementsov-Ogievskiy
2023-09-25 19:03     ` Eric Blake
2023-08-29 17:58 ` [PATCH v6 06/17] nbd/server: Support a request payload Eric Blake
2023-09-05 14:36   ` Vladimir Sementsov-Ogievskiy
2023-09-06 17:52     ` Eric Blake
2023-09-08 17:43       ` Eric Blake
2023-08-29 17:58 ` [PATCH v6 07/17] nbd/server: Prepare to receive extended header requests Eric Blake
2023-08-29 17:58 ` [PATCH v6 08/17] nbd/server: Prepare to send extended header replies Eric Blake
2023-08-29 17:58 ` [PATCH v6 09/17] nbd/server: Support 64-bit block status Eric Blake
2023-08-29 17:58 ` Eric Blake [this message]
2023-08-29 17:58 ` [PATCH v6 11/17] nbd/client: Plumb errp through nbd_receive_replies Eric Blake
2023-08-29 17:58 ` [PATCH v6 12/17] nbd/client: Initial support for extended headers Eric Blake
2023-08-29 17:58 ` [PATCH v6 13/17] nbd/client: Accept 64-bit block status chunks Eric Blake
2023-08-29 17:58 ` [PATCH v6 14/17] nbd/client: Request extended headers during negotiation Eric Blake
2023-08-29 17:58 ` [PATCH v6 15/17] nbd/server: Refactor list of negotiated meta contexts Eric Blake
2023-08-29 17:58 ` [PATCH v6 16/17] nbd/server: Prepare for per-request filtering of BLOCK_STATUS Eric Blake
2023-08-29 17:58 ` [PATCH v6 17/17] nbd/server: Add FLAG_PAYLOAD support to CMD_BLOCK_STATUS Eric Blake

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=20230829175826.377251-29-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.