From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block: Let bdrv_drain_all() to call aio_poll() for each AioContext
Date: Thu, 14 May 2015 17:29:21 +0300 [thread overview]
Message-ID: <878ucr9qri.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <55548F90.8010709@redhat.com> (Paolo Bonzini's message of "Thu, 14 May 2015 14:05:36 +0200")
Paolo Bonzini <pbonzini@redhat.com> writes:
> On 13/05/2015 18:34, Alexander Yarygin wrote:
>> Ah, right. We need second loop, something like this:
>>
>> @@ -2030,20 +2033,33 @@ void bdrv_drain(BlockDriverState *bs)
>> void bdrv_drain_all(void)
>> {
>> /* Always run first iteration so any pending completion BHs run */
>> - bool busy = true;
>> + bool busy = true, pending = false;
>> BlockDriverState *bs;
>> + GList *aio_ctxs = NULL, *ctx;
>> + AioContext *aio_context;
>>
>> while (busy) {
>> busy = false;
>>
>> QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
>> - AioContext *aio_context = bdrv_get_aio_context(bs);
>> + aio_context = bdrv_get_aio_context(bs);
>>
>> aio_context_acquire(aio_context);
>> busy |= bdrv_drain_one(bs);
>> aio_context_release(aio_context);
>> + if (!aio_ctxs || !g_list_find(aio_ctxs, aio_context))
>> + aio_ctxs = g_list_append(aio_ctxs, aio_context);
>> + }
>> + pending = busy;
>> +
>> + for (ctx = aio_ctxs; ctx != NULL; ctx = ctx->next) {
>> + aio_context = ctx->data;
>> + aio_context_acquire(aio_context);
>> + busy |= aio_poll(aio_context, pending);
>> + aio_context_release(aio_context);
>> }
>> }
>> + g_list_free(aio_ctxs);
>> }
>>
>> That looks quite ugly for me and breaks consistence of bdrv_drain_one()
>> since it doesn't call aio_poll() anymore...
>
> It's not ugly. After your patch bdrv_drain_one doesn't call aio_poll,
> while bdrv_drain and bdrv_drain_all call bdrv_drain_one + aio_poll. All
> callers of bdrv_drain_one are consistent.
>
> Perhaps you can rename bdrv_drain_one to bdrv_flush_io_queue (inlining
> the existing bdrv_flush_io_queue into it)? That would work very well
> for me.
>
> Paolo
Hmm, bdrv_flush_io_queue() is public, but has no users. How about
different name, maybe something like "bdrv_drain_requests_one" or so?
Otherwise here is a patch related to renaming to bdrv_flush_io_queue()
below. If it's ok, I will respin the whole patch.
Thanks.
--- a/block.c
+++ b/block.c
@@ -1987,11 +1987,17 @@ static bool bdrv_requests_pending(BlockDriverState *bs)
return false;
}
-static bool bdrv_drain_one(BlockDriverState *bs)
+static bool bdrv_flush_io_queue(BlockDriverState *bs)
{
bool bs_busy;
+ BlockDriver *drv = bs->drv;
+
+ if (drv && drv->bdrv_flush_io_queue) {
+ drv->bdrv_flush_io_queue(bs);
+ } else if (bs->file) {
+ bdrv_flush_io_queue(bs->file);
+ }
- bdrv_flush_io_queue(bs);
bdrv_start_throttled_reqs(bs);
bs_busy = bdrv_requests_pending(bs);
return bs_busy;
@@ -2013,7 +2019,7 @@ void bdrv_drain(BlockDriverState *bs)
while (busy) {
/* Keep iterating */
- busy = bdrv_drain_one(bs);
+ busy = bdrv_flush_io_queue(bs);
busy |= aio_poll(bdrv_get_aio_context(bs), busy);
}
}
@@ -2044,7 +2050,7 @@ void bdrv_drain_all(void)
AioContext *aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
- busy |= bdrv_drain_one(bs);
+ busy |= bdrv_flush_io_queue(bs);
if (!aio_ctxs || !g_slist_find(aio_ctxs, aio_context)) {
busy |= aio_poll(aio_context, busy);
aio_ctxs = g_slist_prepend(aio_ctxs, aio_context);
@@ -6088,16 +6094,6 @@ void bdrv_io_unplug(BlockDriverState *bs)
}
}
-void bdrv_flush_io_queue(BlockDriverState *bs)
-{
- BlockDriver *drv = bs->drv;
- if (drv && drv->bdrv_flush_io_queue) {
- drv->bdrv_flush_io_queue(bs);
- } else if (bs->file) {
- bdrv_flush_io_queue(bs->file);
- }
-}
-
static bool append_open_options(QDict *d, BlockDriverState *bs)
{
const QDictEntry *entry;
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -565,7 +565,6 @@ int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo);
void bdrv_io_plug(BlockDriverState *bs);
void bdrv_io_unplug(BlockDriverState *bs);
-void bdrv_flush_io_queue(BlockDriverState *bs);
BlockAcctStats *bdrv_get_stats(BlockDriverState *bs);
next prev parent reply other threads:[~2015-05-14 14:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-13 15:18 [Qemu-devel] [PATCH] block: Let bdrv_drain_all() to call aio_poll() for each AioContext Alexander Yarygin
2015-05-13 15:23 ` Paolo Bonzini
2015-05-13 16:34 ` Alexander Yarygin
2015-05-14 2:25 ` Fam Zheng
2015-05-14 10:57 ` Alexander Yarygin
2015-05-14 12:05 ` Paolo Bonzini
2015-05-14 14:29 ` Alexander Yarygin [this message]
2015-05-14 14:34 ` Paolo Bonzini
2015-05-13 16:02 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2015-05-13 16:37 ` Alexander Yarygin
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=878ucr9qri.fsf@linux.vnet.ibm.com \
--to=yarygin@linux.vnet.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.