From: Eric Blake <eblake@redhat.com>
To: Sergio Lopez <slp@redhat.com>, qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com,
mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH] mirror: Confirm we're quiesced only if the job is paused or cancelled
Date: Thu, 7 Mar 2019 11:15:48 -0600 [thread overview]
Message-ID: <93b48e49-87dd-9a05-49eb-09bbd7452154@redhat.com> (raw)
In-Reply-To: <20190307140312.28072-1-slp@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2077 bytes --]
On 3/7/19 8:03 AM, Sergio Lopez wrote:
> While child_job_drained_begin() calls to job_pause(), the job doesn't
> actually transition between states until it runs again and reaches a
> pause point. This means bdrv_drained_begin() may return with some jobs
> using the node still having 'busy == true'.
>
> As a consequence, block_job_detach_aio_context() may get into a
> deadlock, waiting for the job to be actually paused, while the coroutine
> servicing the job is yielding and doesn't get the opportunity to get
> scheduled again. This situation can be reproduced by issuing a
> 'block-commit' immediately followed by a 'device_del'.
>
> To ensure bdrv_drained_begin() only returns when the jobs have been
> paused, we change mirror_drained_poll() to only confirm it's quiesced
> when job->paused == true and there aren't any in-flight requests, except
> if we reached that point by a drained section initiated by the
> mirror/commit job itself.
>
> The other block jobs shouldn't need any changes, as the default
> drained_poll() behavior is to only confirm it's quiesced if the job is
> not busy or completed.
>
> Signed-off-by: Sergio Lopez <slp@redhat.com>
> ---
> block/mirror.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> @@ -1119,6 +1126,16 @@ static void coroutine_fn mirror_pause(Job *job)
> static bool mirror_drained_poll(BlockJob *job)
> {
> MirrorBlockJob *s = container_of(job, MirrorBlockJob, common);
> +
> + /* If the job isn't paused nor cancelled, we can't be sure that it won't
> + * issue more requets. We make an exception if we've reached this point
requests
> + * from one of our own drain sections, to avoid a deadlock waiting for
> + * ourselves.
> + */
> + if (!s->common.job.paused && !s->common.job.cancelled && !s->in_drain) {
> + return true;
> + }
> +
> return !!s->in_flight;
> }
>
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2019-03-07 17:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-07 14:03 [Qemu-devel] [PATCH] mirror: Confirm we're quiesced only if the job is paused or cancelled Sergio Lopez
2019-03-07 17:15 ` 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=93b48e49-87dd-9a05-49eb-09bbd7452154@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=slp@redhat.com \
--cc=stefanha@redhat.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).