yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-replication-assert-we-own-context-before-job_cancel_.patch

ddf19c
From 46887feac666d0d7633ff3f5af5721fe2a80a8ab Mon Sep 17 00:00:00 2001
ddf19c
From: Kevin Wolf <kwolf@redhat.com>
ddf19c
Date: Wed, 8 Apr 2020 17:29:13 +0100
ddf19c
Subject: [PATCH 2/6] replication: assert we own context before job_cancel_sync
ddf19c
ddf19c
RH-Author: Kevin Wolf <kwolf@redhat.com>
ddf19c
Message-id: <20200408172917.18712-3-kwolf@redhat.com>
ddf19c
Patchwork-id: 94595
ddf19c
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 2/6] replication: assert we own context before job_cancel_sync
ddf19c
Bugzilla: 1817621
ddf19c
RH-Acked-by: Eric Blake <eblake@redhat.com>
ddf19c
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
ddf19c
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ddf19c
ddf19c
From: Stefan Reiter <s.reiter@proxmox.com>
ddf19c
ddf19c
job_cancel_sync requires the job's lock to be held, all other callers
ddf19c
already do this (replication_stop, drive_backup_abort,
ddf19c
blockdev_backup_abort, job_cancel_sync_all, cancel_common).
ddf19c
ddf19c
In this case we're in a BlockDriver handler, so we already have a lock,
ddf19c
just assert that it is the same as the one used for the commit_job.
ddf19c
ddf19c
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
ddf19c
Message-Id: <20200407115651.69472-3-s.reiter@proxmox.com>
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
(cherry picked from commit 08558e33257ec796594bd411261028a93414a70c)
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 block/replication.c | 5 ++++-
ddf19c
 1 file changed, 4 insertions(+), 1 deletion(-)
ddf19c
ddf19c
diff --git a/block/replication.c b/block/replication.c
ddf19c
index 99532ce..0ce27ee 100644
ddf19c
--- a/block/replication.c
ddf19c
+++ b/block/replication.c
ddf19c
@@ -144,12 +144,15 @@ fail:
ddf19c
 static void replication_close(BlockDriverState *bs)
ddf19c
 {
ddf19c
     BDRVReplicationState *s = bs->opaque;
ddf19c
+    Job *commit_job;
ddf19c
 
ddf19c
     if (s->stage == BLOCK_REPLICATION_RUNNING) {
ddf19c
         replication_stop(s->rs, false, NULL);
ddf19c
     }
ddf19c
     if (s->stage == BLOCK_REPLICATION_FAILOVER) {
ddf19c
-        job_cancel_sync(&s->commit_job->job);
ddf19c
+        commit_job = &s->commit_job->job;
ddf19c
+        assert(commit_job->aio_context == qemu_get_current_aio_context());
ddf19c
+        job_cancel_sync(commit_job);
ddf19c
     }
ddf19c
 
ddf19c
     if (s->mode == REPLICATION_MODE_SECONDARY) {
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c