Skip to content

Commit

Permalink
block: Pause block jobs in bdrv_drain_all
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Fam Zheng authored and kevmw committed Apr 28, 2015
1 parent 751ebd7 commit 69da3b0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions block.c
Expand Up @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit 69da3b0

Please sign in to comment.