Blame SOURCES/kvm-blockjob-introduce-block_job_do_yield.patch

4a2fec
From dace2b99ec7489bdabb4beeb429ec44427805d90 Mon Sep 17 00:00:00 2001
4a2fec
From: Jeffrey Cody <jcody@redhat.com>
4a2fec
Date: Thu, 30 Nov 2017 22:49:14 +0100
4a2fec
Subject: [PATCH 10/21] blockjob: introduce block_job_do_yield
4a2fec
4a2fec
RH-Author: Jeffrey Cody <jcody@redhat.com>
4a2fec
Message-id: <331a28f9c09b1ce40dd95f7b21ded200ab46713d.1511985875.git.jcody@redhat.com>
4a2fec
Patchwork-id: 78046
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 10/11] blockjob: introduce block_job_do_yield
4a2fec
Bugzilla: 1506531
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: John Snow <jsnow@redhat.com>
4a2fec
4a2fec
From: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
4a2fec
Hide the clearing of job->busy in a single function, and set it
4a2fec
in block_job_enter.  This lets block_job_do_yield verify that
4a2fec
qemu_coroutine_enter is not used while job->busy = false.
4a2fec
4a2fec
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
Tested-By: Jeff Cody <jcody@redhat.com>
4a2fec
Reviewed-by: Fam Zheng <famz@redhat.com>
4a2fec
Reviewed-by: Jeff Cody <jcody@redhat.com>
4a2fec
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4a2fec
(cherry picked from commit 356f59b8757f47c0aca3e2e4e51d6010f64cade1)
4a2fec
Signed-off-by: Jeff Cody <jcody@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 blockjob.c | 24 ++++++++++++++++--------
4a2fec
 1 file changed, 16 insertions(+), 8 deletions(-)
4a2fec
4a2fec
diff --git a/blockjob.c b/blockjob.c
4a2fec
index 4d78046..e960b3e 100644
4a2fec
--- a/blockjob.c
4a2fec
+++ b/blockjob.c
4a2fec
@@ -729,6 +729,15 @@ static bool block_job_should_pause(BlockJob *job)
4a2fec
     return job->pause_count > 0;
4a2fec
 }
4a2fec
 
4a2fec
+static void block_job_do_yield(BlockJob *job)
4a2fec
+{
4a2fec
+    job->busy = false;
4a2fec
+    qemu_coroutine_yield();
4a2fec
+
4a2fec
+    /* Set by block_job_enter before re-entering the coroutine.  */
4a2fec
+    assert(job->busy);
4a2fec
+}
4a2fec
+
4a2fec
 void coroutine_fn block_job_pause_point(BlockJob *job)
4a2fec
 {
4a2fec
     assert(job && block_job_started(job));
4a2fec
@@ -746,9 +755,7 @@ void coroutine_fn block_job_pause_point(BlockJob *job)
4a2fec
 
4a2fec
     if (block_job_should_pause(job) && !block_job_is_cancelled(job)) {
4a2fec
         job->paused = true;
4a2fec
-        job->busy = false;
4a2fec
-        qemu_coroutine_yield(); /* wait for block_job_resume() */
4a2fec
-        job->busy = true;
4a2fec
+        block_job_do_yield(job);
4a2fec
         job->paused = false;
4a2fec
     }
4a2fec
 
4a2fec
@@ -778,9 +785,12 @@ void block_job_enter(BlockJob *job)
4a2fec
         return;
4a2fec
     }
4a2fec
 
4a2fec
-    if (!job->busy) {
4a2fec
-        bdrv_coroutine_enter(blk_bs(job->blk), job->co);
4a2fec
+    if (job->busy) {
4a2fec
+        return;
4a2fec
     }
4a2fec
+
4a2fec
+    job->busy = true;
4a2fec
+    aio_co_wake(job->co);
4a2fec
 }
4a2fec
 
4a2fec
 bool block_job_is_cancelled(BlockJob *job)
4a2fec
@@ -819,11 +829,9 @@ void block_job_yield(BlockJob *job)
4a2fec
         return;
4a2fec
     }
4a2fec
 
4a2fec
-    job->busy = false;
4a2fec
     if (!block_job_should_pause(job)) {
4a2fec
-        qemu_coroutine_yield();
4a2fec
+        block_job_do_yield(job);
4a2fec
     }
4a2fec
-    job->busy = true;
4a2fec
 
4a2fec
     block_job_pause_point(job);
4a2fec
 }
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec