blockjob: Remove BlockJob.driver

BlockJob.driver is redundant with Job.driver and only used in very few
places any more. Remove it.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Kevin Wolf 2018-05-14 14:51:21 +02:00
parent 456273b024
commit 9f6bb4c004
2 changed files with 10 additions and 10 deletions

View File

@ -103,10 +103,12 @@ static void block_job_attached_aio_context(AioContext *new_context,
void *opaque) void *opaque)
{ {
BlockJob *job = opaque; BlockJob *job = opaque;
const JobDriver *drv = job->job.driver;
BlockJobDriver *bjdrv = container_of(drv, BlockJobDriver, job_driver);
job->job.aio_context = new_context; job->job.aio_context = new_context;
if (job->driver->attached_aio_context) { if (bjdrv->attached_aio_context) {
job->driver->attached_aio_context(job, new_context); bjdrv->attached_aio_context(job, new_context);
} }
job_resume(&job->job); job_resume(&job->job);
@ -115,10 +117,12 @@ static void block_job_attached_aio_context(AioContext *new_context,
void block_job_drain(Job *job) void block_job_drain(Job *job)
{ {
BlockJob *bjob = container_of(job, BlockJob, job); BlockJob *bjob = container_of(job, BlockJob, job);
const JobDriver *drv = job->driver;
BlockJobDriver *bjdrv = container_of(drv, BlockJobDriver, job_driver);
blk_drain(bjob->blk); blk_drain(bjob->blk);
if (bjob->driver->drain) { if (bjdrv->drain) {
bjob->driver->drain(bjob); bjdrv->drain(bjob);
} }
} }
@ -201,7 +205,7 @@ bool block_job_is_internal(BlockJob *job)
const BlockJobDriver *block_job_driver(BlockJob *job) const BlockJobDriver *block_job_driver(BlockJob *job)
{ {
return job->driver; return container_of(job->job.driver, BlockJobDriver, job_driver);
} }
/* Assumes the job_mutex is held */ /* Assumes the job_mutex is held */
@ -386,7 +390,6 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
assert(job->job.driver->user_resume == &block_job_user_resume); assert(job->job.driver->user_resume == &block_job_user_resume);
assert(job->job.driver->drain == &block_job_drain); assert(job->job.driver->drain == &block_job_drain);
job->driver = driver;
job->blk = blk; job->blk = blk;
job->finalize_cancelled_notifier.notify = block_job_event_cancelled; job->finalize_cancelled_notifier.notify = block_job_event_cancelled;

View File

@ -43,9 +43,6 @@ typedef struct BlockJob {
/** Data belonging to the generic Job infrastructure */ /** Data belonging to the generic Job infrastructure */
Job job; Job job;
/** The job type, including the job vtable. */
const BlockJobDriver *driver;
/** The block device on which the job is operating. */ /** The block device on which the job is operating. */
BlockBackend *blk; BlockBackend *blk;