From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
pbonzini@redhat.com, vsementsov@virtuozzo.com,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v6 10/12] nbd/client: prepare nbd_receive_reply for structured reply
Date: Mon, 13 Nov 2017 13:33:35 -0600 [thread overview]
Message-ID: <025d95af-d978-32a2-6a13-754496b9cc19@redhat.com> (raw)
In-Reply-To: <20171027104037.8319-11-eblake@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3543 bytes --]
On 10/27/2017 05:40 AM, Eric Blake wrote:
> From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>
> In following patch nbd_receive_reply will be used both for simple
> and structured reply header receiving.
> NBDReply is altered into union of simple reply header and structured
> reply chunk header, simple error translation moved to block/nbd-client
> to be consistent with further structured reply error translation.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Signed-off-by: Eric Blake <eblake@redhat.com>
>
> - trace_nbd_receive_reply(magic, reply->error, nbd_err_lookup(reply->error),
> - reply->handle);
> - reply->error = nbd_errno_to_system_errno(reply->error);
> -
> - if (reply->error == ESHUTDOWN) {
> - /* This works even on mingw which lacks a native ESHUTDOWN */
> - error_setg(errp, "server shutting down");
> + trace_nbd_receive_simple_reply(reply->simple.error,
> + nbd_err_lookup(reply->simple.error),
> + reply->handle);
> + if (reply->simple.error == NBD_ESHUTDOWN) {
> + /* This works even on mingw which lacks a native ESHUTDOWN */
> + error_setg(errp, "server shutting down");
> + return -EINVAL;
> + }
> + break;
> + case NBD_STRUCTURED_REPLY_MAGIC:
> + ret = nbd_receive_structured_reply_chunk(ioc, &reply->structured, errp);
> + if (ret < 0) {
> + break;
> + }
> + trace_nbd_receive_structured_reply_chunk(reply->structured.flags,
> + reply->structured.type,
> + reply->structured.handle,
> + reply->structured.length);
> + break;
Ouch. This change means that we now handle NBD_ESHUTDOWN differently if
it was sent as a simple message than if it is sent as a structured reply
chunk. Furthermore, reading the NBD spec:
> On a server shutdown, the server SHOULD wait for inflight requests to be serviced prior to initiating a hard disconnect. A server MAY speed this process up by issuing error replies. The error value issued in respect of these requests and any subsequently received requests SHOULD be ESHUTDOWN.
>
> If the client receives an ESHUTDOWN error it MUST initiate a soft disconnect.
>
> The client MAY issue a soft disconnect at any time, but SHOULD wait until there are no inflight requests first.
We had a pre-existing bug: our behavior in the simple case is wrong - we
are causing a hard disconnect (the server kills the connection) instead
of initiating a soft disconnect (wait for all other pending replies to
come in, then send no further requests other than NBD_CMD_DISC).
A hard disconnect is not the end of the world, even if it is unclean; on
the other hand, not doing a disconnect at all means the client will
continue to see ESHUTDOWN errors until it does shutdown. Meanwhile,
refactoring block/nbd-client.c to properly drain all existing requests
while preventing future requests seems too risky for the 2.11 timeframe.
But I don't like the discrepancy between the two styles, so for 2.11, I
think what I will do is rip out the special-casing of NBD_ESHUTDOWN.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2017-11-13 19:33 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-27 10:40 [Qemu-devel] [PATCH v6 00/12] nbd minimal structured read Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 01/12] nbd: Include error names in trace messages Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 02/12] nbd: Move nbd_errno_to_system_errno() to public header Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 03/12] nbd: Expose constants and structs for structured read Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 04/12] nbd/server: Report error for write to read-only export Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 05/12] nbd/server: Simplify nbd_negotiate_options loop Eric Blake
2017-10-30 16:43 ` Vladimir Sementsov-Ogievskiy
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 06/12] nbd/server: Refactor zero-length option check Eric Blake
2017-10-30 17:22 ` Vladimir Sementsov-Ogievskiy
2017-10-30 20:11 ` Eric Blake
2017-10-30 20:46 ` Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 07/12] nbd: Minimal structured read for server Eric Blake
2017-10-30 17:30 ` Vladimir Sementsov-Ogievskiy
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 08/12] nbd/server: Include human-readable message in structured errors Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 09/12] nbd/client: refactor nbd_receive_starttls Eric Blake
2017-10-30 17:32 ` Vladimir Sementsov-Ogievskiy
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 10/12] nbd/client: prepare nbd_receive_reply for structured reply Eric Blake
2017-11-13 19:33 ` Eric Blake [this message]
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 11/12] nbd: Move nbd_read() to common header Eric Blake
2017-10-27 10:40 ` [Qemu-devel] [PATCH v6 12/12] nbd: Minimal structured read for client Eric Blake
2017-10-30 17:55 ` Vladimir Sementsov-Ogievskiy
2017-10-27 10:45 ` [Qemu-devel] [RFC PATCH v6 13/12] tweak test 83 verbosity Eric Blake
2017-10-30 12:34 ` Vladimir Sementsov-Ogievskiy
2017-10-30 13:00 ` Eric Blake
2017-10-30 18:01 ` Vladimir Sementsov-Ogievskiy
2017-10-27 10:59 ` [Qemu-devel] [PATCH v6 00/12] nbd minimal structured read no-reply
2017-10-27 14:59 ` 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=025d95af-d978-32a2-6a13-754496b9cc19@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).