From: Eric Blake <eblake@redhat.com>
To: "Richard W.M. Jones" <rjones@redhat.com>
Cc: kwolf@redhat.com, vsementsov@virtuozzo.com,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH v2] nbd/server: Suppress Broken pipe errors on abrupt disconnection
Date: Wed, 17 Nov 2021 09:47:28 -0600 [thread overview]
Message-ID: <20211117154728.6bd6uo622zoentur@redhat.com> (raw)
In-Reply-To: <20210913151936.392705-1-rjones@redhat.com>
Revisiting an older thread
On Mon, Sep 13, 2021 at 04:19:36PM +0100, Richard W.M. Jones wrote:
> $ rm -f /tmp/sock /tmp/pid
> $ qemu-img create -f qcow2 /tmp/disk.qcow2 1M
> $ qemu-nbd -t --format=qcow2 --socket=/tmp/sock --pid-file=/tmp/pid /tmp/disk.qcow2 &
> $ nbdsh -u 'nbd+unix:///?socket=/tmp/sock' -c 'h.get_size()'
> qemu-nbd: Disconnect client, due to: Failed to send reply: Unable to write to socket: Broken pipe
> $ killall qemu-nbd
>
> nbdsh is abruptly dropping the NBD connection here which is a valid
> way to close the connection. It seems unnecessary to print an error
> in this case so this commit suppresses it.
I've investigated this a bit further, and found that we have a
regression in 6.0 when the abrupt disconnect occurs over TCP instead
of Unix sockets. Prior to that point, if a client does a hard
disconnect with no pending message, a 5.2 server reports:
$ qemu-nbd -f raw file &
[1] 1059670
$ nbdsh -u nbd://localhost:10809 -c 'h.trim(1,0)'
qemu-nbd: Disconnect client, due to: Failed to read request: Unexpected end-of-file before all bytes were read
[1]+ Done qemu-nbd -f raw file
but in 6.0, we started reporting:
qemu-nbd: Disconnect client, due to: Request handling failed in intermediate state
and looking further, I discovered that if you also use --trace=nbd_\*,
qemu-nbd ends up tracing uninitialized memory; it is now failing
because it sees an unexpected magic number from the uninitialized
memory, rather than its earlier detection of early EOF.
It's interesting that a Unix socket sees EPIPE when a TCP socket does
not, but it also means that your patch in isolation won't solve the
TCP issue, so I'm trying to come up with something today.
>
> Note that if you call the nbdsh h.shutdown() method then the message
> was not printed:
>
> $ nbdsh -u 'nbd+unix:///?socket=/tmp/sock' -c 'h.get_size()' -c 'h.shutdown()'
>
> Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
> ---
> nbd/server.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/nbd/server.c b/nbd/server.c
> index 3927f7789d..e0a43802b2 100644
> --- a/nbd/server.c
> +++ b/nbd/server.c
> @@ -2669,7 +2669,12 @@ static coroutine_fn void nbd_trip(void *opaque)
> ret = nbd_handle_request(client, &request, req->data, &local_err);
> }
> if (ret < 0) {
> - error_prepend(&local_err, "Failed to send reply: ");
> + if (errno != EPIPE) {
> + error_prepend(&local_err, "Failed to send reply: ");
> + } else {
> + error_free(local_err);
> + local_err = NULL;
> + }
> goto disconnect;
> }
>
> --
> 2.32.0
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
prev parent reply other threads:[~2021-11-17 15:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 15:19 [PATCH v2] nbd/server: Suppress Broken pipe errors on abrupt disconnection Richard W.M. Jones
2021-09-14 14:40 ` Vladimir Sementsov-Ogievskiy
2021-09-14 14:52 ` Richard W.M. Jones
2021-09-14 15:21 ` Vladimir Sementsov-Ogievskiy
2021-09-14 16:32 ` Richard W.M. Jones
2021-09-15 7:15 ` Vladimir Sementsov-Ogievskiy
2021-09-15 9:00 ` Richard W.M. Jones
2021-09-15 9:11 ` Vladimir Sementsov-Ogievskiy
2021-09-17 16:10 ` Eric Blake
2021-09-17 16:05 ` Eric Blake
2021-09-14 19:06 ` Eric Blake
2021-09-14 19:01 ` Eric Blake
2021-11-17 15:47 ` Eric Blake [this message]
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=20211117154728.6bd6uo622zoentur@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@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.