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

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