qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: jsnow@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com
Subject: Re: [PATCH 2/2] mirror: Wait only for in-flight operations
Date: Wed, 25 Mar 2020 12:39:01 -0500	[thread overview]
Message-ID: <927a1047-493e-6ca0-1dac-aab57d6ebd41@redhat.com> (raw)
In-Reply-To: <20200325172326.22347-3-kwolf@redhat.com>

On 3/25/20 12:23 PM, Kevin Wolf wrote:
> mirror_wait_for_free_in_flight_slot() just picks a random operation to
> wait for. However, a MirrorOp is already in s->ops_in_flight when
> mirror_co_read() waits for free slots, so if not enough slots are
> immediately available, an operation can end up waiting for itself, or
> two or more operations can wait for each other to complete, which
> results in a hang.
> 
> Fix this by adding a flag to MirrorOp that tells us if the request is
> already in flight (and therefore occupies slots that it will later
> free), and picking only such operations for waiting.
> 
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1794692
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   block/mirror.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/block/mirror.c b/block/mirror.c
> index 393131b135..7fef52ded2 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -102,6 +102,7 @@ struct MirrorOp {
>   
>       bool is_pseudo_op;
>       bool is_active_write;
> +    bool is_in_flight;
>       CoQueue waiting_requests;
>       Coroutine *co;
>   
> @@ -293,7 +294,9 @@ mirror_wait_for_any_operation(MirrorBlockJob *s, bool active)
>            * caller of this function.  Since there is only one pseudo op
>            * at any given time, we will always find some real operation
>            * to wait on. */
> -        if (!op->is_pseudo_op && op->is_active_write == active) {
> +        if (!op->is_pseudo_op && op->is_in_flight &&
> +            op->is_active_write == active)
> +        {
>               qemu_co_queue_wait(&op->waiting_requests, NULL);

Looks like a one-way transition - op->is_in_flight always starts as 
false, and only ever gets set to true (once the op is finished, op is no 
longer needed).  And being more selective on what you wait for here does 
look like it should work in more cases than what patch 1 reverted.

Reviewed-by: Eric Blake <eblake@redhat.com>

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



  reply	other threads:[~2020-03-25 17:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 17:23 [PATCH 0/2] mirror: Fix hang (operation waiting for itself/circular dependency) Kevin Wolf
2020-03-25 17:23 ` [PATCH 1/2] Revert "mirror: Don't let an operation wait for itself" Kevin Wolf
2020-03-25 17:36   ` Eric Blake
2020-03-25 17:23 ` [PATCH 2/2] mirror: Wait only for in-flight operations Kevin Wolf
2020-03-25 17:39   ` Eric Blake [this message]
2020-03-25 17:49 ` [PATCH 0/2] mirror: Fix hang (operation waiting for itself/circular dependency) Kevin Wolf

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=927a1047-493e-6ca0-1dac-aab57d6ebd41@redhat.com \
    --to=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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).