All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Alex Bligh <alex@alex.org.uk>, Wouter Verheist <w@uter.be>,
	nbd list <nbd@other.debian.org>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-devel@nongnu.org, Pavel Borzenkov <pborzenkov@virtuozzo.com>,
	stefanha@redhat.com, "Denis V . Lunev" <den@openvz.org>,
	Markus Pargmann <mpa@pengutronix.de>,
	Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>
Subject: Re: [Qemu-devel] [Nbd] [PATCH] Further tidy-up on block status
Date: Fri, 16 Feb 2018 06:35:47 -0600	[thread overview]
Message-ID: <c2faa919-65c6-d5a3-508d-2f069f2ba61e@redhat.com> (raw)
In-Reply-To: <20161214150840.10899-1-alex@alex.org.uk>

Reviving an old thread, to bring up questions based on a new push to 
implement this extension in qemu.

On 12/14/2016 09:08 AM, Alex Bligh wrote:
> 
> * Change NBD_OPT_LIST_METADATA etc. to explicitly send a list of queries
>    and add a count of queries so we can extend the command later (rather than
>    rely on the length of option)
> 
> * For NBD_OPT_LIST_METADATA make absence of any query (as opposed to zero
>    length query) list all contexts, as absence of any query is now simple.
> 
> * Move definition of namespaces in the document to somewhere more appopriate.
> 
> * Various other minor changes as discussed on the mailing list
> 
> Signed-off-by: Alex Bligh <alex@alex.org.uk>
> ---
>   doc/proto.md | 179 +++++++++++++++++++++++++++++++++++++----------------------
>   1 file changed, 112 insertions(+), 67 deletions(-)
> 

>   
> +Metadata contexts are identified by their names. The name MUST
> +consist of a namespace, followed by a colon, followed by a leaf-name.
> +The namespace and the leaf-name must each consist entirely of
> +printable non-whitespace UTF-8 characters other than colons,
> +and be non-empty. The entire name (namespace, colon and leaf-name)
> +MUST NOT exceed 255 bytes (and therefore botht he namespace and
> +leaf-name are guaranteed to be smaller than 255 bytes).
> +
> +Namespaces MUST be consist of one of the following:
> +- `base`, for metadata contexts defined by this document;
> +- `nbd-server`, for metadata contexts defined by the
> +   implementation that accompanies this document (none
> +   currently);
> +- `x-*`, where `*` can be replaced by any random string not

We're inconsistent on whether extensions are 'x-' or 'X-'; we should 
tighten that up.  (No real impact to implementing things - a server 
should just ignore namespaces it doesn't recognize, regardless of how 
that unknown namespace was spelled).

> +   containing colons, for local experiments. This SHOULD NOT be
> +   used by metadata contexts that are expected to be widely used.
> +- A third-party namespace from the list below.

> @@ -932,51 +961,58 @@ of the newstyle negotiation.
> +    If zero queries are sent, then the server MUST return all
> +    the metadata contexts it knows about.
> +
> +    For details on the query string, see under `NBD_OPT_SET_META_CONTEXT`.
> +
> +    The server MUST either reply with an error (for instance `EINVAL`
> +    if the option is not supported), or reply with a list of
> +    `NBD_REP_META_CONTEXT` replies followed by `NBD_REP_ACK`.
> +    The metadata context ID in these replies is reserved and SHOULD be
> +    set to zero; clients MUST disregard it.

The question came up whether the server is required/permitted to 
diagnose bogus queries (a query for "bad" has no colon, and therefore 
cannot represent any namespace - is that required to be an error, or can 
the server silently ignore it and process the rest of the requests?  Can 
the client rely on the server diagnosing bad requests, or must it be 
prepared for the server to just ignore bad requests?).

Here's my thinking:

A server implementation may want to vet only the first 5 characters of a 
request (because it only supports the namespace "base:").  If that 
server encounters a client asks for context "X-longname:", that is a 
valid request (so we should NOT reply with an error, but merely ignore 
it as an unknown namespace); but if a client asks for namespace 
"garbage", we have the option of whether to return an error.  But for 
both of those client requests, there was no colon in the first 5 
characters.  For a server to robustly distinguish between the two, we 
have to read the entire request and search for a colon, to decide 
whether the missing colon warrants an error reply.  But a client can 
request a name up to 4k in length (the NBD maximum string) - so taking 
the argument to an extreme, we have to manage a 4k string before making 
our decision.  Reading 5 bytes fits easily into the stack, but reading 
4k bytes onto the stack risks skipping the guard page on an OS with 4k 
page sizes, for less-than-stellar handling on stack overflow; and 
reading one byte at a time to check for colon is a pain compared to just 
deciding after 5 bytes that the rest of the string is irrelevant and 
skipping ahead in the data stream to the next point where any useful 
work might be performed.  Thus, I'm arguing that for ease of server 
implementation, we should permit, but not require, the server to 
diagnose ill-formed requests that do not begin with namespace-colon; but 
that we MUST require that the server ignores unknown but well-formed 
requests rather than treating them as errors.

But there is another alternative as well - instead of returning a 
two-part string where colon is the separator, and where the server must 
parse to locate the colon (or lack thereof), would it make sense to 
instead change the NBD_OPT_{LIST,SET}_META_CONTEXT and 
NBD_REP_META_CONTEXT field layout to have two separate length/strings 
per context (first is length/string for namespace, second is 
length/string for leaf name), where colon is no longer special (it is no 
longer possible for a client to pass an ill-formed request that lacks 
colon), and where the server can immediately tell that 'namespace_length 
!= 5, therefore this is a request for a namespace I don't care about'?


