From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Roman Kagan <rvkagan@yandex-team.ru>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH 3/3] nbd: make nbd_read* return -EIO on error
Date: Fri, 29 Jan 2021 08:48:59 +0300 [thread overview]
Message-ID: <b647a64f-5cdc-db8d-9117-feed5e955057@virtuozzo.com> (raw)
In-Reply-To: <20210128201418.607640-4-rvkagan@yandex-team.ru>
28.01.2021 23:14, Roman Kagan wrote:
> NBD reconnect logic considers the error code from the functions that
> read NBD messages to tell if reconnect should be attempted or not: it is
> attempted on -EIO, otherwise the client transitions to NBD_CLIENT_QUIT
> state (see nbd_channel_error). This error code is propagated from the
> primitives like nbd_read.
>
> The problem, however, is that nbd_read itself turns every error into -1
> rather than -EIO. As a result, if the NBD server happens to die while
> sending the message, the client in QEMU receives less data than it
> expects, considers it as a fatal error, and wouldn't attempt
> reestablishing the connection.
>
> Fix it by turning every negative return from qio_channel_read_all into
> -EIO returned from nbd_read. Apparently that was the original behavior,
> but got broken later. Also adjust nbd_readXX to follow.
>
> Fixes: e6798f06a6 ("nbd: generalize usage of nbd_read")
> Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Really looks like a bug in e6798f06a6: it changes error code from -EIO to -1 without any reasoning.
> ---
> include/block/nbd.h | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/include/block/nbd.h b/include/block/nbd.h
> index 4a52a43ef5..5f34d23bb0 100644
> --- a/include/block/nbd.h
> +++ b/include/block/nbd.h
> @@ -364,7 +364,7 @@ static inline int nbd_read(QIOChannel *ioc, void *buffer, size_t size,
> if (desc) {
> error_prepend(errp, "Failed to read %s: ", desc);
> }
> - return -1;
> + return ret;
> }
>
> return 0;
> @@ -375,8 +375,9 @@ static inline int nbd_read##bits(QIOChannel *ioc, \
> uint##bits##_t *val, \
> const char *desc, Error **errp) \
> { \
> - if (nbd_read(ioc, val, sizeof(*val), desc, errp) < 0) { \
> - return -1; \
> + int ret = nbd_read(ioc, val, sizeof(*val), desc, errp); \
> + if (ret < 0) { \
> + return ret; \
> } \
> *val = be##bits##_to_cpu(*val); \
> return 0; \
>
--
Best regards,
Vladimir
next prev parent reply other threads:[~2021-01-29 5:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 20:14 [PATCH 0/3] block/nbd: fix crashers in reconnect while migrating Roman Kagan
2021-01-28 20:14 ` [PATCH 1/3] block/nbd: only detach existing iochannel from aio_context Roman Kagan
2021-01-29 5:37 ` Vladimir Sementsov-Ogievskiy
2021-01-29 7:03 ` Roman Kagan
2021-01-28 20:14 ` [PATCH 2/3] block/nbd: only enter connection coroutine if it's present Roman Kagan
2021-01-29 5:40 ` Vladimir Sementsov-Ogievskiy
2021-01-28 20:14 ` [PATCH 3/3] nbd: make nbd_read* return -EIO on error Roman Kagan
2021-01-29 5:48 ` Vladimir Sementsov-Ogievskiy [this message]
2021-01-29 5:51 ` [PATCH 0/3] block/nbd: fix crashers in reconnect while migrating Vladimir Sementsov-Ogievskiy
2021-01-29 7:35 ` Roman Kagan
2021-01-29 8:19 ` 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=b647a64f-5cdc-db8d-9117-feed5e955057@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rvkagan@yandex-team.ru \
/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).