Blame SOURCES/kvm-jobs-remove-job_defer_to_main_loop.patch

383d26
From 580a6b0332f21a364e2b807dcf63434fddaceada Mon Sep 17 00:00:00 2001
383d26
From: John Snow <jsnow@redhat.com>
383d26
Date: Mon, 10 Sep 2018 18:17:47 +0200
383d26
Subject: [PATCH 09/25] jobs: remove job_defer_to_main_loop
383d26
383d26
RH-Author: John Snow <jsnow@redhat.com>
383d26
Message-id: <20180910181803.11781-10-jsnow@redhat.com>
383d26
Patchwork-id: 82107
383d26
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 09/25] jobs: remove job_defer_to_main_loop
383d26
Bugzilla: 1626061
383d26
RH-Acked-by: Max Reitz <mreitz@redhat.com>
383d26
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
383d26
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
383d26
383d26
Now that the job infrastructure is handling the job_completed call for
383d26
all implemented jobs, we can remove the interface that allowed jobs to
383d26
schedule their own completion.
383d26
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
Reviewed-by: Max Reitz <mreitz@redhat.com>
383d26
Message-id: 20180830015734.19765-10-jsnow@redhat.com
383d26
Signed-off-by: Max Reitz <mreitz@redhat.com>
383d26
(cherry picked from commit e21a1c9831fc80ae3f3c1affdfa43350035d8588)
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 include/qemu/job.h | 17 -----------------
383d26
 job.c              | 40 ++--------------------------------------
383d26
 2 files changed, 2 insertions(+), 55 deletions(-)
383d26
383d26
diff --git a/include/qemu/job.h b/include/qemu/job.h
383d26
index 952ac3a..04090ba 100644
383d26
--- a/include/qemu/job.h
383d26
+++ b/include/qemu/job.h
383d26
@@ -553,23 +553,6 @@ void job_finalize(Job *job, Error **errp);
383d26
  */
383d26
 void job_dismiss(Job **job, Error **errp);
383d26
 
383d26
-typedef void JobDeferToMainLoopFn(Job *job, void *opaque);
383d26
-
383d26
-/**
383d26
- * @job: The job
383d26
- * @fn: The function to run in the main loop
383d26
- * @opaque: The opaque value that is passed to @fn
383d26
- *
383d26
- * This function must be called by the main job coroutine just before it
383d26
- * returns.  @fn is executed in the main loop with the job AioContext acquired.
383d26
- *
383d26
- * Block jobs must call bdrv_unref(), bdrv_close(), and anything that uses
383d26
- * bdrv_drain_all() in the main loop.
383d26
- *
383d26
- * The @job AioContext is held while @fn executes.
383d26
- */
383d26
-void job_defer_to_main_loop(Job *job, JobDeferToMainLoopFn *fn, void *opaque);
383d26
-
383d26
 /**
383d26
  * Synchronously finishes the given @job. If @finish is given, it is called to
383d26
  * trigger completion or cancellation of the job.
383d26
diff --git a/job.c b/job.c
383d26
index 1acbcbc..f56e6a3 100644
383d26
--- a/job.c
383d26
+++ b/job.c
383d26
@@ -556,12 +556,8 @@ static void coroutine_fn job_co_entry(void *opaque)
383d26
     assert(job && job->driver && job->driver->run);
383d26
     job_pause_point(job);
383d26
     job->ret = job->driver->run(job, &job->err);
383d26
-    if (!job->deferred_to_main_loop) {
383d26
-        job->deferred_to_main_loop = true;
383d26
-        aio_bh_schedule_oneshot(qemu_get_aio_context(),
383d26
-                                job_exit,
383d26
-                                job);
383d26
-    }
383d26
+    job->deferred_to_main_loop = true;
383d26
+    aio_bh_schedule_oneshot(qemu_get_aio_context(), job_exit, job);
383d26
 }
383d26
 
383d26
 
383d26
@@ -964,38 +960,6 @@ void job_complete(Job *job, Error **errp)
383d26
     job->driver->complete(job, errp);
383d26
 }
383d26
 
383d26
-
383d26
-typedef struct {
383d26
-    Job *job;
383d26
-    JobDeferToMainLoopFn *fn;
383d26
-    void *opaque;
383d26
-} JobDeferToMainLoopData;
383d26
-
383d26
-static void job_defer_to_main_loop_bh(void *opaque)
383d26
-{
383d26
-    JobDeferToMainLoopData *data = opaque;
383d26
-    Job *job = data->job;
383d26
-    AioContext *aio_context = job->aio_context;
383d26
-
383d26
-    aio_context_acquire(aio_context);
383d26
-    data->fn(data->job, data->opaque);
383d26
-    aio_context_release(aio_context);
383d26
-
383d26
-    g_free(data);
383d26
-}
383d26
-
383d26
-void job_defer_to_main_loop(Job *job, JobDeferToMainLoopFn *fn, void *opaque)
383d26
-{
383d26
-    JobDeferToMainLoopData *data = g_malloc(sizeof(*data));
383d26
-    data->job = job;
383d26
-    data->fn = fn;
383d26
-    data->opaque = opaque;
383d26
-    job->deferred_to_main_loop = true;
383d26
-
383d26
-    aio_bh_schedule_oneshot(qemu_get_aio_context(),
383d26
-                            job_defer_to_main_loop_bh, data);
383d26
-}
383d26
-
383d26
 int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
383d26
 {
383d26
     Error *local_err = NULL;
383d26
-- 
383d26
1.8.3.1
383d26