> -    These two fields MAY be repeated as much as is necessary to select all
> -    metadata contexts the client is interested in.
> +    - 32 bits, length of export name.
> +    - String, name of export for which we wish to list metadata
> +      contexts.
> +    - 32 bits, number of queries
> +    - Zero or more queries, each being:
> +       - 32 bits, length of query
> +       - String, query to select metadata contexts. The syntax of this
> +         query is implementation-defined, except that it MUST start with a
> +         namespace and a colon.
> +

Also, is 32 bits as the length of the query really necessary?  Given 
that NBD strings are capped at 4k, a 16-bit length is sufficient.  It's 
not like we have padding to get things to natural alignments (if it were 
a matter of always sending 32-bit or 64-bit quantities on natural 
alignments, we'd have padding in a lot more places).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  parent reply	other threads:[~2018-02-16 12:36 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-14 15:08 [Qemu-devel] [PATCH] Further tidy-up on block status Alex Bligh
2016-12-14 16:25 ` Vladimir Sementsov-Ogievskiy
2016-12-14 16:38   ` Alex Bligh
2016-12-14 17:05     ` Vladimir Sementsov-Ogievskiy
2016-12-14 17:36       ` Alex Bligh
2016-12-14 17:55         ` Vladimir Sementsov-Ogievskiy
2016-12-14 18:13           ` [Qemu-devel] [Nbd] " Wouter Verhelst
2016-12-14 18:18             ` Alex Bligh
2016-12-14 18:49               ` Wouter Verhelst
2016-12-14 19:01                 ` Alex Bligh
2016-12-14 20:10                   ` Wouter Verhelst
2016-12-26 15:57                   ` Vladimir Sementsov-Ogievskiy
2016-12-29 16:08                     ` Alex Bligh
2016-12-29 16:35                       ` Vladimir Sementsov-Ogievskiy
2016-12-14 18:51               ` Alex Bligh
2016-12-14 20:18                 ` Wouter Verhelst
2016-12-15 10:04                   ` Alex Bligh
2016-12-15 15:03                     ` Wouter Verhelst
2016-12-15 16:32                       ` Alex Bligh
2016-12-15 16:49                         ` Wouter Verhelst
2016-12-15 17:34                           ` Alex Bligh
2016-12-16 15:52                             ` Wouter Verhelst
2016-12-16 16:25                               ` Alex Bligh
2016-12-17  8:34                                 ` Wouter Verhelst
2016-12-17  9:41                                   ` Alex Bligh
2016-12-14 18:17           ` [Qemu-devel] " Alex Bligh
2016-12-26 14:52             ` Vladimir Sementsov-Ogievskiy
2016-12-28  0:18               ` [Qemu-devel] [Nbd] " Wouter Verhelst
2016-12-29 16:04                 ` Alex Bligh
2016-12-29 16:28                   ` Vladimir Sementsov-Ogievskiy
2016-12-14 16:58 ` [Qemu-devel] " Eric Blake
2016-12-14 17:03   ` Alex Bligh
2016-12-14 17:09 ` [Qemu-devel] [Nbd] " Wouter Verhelst
2016-12-14 17:33   ` Vladimir Sementsov-Ogievskiy
2016-12-14 17:39   ` Alex Bligh
2016-12-14 20:47   ` John Snow
2018-05-03 16:18   ` Eric Blake
2018-05-03 17:26   ` Eric Blake
2018-05-04  6:40     ` Wouter Verhelst
2016-12-27 14:09 ` [Qemu-devel] " Vladimir Sementsov-Ogievskiy
2016-12-27 15:56   ` Eric Blake
2016-12-29 16:14   ` Alex Bligh
2017-01-11 15:31 ` Vladimir Sementsov-Ogievskiy
2017-01-11 19:00   ` Alex Bligh
2017-01-12  7:05     ` Vladimir Sementsov-Ogievskiy
2017-01-12 13:11       ` Alex Bligh
2017-01-13  9:48         ` Vladimir Sementsov-Ogievskiy
2017-01-13 10:29           ` Alex Bligh
2017-01-16 12:26             ` Vladimir Sementsov-Ogievskiy
2017-01-12 11:43 ` Vladimir Sementsov-Ogievskiy
2017-01-12 13:16   ` Alex Bligh
2017-01-20 17:04 ` Vladimir Sementsov-Ogievskiy
2017-01-20 18:00   ` Alex Bligh
2017-01-20 19:35     ` Eric Blake
2017-01-21 12:25       ` [Qemu-devel] [Nbd] " Wouter Verhelst
2018-02-16 12:35 ` Eric Blake [this message]
2018-02-16 13:53   ` Vladimir Sementsov-Ogievskiy
2018-02-16 16:10     ` Eric Blake
2018-02-28 13:08       ` Wouter Verhelst
2018-02-28 20:26         ` Eric Blake
2018-02-28 20:29           ` Eric Blake
2018-03-01  9:54         ` 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=c2faa919-65c6-d5a3-508d-2f069f2ba61e@redhat.com \
    --to=eblake@redhat.com \
    --cc=alex@alex.org.uk \
    --cc=den@openvz.org \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mpa@pengutronix.de \
    --cc=nbd@other.debian.org \
    --cc=pbonzini@redhat.com \
    --cc=pborzenkov@virtuozzo.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.com \
    --cc=w@uter.be \
    /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.