[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 17/46] job: Add Job.aio_context
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 17/46] job: Add Job.aio_context |
Date: |
Wed, 23 May 2018 15:11:26 +0200 |
When block jobs need an AioContext, they just take it from their main
block node. Generic jobs don't have a main block node, so we need to
assign them an AioContext explicitly.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: John Snow <address@hidden>
---
include/qemu/job.h | 7 ++++++-
blockjob.c | 5 ++++-
job.c | 4 +++-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/include/qemu/job.h b/include/qemu/job.h
index 5dfbec5d69..01e083f97a 100644
--- a/include/qemu/job.h
+++ b/include/qemu/job.h
@@ -47,6 +47,9 @@ typedef struct Job {
/** Current state; See @JobStatus for details. */
JobStatus status;
+ /** AioContext to run the job coroutine in */
+ AioContext *aio_context;
+
/**
* Set to true if the job should cancel itself. The flag must
* always be tested just before toggling the busy flag from false
@@ -79,9 +82,11 @@ struct JobDriver {
*
* @job_id: The id of the newly-created job, or %NULL for internal jobs
* @driver: The class object for the newly-created job.
+ * @ctx: The AioContext to run the job coroutine in.
* @errp: Error object.
*/
-void *job_create(const char *job_id, const JobDriver *driver, Error **errp);
+void *job_create(const char *job_id, const JobDriver *driver, AioContext *ctx,
+ Error **errp);
/**
* Add a reference to Job refcnt, it will be decreased with job_unref, and then
diff --git a/blockjob.c b/blockjob.c
index f4f9956678..0a0b1c41dd 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -216,6 +216,7 @@ static void block_job_attached_aio_context(AioContext
*new_context,
{
BlockJob *job = opaque;
+ job->job.aio_context = new_context;
if (job->driver->attached_aio_context) {
job->driver->attached_aio_context(job, new_context);
}
@@ -247,6 +248,7 @@ static void block_job_detach_aio_context(void *opaque)
block_job_drain(job);
}
+ job->job.aio_context = NULL;
job_unref(&job->job);
}
@@ -899,7 +901,8 @@ void *block_job_create(const char *job_id, const
BlockJobDriver *driver,
return NULL;
}
- job = job_create(job_id, &driver->job_driver, errp);
+ job = job_create(job_id, &driver->job_driver, blk_get_aio_context(blk),
+ errp);
if (job == NULL) {
blk_unref(blk);
return NULL;
diff --git a/job.c b/job.c
index 1abca6a2fc..01074d0fae 100644
--- a/job.c
+++ b/job.c
@@ -121,7 +121,8 @@ Job *job_get(const char *id)
return NULL;
}
-void *job_create(const char *job_id, const JobDriver *driver, Error **errp)
+void *job_create(const char *job_id, const JobDriver *driver, AioContext *ctx,
+ Error **errp)
{
Job *job;
@@ -140,6 +141,7 @@ void *job_create(const char *job_id, const JobDriver
*driver, Error **errp)
job->driver = driver;
job->id = g_strdup(job_id);
job->refcnt = 1;
+ job->aio_context = ctx;
job_state_transition(job, JOB_STATUS_CREATED);
--
2.13.6
- [Qemu-block] [PULL 03/46] qemu-iotests: 086 doesn't work with NFS, (continued)
- [Qemu-block] [PULL 03/46] qemu-iotests: 086 doesn't work with NFS, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 10/46] job: Rename BlockJobType into JobType, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 08/46] blockjob: Improve BlockJobInfo.offset/len documentation, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 06/46] qemu-iotests: Remove MIG_SOCKET from non-migration tests, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 02/46] qemu-iotests: Filter NFS paths, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 04/46] sheepdog: Remove unnecessary NULL check in sd_prealloc(), Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 05/46] qemu-iotests: Add more tests to "migration" group, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 11/46] job: Add JobDriver.job_type, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 12/46] job: Add job_delete(), Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 07/46] blockjob: Update block-job-pause/resume documentation, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 17/46] job: Add Job.aio_context,
Kevin Wolf <=
- [Qemu-block] [PULL 18/46] job: Move defer_to_main_loop to Job, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 09/46] job: Create Job, JobDriver and job_create(), Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 16/46] job: Move cancelled to Job, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 13/46] job: Maintain a list of all jobs, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 14/46] job: Move state transitions to Job, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 15/46] job: Add reference counting, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 22/46] job: Replace BlockJob.completed with job_is_completed(), Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 21/46] job: Move pause/resume functions to Job, Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 24/46] blockjob: Split block_job_event_pending(), Kevin Wolf, 2018/05/23
- [Qemu-block] [PULL 23/46] job: Move BlockJobCreateFlags to Job, Kevin Wolf, 2018/05/23