All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, berto@igalia.com, famz@redhat.com,
	qemu-block@nongnu.org, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v4 4/8] block: extract bdrv_drain_poll/bdrv_co_yield_to_drain from bdrv_drain/bdrv_co_drain
Date: Thu,  7 Apr 2016 18:33:32 +0200	[thread overview]
Message-ID: <1460046816-102846-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1460046816-102846-1-git-send-email-pbonzini@redhat.com>

Do not call bdrv_drain_recurse twice in bdrv_co_drain.  A small
tweak to the logic in Fam's patch, which is harmless since no
one implements bdrv_drain anyway.  But better get it right.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
	v4: new

 block/io.c | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/block/io.c b/block/io.c
index 9201b89..15bc956 100644
--- a/block/io.c
+++ b/block/io.c
@@ -243,18 +243,30 @@ typedef struct {
     bool done;
 } BdrvCoDrainData;
 
+static void bdrv_drain_poll(BlockDriverState *bs)
+{
+    bool busy = true;
+
+    while (busy) {
+        /* Keep iterating */
+        bdrv_flush_io_queue(bs);
+        busy = bdrv_requests_pending(bs);
+        busy |= aio_poll(bdrv_get_aio_context(bs), busy);
+    }
+}
+
 static void bdrv_co_drain_bh_cb(void *opaque)
 {
     BdrvCoDrainData *data = opaque;
     Coroutine *co = data->co;
 
     qemu_bh_delete(data->bh);
-    bdrv_drain(data->bs);
+    bdrv_drain_poll(data->bs);
     data->done = true;
     qemu_coroutine_enter(co, NULL);
 }
 
-void coroutine_fn bdrv_co_drain(BlockDriverState *bs)
+static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs)
 {
     BdrvCoDrainData data;
 
@@ -288,20 +300,19 @@ void coroutine_fn bdrv_co_drain(BlockDriverState *bs)
  * not depend on events in other AioContexts.  In that case, use
  * bdrv_drain_all() instead.
  */
-void bdrv_drain(BlockDriverState *bs)
+void coroutine_fn bdrv_co_drain(BlockDriverState *bs)
 {
-    bool busy = true;
+    bdrv_drain_recurse(bs);
+    bdrv_co_yield_to_drain(bs);
+}
 
+void bdrv_drain(BlockDriverState *bs)
+{
     bdrv_drain_recurse(bs);
     if (qemu_in_coroutine()) {
-        bdrv_co_drain(bs);
-        return;
-    }
-    while (busy) {
-        /* Keep iterating */
-         bdrv_flush_io_queue(bs);
-         busy = bdrv_requests_pending(bs);
-         busy |= aio_poll(bdrv_get_aio_context(bs), busy);
+        bdrv_co_yield_to_drain(bs);
+    } else {
+        bdrv_drain_poll(bs);
     }
 }
 
-- 
1.8.3.1

  parent reply	other threads:[~2016-04-07 16:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07 16:33 [Qemu-devel] [PATCH v4 0/8] bdrv_flush_io_queue removal, shared LinuxAioState Paolo Bonzini
2016-04-07 16:33 ` [Qemu-devel] [PATCH v4 1/8] block: Don't disable I/O throttling on sync requests Paolo Bonzini
2016-04-07 16:33 ` [Qemu-devel] [PATCH v4 2/8] block: make bdrv_start_throttled_reqs return void Paolo Bonzini
2016-04-07 16:33 ` [Qemu-devel] [PATCH v4 3/8] block: move restarting of throttled reqs to block/throttle-groups.c Paolo Bonzini
2016-04-07 16:33 ` Paolo Bonzini [this message]
2016-04-07 16:33 ` [Qemu-devel] [PATCH v4 5/8] block: introduce bdrv_no_throttling_begin/end Paolo Bonzini
2016-04-07 16:33 ` [Qemu-devel] [PATCH v4 6/8] block: plug whole tree at once, introduce bdrv_io_unplugged_begin/end Paolo Bonzini
2016-04-07 16:33 ` [Qemu-devel] [PATCH v4 7/8] linux-aio: make it more type safe Paolo Bonzini
2016-04-07 16:33 ` [Qemu-devel] [PATCH v4 8/8] linux-aio: share one LinuxAioState within an AioContext Paolo Bonzini
2016-04-19  9:09   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-05-09 16:31     ` Paolo Bonzini
2016-05-10  9:30       ` Stefan Hajnoczi
2016-05-10  9:40         ` Kevin Wolf
2016-05-10 10:32           ` Paolo Bonzini
2016-05-11 13:22             ` Stefan Hajnoczi
2016-05-11 13:18           ` Stefan Hajnoczi
2016-05-11 13:23   ` [Qemu-devel] " Stefan Hajnoczi
2016-04-19  9:10 ` [Qemu-devel] [Qemu-block] [PATCH v4 0/8] bdrv_flush_io_queue removal, shared LinuxAioState Stefan Hajnoczi
2016-04-19 15:09   ` Kevin Wolf

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=1460046816-102846-5-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=berto@igalia.com \
    --cc=famz@redhat.com \
    --cc=kwolf@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.