qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Jeff Cody <jcody@redhat.com>,
	qemu-devel@nongnu.org, mreitz@redhat.com, pbonzini@redhat.com,
	jsnow@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3] blockjob: Fix hang in block_job_finish_sync
Date: Mon, 1 Feb 2016 10:49:00 +0800	[thread overview]
Message-ID: <20160201024900.GC17009@ad.usersys.redhat.com> (raw)
In-Reply-To: <20160129113126.GA15489@stefanha-x1.localdomain>

On Fri, 01/29 11:31, Stefan Hajnoczi wrote:
> On Fri, Jan 29, 2016 at 10:19:49AM +0800, Fam Zheng wrote:
> > @@ -402,6 +407,10 @@ typedef void BlockJobDeferToMainLoopFn(BlockJob *job, void *opaque);
> >   * AioContext acquired.  Block jobs must call bdrv_unref(), bdrv_close(), and
> >   * anything that uses bdrv_drain_all() in the main loop.
> >   *
> > + * The job->deferred_to_main_loop flag will be set. Caller must clear it once
> > + * the deferred work is done and the block job coroutine continues, unless it's
> > + * completing immediately.
> > + *
> 
> It's not necessary to expose job->deferred_to_main_loop to the user.
> Just clear it:
> 
> static void block_job_defer_to_main_loop_bh(void *opaque)
> {
>     BlockJobDeferToMainLoopData *data = opaque;
>     AioContext *aio_context;
> 
>     qemu_bh_delete(data->bh);
> 
>     /* Prevent race with block_job_defer_to_main_loop() */
>     aio_context_acquire(data->aio_context);
> 
>     /* Fetch BDS AioContext again, in case it has changed */
>     aio_context = bdrv_get_aio_context(data->job->bs);
>     aio_context_acquire(aio_context);
> 
>     data->fn(data->job, data->opaque);
>     job->deferred_to_main_loop = false;  /* <----- HERE */

Maybe move one line above in case data->fn() does another
block_job_defer_to_main_loop()?

Fam

> 
>     aio_context_release(aio_context);
> 
>     aio_context_release(data->aio_context);
> 
>     g_free(data);
> }

  reply	other threads:[~2016-02-01  2:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29  2:19 [Qemu-devel] [PATCH v3] blockjob: Fix hang in block_job_finish_sync Fam Zheng
2016-01-29 11:31 ` Stefan Hajnoczi
2016-02-01  2:49   ` Fam Zheng [this message]
2016-02-01 11:36     ` Stefan Hajnoczi

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=20160201024900.GC17009@ad.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --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).