From: Fam Zheng <famz@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
lvivier@redhat.com, Stefan Hajnoczi <stefanha@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block: Fix bdrv_drain in coroutine
Date: Fri, 1 Apr 2016 18:09:58 +0800 [thread overview]
Message-ID: <20160401100958.GA871@ad.usersys.redhat.com> (raw)
In-Reply-To: <56FE4436.4040109@redhat.com>
On Fri, 04/01 11:49, Paolo Bonzini wrote:
>
>
> On 01/04/2016 11:46, Fam Zheng wrote:
> > +
> > +static void bdrv_co_drain_bh_cb(void *opaque)
> > +{
> > + BdrvCoDrainData *data = opaque;
> > + Coroutine *co = data->co;
> > +
> > + bdrv_drain(data->bs);
> > + data->done = true;
> > + qemu_coroutine_enter(co, NULL);
> > +}
> > +
> > +static void coroutine_fn bdrv_co_drain(BlockDriverState *bs)
> > +{
> > + QEMUBH *bh;
> > + BdrvCoDrainData data;
> > +
> > + assert(qemu_in_coroutine());
> > + data = (BdrvCoDrainData) {
> > + .co = qemu_coroutine_self(),
> > + .bs = bs,
> > + .done = false,
> > + };
> > + bh = aio_bh_new(bdrv_get_aio_context(bs), bdrv_co_drain_bh_cb, &data),
> > + qemu_bh_schedule(bh);
> > +
> > + do {
> > + qemu_coroutine_yield();
> > + } while (!data.done);
>
> The loop and "done" is not necessary. Also,
I was trying to protect against the bugs similar to the one fixed in
e424aff5f30, but you're right we can make this an assertion and the loop is not
needed. If a calling coroutine is resumed unexpectedly, we will catch it and
fix it.
>
> > + qemu_bh_delete(bh);
>
> this can be moved to bdrv_co_drain_bh_cb before bdrv_drain, so that the
> bottom half doesn't slow down the event loop until bdrv_drain completes.
Good point! Will fix.
Thanks,
Fam
next prev parent reply other threads:[~2016-04-01 10:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-01 9:46 [Qemu-devel] [PATCH] block: Fix bdrv_drain in coroutine Fam Zheng
2016-04-01 9:49 ` Paolo Bonzini
2016-04-01 10:09 ` Fam Zheng [this message]
2016-04-01 12:05 ` Laurent Vivier
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=20160401100958.GA871@ad.usersys.redhat.com \
--to=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=lvivier@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).