summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy2021-02-05 17:37:15 +0100
committerEric Blake2021-02-12 18:29:40 +0100
commit521ff8b779b11c394dbdc43f02e158dd99df308a (patch)
tree4b4d202e5db680dc342e5e96ae71b0f2ae5da050
parentjob: add .cancel handler for the driver (diff)
downloadqemu-521ff8b779b11c394dbdc43f02e158dd99df308a.tar.gz
qemu-521ff8b779b11c394dbdc43f02e158dd99df308a.tar.xz
qemu-521ff8b779b11c394dbdc43f02e158dd99df308a.zip
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>
-rw-r--r--block/mirror.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/block/mirror.c b/block/mirror.c
index 8e1ad6eceb..9faffe4707 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1179,6 +1179,14 @@ static bool mirror_drained_poll(BlockJob *job)
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 @@ static const BlockJobDriver mirror_job_driver = {
.abort = mirror_abort,
.pause = mirror_pause,
.complete = mirror_complete,
+ .cancel = mirror_cancel,
},
.drained_poll = mirror_drained_poll,
};