aboutsummaryrefslogtreecommitdiff
path: root/blockjob.c
diff options
context:
space:
mode:
Diffstat (limited to 'blockjob.c')
-rw-r--r--blockjob.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/blockjob.c b/blockjob.c
index 0bf0a26af0..f4f9956678 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -379,7 +379,7 @@ static void block_job_conclude(BlockJob *job)
static void block_job_update_rc(BlockJob *job)
{
- if (!job->ret && block_job_is_cancelled(job)) {
+ if (!job->ret && job_is_cancelled(&job->job)) {
job->ret = -ECANCELED;
}
if (job->ret) {
@@ -438,7 +438,7 @@ static int block_job_finalize_single(BlockJob *job)
/* Emit events only if we actually started */
if (block_job_started(job)) {
- if (block_job_is_cancelled(job)) {
+ if (job_is_cancelled(&job->job)) {
block_job_event_cancelled(job);
} else {
const char *msg = NULL;
@@ -464,7 +464,7 @@ static void block_job_cancel_async(BlockJob *job, bool force)
job->user_paused = false;
job->pause_count--;
}
- job->cancelled = true;
+ job->job.cancelled = true;
/* To prevent 'force == false' overriding a previous 'force == true' */
job->force |= force;
}
@@ -519,7 +519,8 @@ static int block_job_finish_sync(BlockJob *job,
while (!job->completed) {
aio_poll(qemu_get_aio_context(), true);
}
- ret = (job->cancelled && job->ret == 0) ? -ECANCELED : job->ret;
+ ret = (job_is_cancelled(&job->job) && job->ret == 0)
+ ? -ECANCELED : job->ret;
job_unref(&job->job);
return ret;
}
@@ -557,7 +558,7 @@ static void block_job_completed_txn_abort(BlockJob *job)
other_job = QLIST_FIRST(&txn->jobs);
ctx = blk_get_aio_context(other_job->blk);
if (!other_job->completed) {
- assert(other_job->cancelled);
+ assert(job_is_cancelled(&other_job->job));
block_job_finish_sync(other_job, NULL, NULL);
}
block_job_finalize_single(other_job);
@@ -651,7 +652,9 @@ void block_job_complete(BlockJob *job, Error **errp)
if (job_apply_verb(&job->job, JOB_VERB_COMPLETE, errp)) {
return;
}
- if (job->pause_count || job->cancelled || !job->driver->complete) {
+ if (job->pause_count || job_is_cancelled(&job->job) ||
+ !job->driver->complete)
+ {
error_setg(errp, "The active block job '%s' cannot be completed",
job->job.id);
return;
@@ -1006,7 +1009,7 @@ void coroutine_fn block_job_pause_point(BlockJob *job)
if (!block_job_should_pause(job)) {
return;
}
- if (block_job_is_cancelled(job)) {
+ if (job_is_cancelled(&job->job)) {
return;
}
@@ -1014,7 +1017,7 @@ void coroutine_fn block_job_pause_point(BlockJob *job)
job->driver->pause(job);
}
- if (block_job_should_pause(job) && !block_job_is_cancelled(job)) {
+ if (block_job_should_pause(job) && !job_is_cancelled(&job->job)) {
JobStatus status = job->job.status;
job_state_transition(&job->job, status == JOB_STATUS_READY
? JOB_STATUS_STANDBY
@@ -1066,17 +1069,12 @@ void block_job_enter(BlockJob *job)
block_job_enter_cond(job, NULL);
}
-bool block_job_is_cancelled(BlockJob *job)
-{
- return job->cancelled;
-}
-
void block_job_sleep_ns(BlockJob *job, int64_t ns)
{
assert(job->busy);
/* Check cancellation *before* setting busy = false, too! */
- if (block_job_is_cancelled(job)) {
+ if (job_is_cancelled(&job->job)) {
return;
}
@@ -1092,7 +1090,7 @@ void block_job_yield(BlockJob *job)
assert(job->busy);
/* Check cancellation *before* setting busy = false, too! */
- if (block_job_is_cancelled(job)) {
+ if (job_is_cancelled(&job->job)) {
return;
}