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