From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: vsementsov@virtuozzo.com, Paolo Bonzini <pbonzini@redhat.com>,
Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
"open list:Network Block Dev..." <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PATCH v2 1/2] nbd: BLOCK_STATUS constants
Date: Mon, 26 Feb 2018 10:57:22 -0600 [thread overview]
Message-ID: <20180226165723.17818-2-eblake@redhat.com> (raw)
In-Reply-To: <20180226165723.17818-1-eblake@redhat.com>
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Expose the new constants and structs that will be used by both
server and client implementations of NBD_CMD_BLOCK_STATUS (the
command is currently experimental at
https://github.com/NetworkBlockDevice/nbd/blob/extension-blockstatus/doc/proto.md
but will hopefully be stabilized soon).
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <1518702707-7077-4-git-send-email-vsementsov@virtuozzo.com>
[eblake: split from larger patch on server implementation]
Signed-off-by: Eric Blake <eblake@redhat.com>
---
include/block/nbd.h | 31 +++++++++++++++++++++++++++++++
nbd/common.c | 10 ++++++++++
2 files changed, 41 insertions(+)
diff --git a/include/block/nbd.h b/include/block/nbd.h
index ef1698914ba..53250d0979c 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -41,6 +41,12 @@ struct NBDOptionReply {
} QEMU_PACKED;
typedef struct NBDOptionReply NBDOptionReply;
+typedef struct NBDOptionReplyMetaContext {
+ NBDOptionReply h; /* h.type = NBD_REP_META_CONTEXT, h.length > 4 */
+ uint32_t context_id;
+ /* meta context name follows */
+} QEMU_PACKED NBDOptionReplyMetaContext;
+
/* Transmission phase structs
*
* Note: these are _NOT_ the same as the network representation of an NBD
@@ -105,6 +111,19 @@ typedef struct NBDStructuredError {
uint16_t message_length;
} QEMU_PACKED NBDStructuredError;
+/* Header of NBD_REPLY_TYPE_BLOCK_STATUS */
+typedef struct NBDStructuredMeta {
+ NBDStructuredReplyChunk h; /* h.length >= 12 (at least one extent) */
+ uint32_t context_id;
+ /* extents follows */
+} QEMU_PACKED NBDStructuredMeta;
+
+/* Extent chunk for NBD_REPLY_TYPE_BLOCK_STATUS */
+typedef struct NBDExtent {
+ uint32_t length;
+ uint32_t flags; /* NBD_STATE_* */
+} QEMU_PACKED NBDExtent;
+
/* Transmission (export) flags: sent from server to client during handshake,
but describe what will happen during transmission */
#define NBD_FLAG_HAS_FLAGS (1 << 0) /* Flags are there */
@@ -136,6 +155,8 @@ typedef struct NBDStructuredError {
#define NBD_OPT_INFO (6)
#define NBD_OPT_GO (7)
#define NBD_OPT_STRUCTURED_REPLY (8)
+#define NBD_OPT_LIST_META_CONTEXT (9)
+#define NBD_OPT_SET_META_CONTEXT (10)
/* Option reply types. */
#define NBD_REP_ERR(value) ((UINT32_C(1) << 31) | (value))
@@ -143,6 +164,7 @@ typedef struct NBDStructuredError {
#define NBD_REP_ACK (1) /* Data sending finished. */
#define NBD_REP_SERVER (2) /* Export description. */
#define NBD_REP_INFO (3) /* NBD_OPT_INFO/GO. */
+#define NBD_REP_META_CONTEXT (4) /* NBD_OPT_{LIST,SET}_META_CONTEXT */
#define NBD_REP_ERR_UNSUP NBD_REP_ERR(1) /* Unknown option */
#define NBD_REP_ERR_POLICY NBD_REP_ERR(2) /* Server denied */
@@ -163,6 +185,8 @@ typedef struct NBDStructuredError {
#define NBD_CMD_FLAG_FUA (1 << 0) /* 'force unit access' during write */
#define NBD_CMD_FLAG_NO_HOLE (1 << 1) /* don't punch hole on zero run */
#define NBD_CMD_FLAG_DF (1 << 2) /* don't fragment structured read */
+#define NBD_CMD_FLAG_REQ_ONE (1 << 3) /* only one extent in BLOCK_STATUS
+ * reply chunk */
/* Supported request types */
enum {
@@ -173,6 +197,7 @@ enum {
NBD_CMD_TRIM = 4,
/* 5 reserved for failed experiment NBD_CMD_CACHE */
NBD_CMD_WRITE_ZEROES = 6,
+ NBD_CMD_BLOCK_STATUS = 7,
};
#define NBD_DEFAULT_PORT 10809
@@ -200,9 +225,15 @@ enum {
#define NBD_REPLY_TYPE_NONE 0
#define NBD_REPLY_TYPE_OFFSET_DATA 1
#define NBD_REPLY_TYPE_OFFSET_HOLE 2
+#define NBD_REPLY_TYPE_BLOCK_STATUS 3
#define NBD_REPLY_TYPE_ERROR NBD_REPLY_ERR(1)
#define NBD_REPLY_TYPE_ERROR_OFFSET NBD_REPLY_ERR(2)
+/* Flags for extents (NBDExtent.flags) of NBD_REPLY_TYPE_BLOCK_STATUS,
+ * for base:allocation meta context */
+#define NBD_STATE_HOLE (1 << 0)
+#define NBD_STATE_ZERO (1 << 1)
+
static inline bool nbd_reply_type_is_error(int type)
{
return type & (1 << 15);
diff --git a/nbd/common.c b/nbd/common.c
index 6295526dd14..8c95c1d606e 100644
--- a/nbd/common.c
+++ b/nbd/common.c
@@ -75,6 +75,10 @@ const char *nbd_opt_lookup(uint32_t opt)
return "go";
case NBD_OPT_STRUCTURED_REPLY:
return "structured reply";
+ case NBD_OPT_LIST_META_CONTEXT:
+ return "list meta context";
+ case NBD_OPT_SET_META_CONTEXT:
+ return "set meta context";
default:
return "<unknown>";
}
@@ -90,6 +94,8 @@ const char *nbd_rep_lookup(uint32_t rep)
return "server";
case NBD_REP_INFO:
return "info";
+ case NBD_REP_META_CONTEXT:
+ return "meta context";
case NBD_REP_ERR_UNSUP:
return "unsupported";
case NBD_REP_ERR_POLICY:
@@ -144,6 +150,8 @@ const char *nbd_cmd_lookup(uint16_t cmd)
return "trim";
case NBD_CMD_WRITE_ZEROES:
return "write zeroes";
+ case NBD_CMD_BLOCK_STATUS:
+ return "block status";
default:
return "<unknown>";
}
@@ -159,6 +167,8 @@ const char *nbd_reply_type_lookup(uint16_t type)
return "data";
case NBD_REPLY_TYPE_OFFSET_HOLE:
return "hole";
+ case NBD_REPLY_TYPE_BLOCK_STATUS:
+ return "block status";
case NBD_REPLY_TYPE_ERROR:
return "generic error";
case NBD_REPLY_TYPE_ERROR_OFFSET:
--
2.14.3
next prev parent reply other threads:[~2018-02-26 16:57 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-15 13:51 [Qemu-devel] [PATCH 0/9] nbd block status base:allocation Vladimir Sementsov-Ogievskiy
2018-02-15 13:51 ` [Qemu-devel] [PATCH 1/9] nbd/server: add nbd_opt_invalid helper Vladimir Sementsov-Ogievskiy
2018-02-15 22:01 ` Eric Blake
2018-03-02 12:40 ` Vladimir Sementsov-Ogievskiy
2018-02-15 13:51 ` [Qemu-devel] [PATCH 2/9] nbd: change indenting in nbd.h Vladimir Sementsov-Ogievskiy
2018-02-15 22:03 ` Eric Blake
2018-02-15 13:51 ` [Qemu-devel] [PATCH 3/9] nbd: BLOCK_STATUS for standard get_block_status function: server part Vladimir Sementsov-Ogievskiy
2018-02-15 23:02 ` Eric Blake
2018-02-16 11:09 ` Vladimir Sementsov-Ogievskiy
2018-02-16 11:45 ` Eric Blake
2018-02-16 13:21 ` Eric Blake
2018-02-16 14:43 ` Vladimir Sementsov-Ogievskiy
2018-02-16 17:01 ` Eric Blake
2018-03-01 11:36 ` Vladimir Sementsov-Ogievskiy
2018-03-02 15:07 ` Vladimir Sementsov-Ogievskiy
2018-02-15 13:51 ` [Qemu-devel] [PATCH 4/9] block/nbd-client: save first fatal error in nbd_iter_error Vladimir Sementsov-Ogievskiy
2018-02-16 17:35 ` Eric Blake
2018-02-15 13:51 ` [Qemu-devel] [PATCH 5/9] nbd/client: fix error messages in nbd_handle_reply_err Vladimir Sementsov-Ogievskiy
2018-02-16 17:38 ` Eric Blake
2018-03-01 11:38 ` Vladimir Sementsov-Ogievskiy
2018-02-15 13:51 ` [Qemu-devel] [PATCH 6/9] nbd: BLOCK_STATUS for standard get_block_status function: client part Vladimir Sementsov-Ogievskiy
2018-02-16 20:40 ` Eric Blake
2018-03-09 18:47 ` Vladimir Sementsov-Ogievskiy
2018-03-12 9:06 ` Vladimir Sementsov-Ogievskiy
2018-03-12 9:23 ` Vladimir Sementsov-Ogievskiy
2018-03-12 9:48 ` Vladimir Sementsov-Ogievskiy
2018-03-12 13:13 ` Vladimir Sementsov-Ogievskiy
2018-03-12 14:00 ` Eric Blake
2018-02-15 13:51 ` [Qemu-devel] [PATCH 7/9] iotests.py: tiny refactor: move system imports up Vladimir Sementsov-Ogievskiy
2018-02-16 20:44 ` Eric Blake
2018-03-09 18:54 ` Vladimir Sementsov-Ogievskiy
2018-02-15 13:51 ` [Qemu-devel] [PATCH 8/9] iotests: add file_path helper Vladimir Sementsov-Ogievskiy
2018-02-16 20:46 ` Eric Blake
2018-02-20 5:42 ` Jeff Cody
2018-03-12 10:04 ` Vladimir Sementsov-Ogievskiy
2018-02-15 13:51 ` [Qemu-devel] [PATCH 9/9] iotests: new test 206 for NBD BLOCK_STATUS Vladimir Sementsov-Ogievskiy
2018-02-16 21:02 ` Eric Blake
2018-03-01 11:51 ` Vladimir Sementsov-Ogievskiy
2018-03-01 18:23 ` Eric Blake
2018-02-22 19:30 ` [Qemu-devel] [PATCH 0/9] nbd block status base:allocation no-reply
2018-02-23 14:02 ` no-reply
2018-02-24 6:48 ` no-reply
2018-02-26 16:57 ` [Qemu-devel] [PATCH v2 0/2] nbd block status initial patches Eric Blake
2018-02-26 16:57 ` Eric Blake [this message]
2018-03-01 12:06 ` [Qemu-devel] [PATCH v2 1/2] nbd: BLOCK_STATUS constants Vladimir Sementsov-Ogievskiy
2018-02-26 16:57 ` [Qemu-devel] [PATCH v2 2/2] nbd/client: fix error messages in nbd_handle_reply_err Eric Blake
2018-03-01 12:10 ` Vladimir Sementsov-Ogievskiy
2018-03-01 18:25 ` Eric Blake
2018-03-09 19:08 ` [Qemu-devel] [PATCH 0/9] nbd block status base:allocation Eric Blake
2018-03-09 19:28 ` Vladimir Sementsov-Ogievskiy
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=20180226165723.17818-2-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.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).