From: Paolo Bonzini <pbonzini@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
lvivier@redhat.com, Stefan Hajnoczi <stefanha@redhat.com>,
qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block: Fix bdrv_drain in coroutine
Date: Fri, 1 Apr 2016 11:49:42 +0200 [thread overview]
Message-ID: <56FE4436.4040109@redhat.com> (raw)
In-Reply-To: <1459503998-31592-1-git-send-email-famz@redhat.com>
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,
> + 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.
Paolo
> +}
next prev parent reply other threads:[~2016-04-01 9:49 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 [this message]
2016-04-01 10:09 ` Fam Zheng
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=56FE4436.4040109@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=lvivier@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).