diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2017-11-29 11:25:12 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-11-29 15:11:14 +0100 |
commit | 356f59b8757f47c0aca3e2e4e51d6010f64cade1 (patch) | |
tree | 485b5ad24c5e77c0b6b424aa26c4a31709b3343b /blockjob.c | |
parent | 5bf1d5a73a4a6d0e2d692bd02b6d7f3eedeed3b7 (diff) |
blockjob: introduce block_job_do_yield
Hide the clearing of job->busy in a single function, and set it
in block_job_enter. This lets block_job_do_yield verify that
qemu_coroutine_enter is not used while job->busy = false.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-By: Jeff Cody <jcody@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockjob.c')
-rw-r--r-- | blockjob.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/blockjob.c b/blockjob.c index db9e4fc89a..4d22b7d2fb 100644 --- a/blockjob.c +++ b/blockjob.c @@ -729,6 +729,15 @@ static bool block_job_should_pause(BlockJob *job) return job->pause_count > 0; } +static void block_job_do_yield(BlockJob *job) +{ + job->busy = false; + qemu_coroutine_yield(); + + /* Set by block_job_enter before re-entering the coroutine. */ + assert(job->busy); +} + void coroutine_fn block_job_pause_point(BlockJob *job) { assert(job && block_job_started(job)); @@ -746,9 +755,7 @@ void coroutine_fn block_job_pause_point(BlockJob *job) if (block_job_should_pause(job) && !block_job_is_cancelled(job)) { job->paused = true; - job->busy = false; - qemu_coroutine_yield(); /* wait for block_job_resume() */ - job->busy = true; + block_job_do_yield(job); job->paused = false; } @@ -778,9 +785,12 @@ void block_job_enter(BlockJob *job) return; } - if (!job->busy) { - bdrv_coroutine_enter(blk_bs(job->blk), job->co); + if (job->busy) { + return; } + + job->busy = true; + aio_co_wake(job->co); } bool block_job_is_cancelled(BlockJob *job) @@ -819,11 +829,9 @@ void block_job_yield(BlockJob *job) return; } - job->busy = false; if (!block_job_should_pause(job)) { - qemu_coroutine_yield(); + block_job_do_yield(job); } - job->busy = true; block_job_pause_point(job); } |