block/mirror: implement .cancel job handler

Cancel in-flight io on target to not waste the time.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20210205163720.887197-6-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2021-02-05 19:37:15 +03:00 committed by Eric Blake
parent 9820933b57
commit 521ff8b779

View File

@ -1179,6 +1179,14 @@ static bool mirror_drained_poll(BlockJob *job)
return !!s->in_flight; return !!s->in_flight;
} }
static void mirror_cancel(Job *job)
{
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
BlockDriverState *target = blk_bs(s->target);
bdrv_cancel_in_flight(target);
}
static const BlockJobDriver mirror_job_driver = { static const BlockJobDriver mirror_job_driver = {
.job_driver = { .job_driver = {
.instance_size = sizeof(MirrorBlockJob), .instance_size = sizeof(MirrorBlockJob),
@ -1190,6 +1198,7 @@ static const BlockJobDriver mirror_job_driver = {
.abort = mirror_abort, .abort = mirror_abort,
.pause = mirror_pause, .pause = mirror_pause,
.complete = mirror_complete, .complete = mirror_complete,
.cancel = mirror_cancel,
}, },
.drained_poll = mirror_drained_poll, .drained_poll = mirror_drained_poll,
}; };