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>
diff --git a/block/mirror.c b/block/mirror.c
index 8e1ad6e..9faffe4 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1179,6 +1179,14 @@
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 = {
.job_driver = {
.instance_size = sizeof(MirrorBlockJob),
@@ -1190,6 +1198,7 @@
.abort = mirror_abort,
.pause = mirror_pause,
.complete = mirror_complete,
+ .cancel = mirror_cancel,
},
.drained_poll = mirror_drained_poll,
};