mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
job: Convert block_job_cancel_async() to Job
block_job_cancel_async() did two things that were still block job specific: * Setting job->force. This field makes sense on the Job level, so we can just move it. While at it, rename it to job->force_cancel to make its purpose more obvious. * Resetting the I/O status. This can't be moved because generic Jobs don't have an I/O status. What the function really implements is a user resume, except without entering the coroutine. Consequently, it makes sense to call the .user_resume driver callback here which already resets the I/O status. The old block_job_cancel_async() has two separate if statements that check job->iostatus != BLOCK_DEVICE_IO_STATUS_OK and job->user_paused. However, the former condition always implies the latter (as is asserted in block_job_iostatus_reset()), so changing the explicit call of block_job_iostatus_reset() on the former condition with the .user_resume callback on the latter condition is equivalent and doesn't need to access any BlockJob specific state. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
4ad351819b
commit
004e95df98
4 changed files with 21 additions and 20 deletions
|
@ -871,7 +871,7 @@ static void coroutine_fn mirror_run(void *opaque)
|
|||
trace_mirror_before_sleep(s, cnt, s->synced, delay_ns);
|
||||
job_sleep_ns(&s->common.job, delay_ns);
|
||||
if (job_is_cancelled(&s->common.job) &&
|
||||
(!s->synced || s->common.force))
|
||||
(!s->synced || s->common.job.force_cancel))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -884,7 +884,7 @@ immediate_exit:
|
|||
* or it was cancelled prematurely so that we do not guarantee that
|
||||
* the target is a copy of the source.
|
||||
*/
|
||||
assert(ret < 0 || ((s->common.force || !s->synced) &&
|
||||
assert(ret < 0 || ((s->common.job.force_cancel || !s->synced) &&
|
||||
job_is_cancelled(&s->common.job)));
|
||||
assert(need_drain);
|
||||
mirror_wait_for_all_io(s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue