summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2015-04-03 22:05:19 +0800
committerKevin Wolf <kwolf@redhat.com>2015-04-28 15:36:09 +0200
commit69da3b0b47c8f6016e9109fcfa608e9e7e99bc05 (patch)
tree6a012964514769d9345da94a20bd8807401c7a64 /block.c
parent751ebd76e654bd1e65da08ecf694325282b4cfcc (diff)
downloadqemu-69da3b0b47c8f6016e9109fcfa608e9e7e99bc05.tar.gz
block: Pause block jobs in bdrv_drain_all
This is necessary to suppress more IO requests from being generated from block job coroutines. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Message-id: 1428069921-2957-3-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/block.c b/block.c
index 670d7e4fc2..70aed80089 100644
--- a/block.c
+++ b/block.c
@@ -2040,6 +2040,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;
@@ -2051,6 +2061,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