All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org, rjones@redhat.com, nsoffer@redhat.com,
	Hanna Reitz <hreitz@redhat.com>
Subject: Re: [PATCH] nbd/server: Advertise MULTI_CONN for shared writable exports
Date: Thu, 28 Oct 2021 16:37:36 +0200	[thread overview]
Message-ID: <YXq1sFMjyn3vbzrA@redhat.com> (raw)
In-Reply-To: <20210827150916.532260-1-eblake@redhat.com>

Am 27.08.2021 um 17:09 hat Eric Blake geschrieben:
> According to the NBD spec, a server advertising
> NBD_FLAG_CAN_MULTI_CONN promises that multiple client connections will
> not see any cache inconsistencies: when properly separated by a single
> flush, actions performed by one client will be visible to another
> client, regardless of which client did the flush.  We satisfy these
> conditions in qemu because our block layer serializes any overlapping
> operations (see bdrv_find_conflicting_request and friends): no matter
> which client performs a flush, parallel requests coming from distinct
> NBD clients will still be well-ordered by the time they are passed on
> to the underlying device, with no caching in qemu proper to allow
> stale results to leak after a flush.
> 
> We don't want to advertise MULTI_CONN when we know that a second
> client can connect (which is the default for qemu-nbd, but not for QMP
> nbd-server-add),

Do you mean when a second client _can't_ connect?

> so it does require a QAPI addition.  But other than
> that, the actual change to advertise the bit for writable servers is
> fairly small.  The harder part of this patch is setting up an iotest
> to demonstrate behavior of multiple NBD clients to a single server.
> It might be possible with parallel qemu-io processes, but concisely
> managing that in shell is painful.

I think it should be fairly straightforward in a Python test case.

Another option is using a single QEMU or QSD instance that has multiple
-blockdev for the same NBD server. For the server these are multiple
clients, even if all connnection come from a single process.

> I found it easier to do by relying
> on the libnbd project's nbdsh, which means this test will be skipped
> on platforms where that is not available.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

> diff --git a/docs/interop/nbd.txt b/docs/interop/nbd.txt
> index 10ce098a29bf..d03910f1e9eb 100644
> --- a/docs/interop/nbd.txt
> +++ b/docs/interop/nbd.txt
> @@ -68,3 +68,4 @@ NBD_CMD_BLOCK_STATUS for "qemu:dirty-bitmap:", NBD_CMD_CACHE
>  * 4.2: NBD_FLAG_CAN_MULTI_CONN for shareable read-only exports,
>  NBD_CMD_FLAG_FAST_ZERO
>  * 5.2: NBD_CMD_BLOCK_STATUS for "qemu:allocation-depth"
> +* 6.2: NBD_FLAG_CAN_MULTI_CONN for shareable writable exports
> diff --git a/docs/tools/qemu-nbd.rst b/docs/tools/qemu-nbd.rst
> index 5643da26e982..81be32164a55 100644
> --- a/docs/tools/qemu-nbd.rst
> +++ b/docs/tools/qemu-nbd.rst
> @@ -138,8 +138,7 @@ driver options if ``--image-opts`` is specified.
>  .. option:: -e, --shared=NUM
> 
>    Allow up to *NUM* clients to share the device (default
> -  ``1``), 0 for unlimited. Safe for readers, but for now,
> -  consistency is not guaranteed between multiple writers.
> +  ``1``), 0 for unlimited.
> 
>  .. option:: -t, --persistent

If qemu-nbd supports a maximum number of connections rather than just a
bool...

> diff --git a/qapi/block-export.json b/qapi/block-export.json
> index 0ed63442a819..b2085a9fdd4c 100644
> --- a/qapi/block-export.json
> +++ b/qapi/block-export.json
> @@ -95,11 +95,15 @@
>  #                    the metadata context name "qemu:allocation-depth" to
>  #                    inspect allocation details. (since 5.2)
>  #
> +# @shared: True if the server should advertise that multiple clients may
> +#          connect, default false. (since 6.2)
> +#
>  # Since: 5.2
>  ##
>  { 'struct': 'BlockExportOptionsNbd',
>    'base': 'BlockExportOptionsNbdBase',
> -  'data': { '*bitmaps': ['str'], '*allocation-depth': 'bool' } }
> +  'data': { '*bitmaps': ['str'], '*allocation-depth': 'bool',
> +             '*shared': 'bool' } }

...wouldn't it be better to mirror this in the QAPI interface?

I think eventually we want to add everything missing to the built-in NBD
server and then change qemu-nbd to use it instead of managing the
connections itself. So I'm not sure if diverging here is a good idea.

Kevin



  parent reply	other threads:[~2021-10-28 14:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 15:09 [PATCH] nbd/server: Advertise MULTI_CONN for shared writable exports Eric Blake
2021-08-27 16:48 ` Richard W.M. Jones
2021-08-27 17:54   ` Eric Blake
2021-08-27 16:58 ` Vladimir Sementsov-Ogievskiy
2021-08-27 18:45   ` Eric Blake
2021-09-01  9:03     ` Vladimir Sementsov-Ogievskiy
2021-09-01  8:39 ` Vladimir Sementsov-Ogievskiy
2021-10-28 14:37 ` Kevin Wolf [this message]
2021-10-29 20:52   ` 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=YXq1sFMjyn3vbzrA@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=nsoffer@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --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 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.