qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH v2 2/4] block: Pause block jobs in bdrv_drain_all


From: Fam Zheng
Subject: [Qemu-block] [PATCH v2 2/4] block: Pause block jobs in bdrv_drain_all
Date: Fri, 3 Apr 2015 22:05:19 +0800

This is necessary to suppress more IO requests from being generated from
block job coroutines.

Signed-off-by: Fam Zheng <address@hidden>
---
 block.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/block.c b/block.c
index f2f8ae7..00cd91e 100644
--- a/block.c
+++ b/block.c
@@ -2033,6 +2033,16 @@ void bdrv_drain_all(void)
     bool busy = true;
     BlockDriverState *bs;
 
+    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
+        AioContext *aio_context = bdrv_get_aio_context(bs);
+
+        aio_context_acquire(aio_context);
+        if (bs->job) {
+            block_job_pause(bs->job);
+        }
+        aio_context_release(aio_context);
+    }
+
     while (busy) {
         busy = false;
 
@@ -2044,6 +2054,16 @@ void bdrv_drain_all(void)
             aio_context_release(aio_context);
         }
     }
+
+    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
+        AioContext *aio_context = bdrv_get_aio_context(bs);
+
+        aio_context_acquire(aio_context);
+        if (bs->job) {
+            block_job_resume(bs->job);
+        }
+        aio_context_release(aio_context);
+    }
 }
 
 /* make a BlockDriverState anonymous by removing from bdrv_state and
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]