qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: mreitz@redhat.com, kwolf@redhat.com, pbonzini@redhat.com, den@openvz.org
Subject: Re: [Qemu-devel] [PATCH v2 6/7] block/nbd-client: early fail nbd_read_reply_entry if s->quit is set
Date: Mon, 18 Sep 2017 17:27:18 -0500	[thread overview]
Message-ID: <b016f0b6-c7bd-eef3-caee-47f7da7d8deb@redhat.com> (raw)
In-Reply-To: <20170918135935.255591-7-vsementsov@virtuozzo.com>

[-- Attachment #1: Type: text/plain, Size: 3109 bytes --]

On 09/18/2017 08:59 AM, Vladimir Sementsov-Ogievskiy wrote:
> Do not continue any operation if s->quit is set in parallel.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/nbd-client.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/block/nbd-client.c b/block/nbd-client.c
> index 280147e6a7..f80a4c5564 100644
> --- a/block/nbd-client.c
> +++ b/block/nbd-client.c
> @@ -81,7 +81,7 @@ static coroutine_fn void nbd_read_reply_entry(void *opaque)
>          if (ret < 0) {
>              error_report_err(local_err);
>          }
> -        if (ret <= 0) {
> +        if (ret <= 0 || s->quit) {
>              break;
>          }

I'm still not convinced this helps: either nbd_receive_reply() already
returned an error, or we got a successful reply header, at which point
either the command is done (no need to abort the command early - it
succeeded) or it is a read command (and we should detect at the point
where we try to populate the qiov that we don't want to read any more).
It depends on your 3/7 patch for the fact that we even try to read the
qiov directly in this while loop rather than in the coroutine handler,
where Paolo questioned whether we need that change.

> @@ -105,9 +105,8 @@ static coroutine_fn void nbd_read_reply_entry(void *opaque)
>              assert(qiov != NULL);
>              assert(s->requests[i].request->len ==
>                     iov_size(qiov->iov, qiov->niov));
> -            if (qio_channel_readv_all(s->ioc, qiov->iov, qiov->niov,
> -                                      NULL) < 0)
> -            {
> +            ret = qio_channel_readv_all(s->ioc, qiov->iov, qiov->niov, NULL);
> +            if (ret < 0 || s->quit) {
>                  s->requests[i].ret = -EIO;
>                  break;
>              }

The placement here looks odd. Either we should not attempt the read
because s->quit was already set (okay, your first addition makes sense
in that light), or we succeeded at the read (at which point, why do we
need to claim it failed?).

I'm trying to look forward to structured reads, where we will have to
deal with more than one server message in reply to a single client
request.  For read, we just piece together portions of the qiov until
the server has sent us all the pieces.  But for block query, I really do
think we'll want to defer to specialized handlers for doing further
reads (the amount of data to be read from the server is not known by the
client a priori, so it is a two-part read, one to get the length, and
another to read that remaining length); if we need some sort of callback
function rather than cramming all the logic here in the main read loop,
then the qio_channel_readv_all for read commands would belong in the
callback, and it is more a question of the main read loop checking
whether there is an early quit condition before calling into the callback.

-- 
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 --]

  reply	other threads:[~2017-09-18 22:27 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 13:59 [Qemu-devel] [PATCH v2 0/7] nbd client refactoring and fixing Vladimir Sementsov-Ogievskiy
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 1/7] block/nbd-client: refactor nbd_co_receive_reply Vladimir Sementsov-Ogievskiy
2017-09-18 15:38   ` Eric Blake
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 2/7] block/nbd-client: exit reply-reading coroutine on incorrect handle Vladimir Sementsov-Ogievskiy
2017-09-18 15:45   ` Eric Blake
2017-09-18 19:50   ` Eric Blake
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 3/7] block/nbd-client: refactor reading reply Vladimir Sementsov-Ogievskiy
2017-09-18 15:43   ` Paolo Bonzini
2017-09-18 15:54     ` Eric Blake
2017-09-19  9:25     ` Vladimir Sementsov-Ogievskiy
2017-09-19 10:01       ` Paolo Bonzini
2017-09-19 11:03         ` Vladimir Sementsov-Ogievskiy
2017-09-19 12:50           ` Paolo Bonzini
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 4/7] block/nbd-client: drop reply field from NBDClientSession Vladimir Sementsov-Ogievskiy
2017-09-18 22:00   ` Eric Blake
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 5/7] block/nbd-client: nbd_co_send_request: return -EIO if s->quit was set in parallel Vladimir Sementsov-Ogievskiy
2017-09-18 16:01   ` Eric Blake
2017-09-18 19:16     ` Eric Blake
2017-09-20 12:03     ` Vladimir Sementsov-Ogievskiy
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 6/7] block/nbd-client: early fail nbd_read_reply_entry if s->quit is set Vladimir Sementsov-Ogievskiy
2017-09-18 22:27   ` Eric Blake [this message]
2017-09-19  9:43     ` Vladimir Sementsov-Ogievskiy
2017-09-19 10:03       ` Paolo Bonzini
2017-09-19 11:07         ` Vladimir Sementsov-Ogievskiy
2017-09-18 13:59 ` [Qemu-devel] [PATCH v2 7/7] block/nbd-client: do not yield from nbd_read_reply_entry Vladimir Sementsov-Ogievskiy
2017-09-18 22:36   ` Eric Blake
2017-09-19 10:00     ` Vladimir Sementsov-Ogievskiy
2017-09-19 13:45       ` Eric Blake
  -- strict thread matches above, loose matches on Subject: below --
2017-10-09 17:27 [Qemu-devel] [PATCH v2 00/10] nbd minimal structured read Vladimir Sementsov-Ogievskiy
2017-10-09 17:27 ` [Qemu-devel] [PATCH v2 6/7] block/nbd-client: early fail nbd_read_reply_entry if s->quit is set 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=b016f0b6-c7bd-eef3-caee-47f7da7d8deb@redhat.com \
    --to=eblake@redhat.com \
    --cc=den@openvz.org \
    --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).