qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] block: add the support for draining the throttled request queue
@ 2012-02-20  4:50 zwu.kernel
  2012-02-20  9:26 ` Kevin Wolf
  2012-02-24  8:49 ` Stefan Hajnoczi
  0 siblings, 2 replies; 12+ messages in thread
From: zwu.kernel @ 2012-02-20  4:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, chris, Zhi Yong Wu, stefanha

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

If one guest has multiple disks with enabling I/O throttling function separately, when draining activities are done, some requests maybe are in the throttled queue; So we need to restart them at first.

Moreover, when only one disk need to be drained such as hotplug out, if another disk still has some requests in its throttled queue, these request should not be effected.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 block.c     |   29 ++++++++++++++++++++++-------
 block_int.h |    1 +
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index ae297bb..f78df78 100644
--- a/block.c
+++ b/block.c
@@ -853,25 +853,40 @@ void bdrv_close_all(void)
     }
 }
 
-/*
- * Wait for pending requests to complete across all BlockDriverStates
- *
- * This function does not flush data to disk, use bdrv_flush_all() for that
- * after calling this function.
- */
-void bdrv_drain_all(void)
+void bdrv_drain_request(BlockDriverState *throttled_bs)
 {
     BlockDriverState *bs;
 
+    QTAILQ_FOREACH(bs, &bdrv_states, list) {
+        if (throttled_bs && throttled_bs != bs) {
+            continue;
+        }
+        qemu_co_queue_restart_all(&bs->throttled_reqs);
+    }
+
     qemu_aio_flush();
 
     /* If requests are still pending there is a bug somewhere */
     QTAILQ_FOREACH(bs, &bdrv_states, list) {
         assert(QLIST_EMPTY(&bs->tracked_requests));
+        if (throttled_bs && throttled_bs != bs) {
+            continue;
+        }
         assert(qemu_co_queue_empty(&bs->throttled_reqs));
     }
 }
 
+/*
+ * Wait for pending requests to complete across all BlockDriverStates
+ *
+ * This function does not flush data to disk, use bdrv_flush_all() for that
+ * after calling this function.
+ */
+void bdrv_drain_all(void)
+{
+    bdrv_drain_request(NULL);
+}
+
 /* make a BlockDriverState anonymous by removing from bdrv_state list.
    Also, NULL terminate the device_name to prevent double remove */
 void bdrv_make_anon(BlockDriverState *bs)
diff --git a/block_int.h b/block_int.h
index 7946cf6..1311288 100644
--- a/block_int.h
+++ b/block_int.h
@@ -323,6 +323,7 @@ void qemu_aio_release(void *p);
 
 void bdrv_set_io_limits(BlockDriverState *bs,
                         BlockIOLimit *io_limits);
+void bdrv_drain_request(BlockDriverState *bs);
 
 #ifdef _WIN32
 int is_windows_drive(const char *filename);
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-02-24 13:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-20  4:50 [Qemu-devel] [PATCH 1/2] block: add the support for draining the throttled request queue zwu.kernel
2012-02-20  9:26 ` Kevin Wolf
2012-02-20  9:29   ` Zhi Yong Wu
2012-02-20  9:39     ` Kevin Wolf
2012-02-20  9:46       ` Zhi Yong Wu
2012-02-20  9:34   ` Zhi Yong Wu
2012-02-24  8:49 ` Stefan Hajnoczi
2012-02-24  9:20   ` Zhi Yong Wu
2012-02-24  9:25   ` Zhi Yong Wu
2012-02-24 11:18     ` Stefan Hajnoczi
2012-02-24 13:07       ` Zhi Yong Wu
2012-02-24 12:54   ` Paolo Bonzini

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).