Skip to content

Commit a640fa0

Browse files
XanClicVladimir Sementsov-Ogievskiy
authored andcommitted
mirror: Do not clear .cancelled
Clearing .cancelled before leaving the main loop when the job has been soft-cancelled is no longer necessary since job_is_cancelled() only returns true for jobs that have been force-cancelled. Therefore, this only makes a differences in places that call job_cancel_requested(). In block/mirror.c, this is done only before .cancelled was cleared. In job.c, there are two callers: - job_completed_txn_abort() asserts that .cancelled is true, so keeping it true will not affect this place. - job_complete() refuses to let a job complete that has .cancelled set. It is correct to refuse to let the user invoke job-complete on mirror jobs that have already been soft-cancelled. With this change, there are no places that reset .cancelled to false and so we can be sure that .force_cancel can only be true if .cancelled is true as well. Assert this in job_is_cancelled(). Signed-off-by: Hanna Reitz <[email protected]> Reviewed-by: Eric Blake <[email protected]> Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]> Message-Id: <[email protected]> Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>
1 parent 9b230ef commit a640fa0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

block/mirror.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
946946
while (!job_cancel_requested(&s->common.job) && !s->should_complete) {
947947
job_yield(&s->common.job);
948948
}
949-
s->common.job.cancelled = false;
950949
goto immediate_exit;
951950
}
952951

@@ -1085,7 +1084,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
10851084
* completion.
10861085
*/
10871086
assert(QLIST_EMPTY(&bs->tracked_requests));
1088-
s->common.job.cancelled = false;
10891087
need_drain = false;
10901088
break;
10911089
}

job.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ const char *job_type_str(const Job *job)
217217

218218
bool job_is_cancelled(Job *job)
219219
{
220-
return job->cancelled && job->force_cancel;
220+
/* force_cancel may be true only if cancelled is true, too */
221+
assert(job->cancelled || !job->force_cancel);
222+
return job->force_cancel;
221223
}
222224

223225
bool job_cancel_requested(Job *job)

0 commit comments

Comments
 (0)