26ba25
From f842ac5501037ccea54e3b6c8a7a2471b30aaea7 Mon Sep 17 00:00:00 2001
26ba25
From: Kevin Wolf <kwolf@redhat.com>
26ba25
Date: Wed, 10 Oct 2018 20:21:55 +0100
26ba25
Subject: [PATCH 29/49] job: Fix missing locking due to mismerge
26ba25
26ba25
RH-Author: Kevin Wolf <kwolf@redhat.com>
26ba25
Message-id: <20181010202213.7372-17-kwolf@redhat.com>
26ba25
Patchwork-id: 82607
26ba25
O-Subject: [RHEL-8 qemu-kvm PATCH 26/44] job: Fix missing locking due to mismerge
26ba25
Bugzilla: 1637976
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
26ba25
job_completed() had a problem with double locking that was recently
26ba25
fixed independently by two different commits:
26ba25
26ba25
"job: Fix nested aio_poll() hanging in job_txn_apply"
26ba25
"jobs: add exit shim"
26ba25
26ba25
One fix removed the first aio_context_acquire(), the other fix removed
26ba25
the other one. Now we have a bug again and the code is run without any
26ba25
locking.
26ba25
26ba25
Add it back in one of the places.
26ba25
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Reviewed-by: Max Reitz <mreitz@redhat.com>
26ba25
Reviewed-by: John Snow <jsnow@redhat.com>
26ba25
(cherry picked from commit d1756c780b7879fb64e41135feac781d84a1f995)
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 job.c | 4 ++++
26ba25
 1 file changed, 4 insertions(+)
26ba25
26ba25
diff --git a/job.c b/job.c
26ba25
index 5d117fb..db53163 100644
26ba25
--- a/job.c
26ba25
+++ b/job.c
26ba25
@@ -842,7 +842,11 @@ static void job_completed(Job *job)
26ba25
 static void job_exit(void *opaque)
26ba25
 {
26ba25
     Job *job = (Job *)opaque;
26ba25
+    AioContext *ctx = job->aio_context;
26ba25
+
26ba25
+    aio_context_acquire(ctx);
26ba25
     job_completed(job);
26ba25
+    aio_context_release(ctx);
26ba25
 }
26ba25
 
26ba25
 /**
26ba25
-- 
26ba25
1.8.3.1
26ba25