qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org,
	mreitz@redhat.com
Subject: Re: [PATCH v5 3/5] block/nbd: refactor nbd_recv_coroutines_wake_all()
Date: Fri, 16 Jul 2021 16:25:13 -0500	[thread overview]
Message-ID: <20210716212513.x5dtfslhgtyufx6x@redhat.com> (raw)
In-Reply-To: <20210714165916.102363-4-vsementsov@virtuozzo.com>

On Wed, Jul 14, 2021 at 07:59:14PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Split out nbd_recv_coroutine_wake(), as it will be used in separate.

s/in separate/separately/

> Also add a possibility to wake only first found sleeping coroutine.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/nbd.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 

> +
> +static void nbd_recv_coroutines_wake_all(BDRVNBDState *s, bool only_one)

Without reading docs (including the parameter name), I would have guessed:

wake_all(s, true) - wakes all
wake_all(s, false) - wakes one

but your code does:

wake_all(s, true) - wakes one
wake_all(s, false) - wakes all

Maybe that means this function and/or its parameter is now misnamed.
Having the _all in the name with true to NOT be all is what threw me.
Would the following be any better:

nbd_recv_coroutines_wake(BDRVNBDState *s, bool all)

where

wake(s, true) - wakes all
wake(s, false) - wakes one

and where your helper function needs to be renamed, and callers
updated to match those semantics?

>  {
>      int i;
>  
>      for (i = 0; i < MAX_NBD_REQUESTS; i++) {
> -        NBDClientRequest *req = &s->requests[i];
> -
> -        if (req->coroutine && req->receiving) {
> -            req->receiving = false;
> -            aio_co_wake(req->coroutine);
> +        if (nbd_recv_coroutine_wake(&s->requests[i]) && only_one) {
> +            return;

But while I'm not sold on the naming, the change in logic (to be able
to wake any one waiter but not the whole list) looks useful for future
patches.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



  reply	other threads:[~2021-07-16 21:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14 16:59 [PATCH v5 0/5] block/nbd: drop connection_co Vladimir Sementsov-Ogievskiy
2021-07-14 16:59 ` [PATCH v5 1/5] block/nbd: nbd_channel_error() shutdown channel unconditionally Vladimir Sementsov-Ogievskiy
2021-07-16 20:34   ` Eric Blake
2021-07-14 16:59 ` [PATCH v5 2/5] block/nbd: move nbd_recv_coroutines_wake_all() up Vladimir Sementsov-Ogievskiy
2021-07-16 20:35   ` Eric Blake
2021-07-14 16:59 ` [PATCH v5 3/5] block/nbd: refactor nbd_recv_coroutines_wake_all() Vladimir Sementsov-Ogievskiy
2021-07-16 21:25   ` Eric Blake [this message]
2021-07-19  9:13     ` Vladimir Sementsov-Ogievskiy
2021-07-14 16:59 ` [PATCH v5 4/5] block/nbd: drop connection_co Vladimir Sementsov-Ogievskiy
2021-07-14 17:07   ` Vladimir Sementsov-Ogievskiy
2021-07-14 16:59 ` [PATCH v5 5/5] block/nbd: check that received handle is valid 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=20210716212513.x5dtfslhgtyufx6x@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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).