|
|
383d26 |
From 583fce2c4839f5b0f3da8794182cc7738311a991 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Date: Mon, 10 Sep 2018 18:17:58 +0200
|
|
|
383d26 |
Subject: [PATCH 20/25] jobs: remove .exit callback
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Message-id: <20180910181803.11781-21-jsnow@redhat.com>
|
|
|
383d26 |
Patchwork-id: 82101
|
|
|
383d26 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 20/25] jobs: remove .exit callback
|
|
|
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 all of the jobs use the component finalization callbacks,
|
|
|
383d26 |
there's no use for the heavy-hammer .exit callback anymore.
|
|
|
383d26 |
|
|
|
383d26 |
job_exit becomes a glorified type shim so that we can call
|
|
|
383d26 |
job_completed from aio_bh_schedule_oneshot.
|
|
|
383d26 |
|
|
|
383d26 |
Move these three functions down into job.c to eliminate a
|
|
|
383d26 |
forward reference.
|
|
|
383d26 |
|
|
|
383d26 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
Message-id: 20180906130225.5118-12-jsnow@redhat.com
|
|
|
383d26 |
Reviewed-by: Jeff Cody <jcody@redhat.com>
|
|
|
383d26 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
(cherry picked from commit 7e9e7780ef18e902a6458dfa6b024d9e2053923c)
|
|
|
383d26 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
include/qemu/job.h | 11 --------
|
|
|
383d26 |
job.c | 77 ++++++++++++++++++++++++------------------------------
|
|
|
383d26 |
2 files changed, 34 insertions(+), 54 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
|
|
383d26 |
index 04090ba..fdaa06f 100644
|
|
|
383d26 |
--- a/include/qemu/job.h
|
|
|
383d26 |
+++ b/include/qemu/job.h
|
|
|
383d26 |
@@ -222,17 +222,6 @@ struct JobDriver {
|
|
|
383d26 |
void (*drain)(Job *job);
|
|
|
383d26 |
|
|
|
383d26 |
/**
|
|
|
383d26 |
- * If the callback is not NULL, exit will be invoked from the main thread
|
|
|
383d26 |
- * when the job's coroutine has finished, but before transactional
|
|
|
383d26 |
- * convergence; before @prepare or @abort.
|
|
|
383d26 |
- *
|
|
|
383d26 |
- * FIXME TODO: This callback is only temporary to transition remaining jobs
|
|
|
383d26 |
- * to prepare/commit/abort/clean callbacks and will be removed before 3.1.
|
|
|
383d26 |
- * is released.
|
|
|
383d26 |
- */
|
|
|
383d26 |
- void (*exit)(Job *job);
|
|
|
383d26 |
-
|
|
|
383d26 |
- /**
|
|
|
383d26 |
* If the callback is not NULL, prepare will be invoked when all the jobs
|
|
|
383d26 |
* belonging to the same transaction complete; or upon this job's completion
|
|
|
383d26 |
* if it is not in a transaction.
|
|
|
383d26 |
diff --git a/job.c b/job.c
|
|
|
383d26 |
index f56e6a3..dfba4bc 100644
|
|
|
383d26 |
--- a/job.c
|
|
|
383d26 |
+++ b/job.c
|
|
|
383d26 |
@@ -530,49 +530,6 @@ void job_drain(Job *job)
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
-static void job_completed(Job *job);
|
|
|
383d26 |
-
|
|
|
383d26 |
-static void job_exit(void *opaque)
|
|
|
383d26 |
-{
|
|
|
383d26 |
- Job *job = (Job *)opaque;
|
|
|
383d26 |
- AioContext *aio_context = job->aio_context;
|
|
|
383d26 |
-
|
|
|
383d26 |
- if (job->driver->exit) {
|
|
|
383d26 |
- aio_context_acquire(aio_context);
|
|
|
383d26 |
- job->driver->exit(job);
|
|
|
383d26 |
- aio_context_release(aio_context);
|
|
|
383d26 |
- }
|
|
|
383d26 |
- job_completed(job);
|
|
|
383d26 |
-}
|
|
|
383d26 |
-
|
|
|
383d26 |
-/**
|
|
|
383d26 |
- * All jobs must allow a pause point before entering their job proper. This
|
|
|
383d26 |
- * ensures that jobs can be paused prior to being started, then resumed later.
|
|
|
383d26 |
- */
|
|
|
383d26 |
-static void coroutine_fn job_co_entry(void *opaque)
|
|
|
383d26 |
-{
|
|
|
383d26 |
- Job *job = opaque;
|
|
|
383d26 |
-
|
|
|
383d26 |
- assert(job && job->driver && job->driver->run);
|
|
|
383d26 |
- job_pause_point(job);
|
|
|
383d26 |
- job->ret = job->driver->run(job, &job->err);
|
|
|
383d26 |
- job->deferred_to_main_loop = true;
|
|
|
383d26 |
- aio_bh_schedule_oneshot(qemu_get_aio_context(), job_exit, job);
|
|
|
383d26 |
-}
|
|
|
383d26 |
-
|
|
|
383d26 |
-
|
|
|
383d26 |
-void job_start(Job *job)
|
|
|
383d26 |
-{
|
|
|
383d26 |
- assert(job && !job_started(job) && job->paused &&
|
|
|
383d26 |
- job->driver && job->driver->run);
|
|
|
383d26 |
- job->co = qemu_coroutine_create(job_co_entry, job);
|
|
|
383d26 |
- job->pause_count--;
|
|
|
383d26 |
- job->busy = true;
|
|
|
383d26 |
- job->paused = false;
|
|
|
383d26 |
- job_state_transition(job, JOB_STATUS_RUNNING);
|
|
|
383d26 |
- aio_co_enter(job->aio_context, job->co);
|
|
|
383d26 |
-}
|
|
|
383d26 |
-
|
|
|
383d26 |
/* Assumes the block_job_mutex is held */
|
|
|
383d26 |
static bool job_timer_not_pending(Job *job)
|
|
|
383d26 |
{
|
|
|
383d26 |
@@ -889,6 +846,40 @@ static void job_completed(Job *job)
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
+/** Useful only as a type shim for aio_bh_schedule_oneshot. */
|
|
|
383d26 |
+static void job_exit(void *opaque)
|
|
|
383d26 |
+{
|
|
|
383d26 |
+ Job *job = (Job *)opaque;
|
|
|
383d26 |
+ job_completed(job);
|
|
|
383d26 |
+}
|
|
|
383d26 |
+
|
|
|
383d26 |
+/**
|
|
|
383d26 |
+ * All jobs must allow a pause point before entering their job proper. This
|
|
|
383d26 |
+ * ensures that jobs can be paused prior to being started, then resumed later.
|
|
|
383d26 |
+ */
|
|
|
383d26 |
+static void coroutine_fn job_co_entry(void *opaque)
|
|
|
383d26 |
+{
|
|
|
383d26 |
+ Job *job = opaque;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ assert(job && job->driver && job->driver->run);
|
|
|
383d26 |
+ job_pause_point(job);
|
|
|
383d26 |
+ job->ret = job->driver->run(job, &job->err);
|
|
|
383d26 |
+ job->deferred_to_main_loop = true;
|
|
|
383d26 |
+ aio_bh_schedule_oneshot(qemu_get_aio_context(), job_exit, job);
|
|
|
383d26 |
+}
|
|
|
383d26 |
+
|
|
|
383d26 |
+void job_start(Job *job)
|
|
|
383d26 |
+{
|
|
|
383d26 |
+ assert(job && !job_started(job) && job->paused &&
|
|
|
383d26 |
+ job->driver && job->driver->run);
|
|
|
383d26 |
+ job->co = qemu_coroutine_create(job_co_entry, job);
|
|
|
383d26 |
+ job->pause_count--;
|
|
|
383d26 |
+ job->busy = true;
|
|
|
383d26 |
+ job->paused = false;
|
|
|
383d26 |
+ job_state_transition(job, JOB_STATUS_RUNNING);
|
|
|
383d26 |
+ aio_co_enter(job->aio_context, job->co);
|
|
|
383d26 |
+}
|
|
|
383d26 |
+
|
|
|
383d26 |
void job_cancel(Job *job, bool force)
|
|
|
383d26 |
{
|
|
|
383d26 |
if (job->status == JOB_STATUS_CONCLUDED) {
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|