qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: zwu.kernel@gmail.com
To: qemu-devel@nongnu.org
Cc: zwu.kernel@gmail.com, pbonzini@redhat.com,
	Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>,
	stefanha@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH] block: add the support to drain throttled requests
Date: Tue, 13 Mar 2012 09:53:31 +0800	[thread overview]
Message-ID: <1331603611-9103-1-git-send-email-zwu.kernel@gmail.com> (raw)

From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
[ Iterate until all block devices have processed all requests,
 add comments. - Paolo ]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block.c |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index 52ffe14..52dabd0 100644
--- a/block.c
+++ b/block.c
@@ -858,12 +858,32 @@ void bdrv_close_all(void)
  *
  * This function does not flush data to disk, use bdrv_flush_all() for that
  * after calling this function.
- */
+ *
+ * Note that completion of an asynchronous I/O operation can trigger any
+ * number of other I/O operations on other devices---for example a coroutine
+ * can be arbitrarily complex and a constant flow of I/O to multiple devices
+ * can come until the coroutine is complete.  Because of this, it is not
+ * possible to drain a single device's I/O queue.
+*/
 void bdrv_drain_all(void)
 {
     BlockDriverState *bs;
+    bool busy;
 
-    qemu_aio_flush();
+    do {
+        busy = false;
+        qemu_aio_flush();
+
+        /* FIXME: We do not have timer support here, so this is effectively
+         * a busy wait.
+         */
+        QTAILQ_FOREACH(bs, &bdrv_states, list) {
+            if (!qemu_co_queue_empty(&bs->throttled_reqs)) {
+                qemu_co_queue_restart_all(&bs->throttled_reqs);
+                busy = true;
+            }
+        }
+    } while (busy);
 
     /* If requests are still pending there is a bug somewhere */
     QTAILQ_FOREACH(bs, &bdrv_states, list) {
-- 
1.7.6

             reply	other threads:[~2012-03-13  1:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-13  1:53 zwu.kernel [this message]
2012-03-20  9:40 ` [Qemu-devel] [PATCH] block: add the support to drain throttled requests Zhi Yong Wu
2012-03-20  9:47   ` Paolo Bonzini
2012-03-20  9:58     ` Kevin Wolf
2012-03-20 11:44       ` Stefan Hajnoczi
2012-03-22 19:07         ` Chris Webb
2012-03-23 10:38           ` Stefan Hajnoczi
2012-03-23 10:43             ` Chris Webb
2012-03-23 10:50               ` Stefan Hajnoczi
2012-03-23 11:02                 ` Richard Davies
2012-03-23 11:32                   ` Stefan Hajnoczi
2012-03-23 16:56                     ` Stefan Hajnoczi
2012-03-26 14:21         ` Stefan Hajnoczi
2012-03-26 14:31           ` Kevin Wolf
2012-03-27  4:29           ` Zhi Yong Wu
2012-03-27  6:52             ` Stefan Hajnoczi
2012-03-20  9:56   ` 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=1331603611-9103-1-git-send-email-zwu.kernel@gmail.com \
    --to=zwu.kernel@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    --cc=wuzhy@linux.vnet.ibm.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).