|
|
383d26 |
From 25511b69b93fae007b86ccf1410585e6288c2b78 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Date: Tue, 26 Jun 2018 09:48:07 +0200
|
|
|
383d26 |
Subject: [PATCH 38/89] job: Add Job.aio_context
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Message-id: <20180626094856.6924-25-kwolf@redhat.com>
|
|
|
383d26 |
Patchwork-id: 81075
|
|
|
383d26 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 24/73] job: Add Job.aio_context
|
|
|
383d26 |
Bugzilla: 1513543
|
|
|
383d26 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
When block jobs need an AioContext, they just take it from their main
|
|
|
383d26 |
block node. Generic jobs don't have a main block node, so we need to
|
|
|
383d26 |
assign them an AioContext explicitly.
|
|
|
383d26 |
|
|
|
383d26 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
Reviewed-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
(cherry picked from commit 08be6fe26f6c76d900fc987f58d322b94bc4e248)
|
|
|
383d26 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
blockjob.c | 5 ++++-
|
|
|
383d26 |
include/qemu/job.h | 7 ++++++-
|
|
|
383d26 |
job.c | 4 +++-
|
|
|
383d26 |
3 files changed, 13 insertions(+), 3 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/blockjob.c b/blockjob.c
|
|
|
383d26 |
index f4f9956..0a0b1c4 100644
|
|
|
383d26 |
--- a/blockjob.c
|
|
|
383d26 |
+++ b/blockjob.c
|
|
|
383d26 |
@@ -216,6 +216,7 @@ static void block_job_attached_aio_context(AioContext *new_context,
|
|
|
383d26 |
{
|
|
|
383d26 |
BlockJob *job = opaque;
|
|
|
383d26 |
|
|
|
383d26 |
+ job->job.aio_context = new_context;
|
|
|
383d26 |
if (job->driver->attached_aio_context) {
|
|
|
383d26 |
job->driver->attached_aio_context(job, new_context);
|
|
|
383d26 |
}
|
|
|
383d26 |
@@ -247,6 +248,7 @@ static void block_job_detach_aio_context(void *opaque)
|
|
|
383d26 |
block_job_drain(job);
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
+ job->job.aio_context = NULL;
|
|
|
383d26 |
job_unref(&job->job);
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
@@ -899,7 +901,8 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
|
|
|
383d26 |
return NULL;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
- job = job_create(job_id, &driver->job_driver, errp);
|
|
|
383d26 |
+ job = job_create(job_id, &driver->job_driver, blk_get_aio_context(blk),
|
|
|
383d26 |
+ errp);
|
|
|
383d26 |
if (job == NULL) {
|
|
|
383d26 |
blk_unref(blk);
|
|
|
383d26 |
return NULL;
|
|
|
383d26 |
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
|
|
383d26 |
index 5dfbec5..01e083f 100644
|
|
|
383d26 |
--- a/include/qemu/job.h
|
|
|
383d26 |
+++ b/include/qemu/job.h
|
|
|
383d26 |
@@ -47,6 +47,9 @@ typedef struct Job {
|
|
|
383d26 |
/** Current state; See @JobStatus for details. */
|
|
|
383d26 |
JobStatus status;
|
|
|
383d26 |
|
|
|
383d26 |
+ /** AioContext to run the job coroutine in */
|
|
|
383d26 |
+ AioContext *aio_context;
|
|
|
383d26 |
+
|
|
|
383d26 |
/**
|
|
|
383d26 |
* Set to true if the job should cancel itself. The flag must
|
|
|
383d26 |
* always be tested just before toggling the busy flag from false
|
|
|
383d26 |
@@ -79,9 +82,11 @@ struct JobDriver {
|
|
|
383d26 |
*
|
|
|
383d26 |
* @job_id: The id of the newly-created job, or %NULL for internal jobs
|
|
|
383d26 |
* @driver: The class object for the newly-created job.
|
|
|
383d26 |
+ * @ctx: The AioContext to run the job coroutine in.
|
|
|
383d26 |
* @errp: Error object.
|
|
|
383d26 |
*/
|
|
|
383d26 |
-void *job_create(const char *job_id, const JobDriver *driver, Error **errp);
|
|
|
383d26 |
+void *job_create(const char *job_id, const JobDriver *driver, AioContext *ctx,
|
|
|
383d26 |
+ Error **errp);
|
|
|
383d26 |
|
|
|
383d26 |
/**
|
|
|
383d26 |
* Add a reference to Job refcnt, it will be decreased with job_unref, and then
|
|
|
383d26 |
diff --git a/job.c b/job.c
|
|
|
383d26 |
index 1abca6a..01074d0 100644
|
|
|
383d26 |
--- a/job.c
|
|
|
383d26 |
+++ b/job.c
|
|
|
383d26 |
@@ -121,7 +121,8 @@ Job *job_get(const char *id)
|
|
|
383d26 |
return NULL;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
-void *job_create(const char *job_id, const JobDriver *driver, Error **errp)
|
|
|
383d26 |
+void *job_create(const char *job_id, const JobDriver *driver, AioContext *ctx,
|
|
|
383d26 |
+ Error **errp)
|
|
|
383d26 |
{
|
|
|
383d26 |
Job *job;
|
|
|
383d26 |
|
|
|
383d26 |
@@ -140,6 +141,7 @@ void *job_create(const char *job_id, const JobDriver *driver, Error **errp)
|
|
|
383d26 |
job->driver = driver;
|
|
|
383d26 |
job->id = g_strdup(job_id);
|
|
|
383d26 |
job->refcnt = 1;
|
|
|
383d26 |
+ job->aio_context = ctx;
|
|
|
383d26 |
|
|
|
383d26 |
job_state_transition(job, JOB_STATUS_CREATED);
|
|
|
383d26 |
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|