Skip to content

Commit

Permalink
block: use the block job list in bdrv_drain_all()
Browse files Browse the repository at this point in the history
bdrv_drain_all() pauses all block jobs by using bdrv_next() to iterate
over all top-level BlockDriverStates. Therefore the code is unable to
find block jobs in other nodes.

This patch uses block_job_next() to iterate over all block jobs.

Signed-off-by: Alberto Garcia <[email protected]>
Message-id: 55ee7d7d4a65c28aa1a1b28823897ef326f328e2.1464346103.git.berto@igalia.com
Reviewed-by: Max Reitz <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
  • Loading branch information
bertogg authored and XanClic committed Jun 16, 2016
1 parent 4186904 commit eb1364c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions block/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,21 @@ void bdrv_drain_all(void)
bool busy = true;
BlockDriverState *bs;
BdrvNextIterator it;
BlockJob *job = NULL;
GSList *aio_ctxs = NULL, *ctx;

while ((job = block_job_next(job))) {
AioContext *aio_context = blk_get_aio_context(job->blk);

aio_context_acquire(aio_context);
block_job_pause(job);
aio_context_release(aio_context);
}

for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
AioContext *aio_context = bdrv_get_aio_context(bs);

aio_context_acquire(aio_context);
if (bs->job) {
block_job_pause(bs->job);
}
bdrv_parent_drained_begin(bs);
bdrv_io_unplugged_begin(bs);
bdrv_drain_recurse(bs);
Expand Down Expand Up @@ -340,12 +346,18 @@ void bdrv_drain_all(void)
aio_context_acquire(aio_context);
bdrv_io_unplugged_end(bs);
bdrv_parent_drained_end(bs);
if (bs->job) {
block_job_resume(bs->job);
}
aio_context_release(aio_context);
}
g_slist_free(aio_ctxs);

job = NULL;
while ((job = block_job_next(job))) {
AioContext *aio_context = blk_get_aio_context(job->blk);

aio_context_acquire(aio_context);
block_job_resume(job);
aio_context_release(aio_context);
}
}

/**
Expand Down

0 comments on commit eb1364c

Please sign in to comment.