yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
26ba25
From 2278ae1bb1dbbf0038e4bcc96ecdd875498c5eec Mon Sep 17 00:00:00 2001
26ba25
From: Kevin Wolf <kwolf@redhat.com>
26ba25
Date: Tue, 26 Jun 2018 09:48:34 +0200
26ba25
Subject: [PATCH 126/268] blockjob: Remove BlockJob.driver
26ba25
26ba25
RH-Author: Kevin Wolf <kwolf@redhat.com>
26ba25
Message-id: <20180626094856.6924-52-kwolf@redhat.com>
26ba25
Patchwork-id: 81123
26ba25
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 51/73] blockjob: Remove BlockJob.driver
26ba25
Bugzilla: 1513543
26ba25
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: Fam Zheng <famz@redhat.com>
26ba25
26ba25
BlockJob.driver is redundant with Job.driver and only used in very few
26ba25
places any more. Remove it.
26ba25
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
(cherry picked from commit 9f6bb4c004a6458227b9eec6aff3f79afe159699)
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 blockjob.c               | 17 ++++++++++-------
26ba25
 include/block/blockjob.h |  3 ---
26ba25
 2 files changed, 10 insertions(+), 10 deletions(-)
26ba25
26ba25
diff --git a/blockjob.c b/blockjob.c
26ba25
index 5c8ff6f..0306533 100644
26ba25
--- a/blockjob.c
26ba25
+++ b/blockjob.c
26ba25
@@ -103,10 +103,12 @@ static void block_job_attached_aio_context(AioContext *new_context,
26ba25
                                            void *opaque)
26ba25
 {
26ba25
     BlockJob *job = opaque;
26ba25
+    const JobDriver *drv = job->job.driver;
26ba25
+    BlockJobDriver *bjdrv = container_of(drv, BlockJobDriver, job_driver);
26ba25
 
26ba25
     job->job.aio_context = new_context;
26ba25
-    if (job->driver->attached_aio_context) {
26ba25
-        job->driver->attached_aio_context(job, new_context);
26ba25
+    if (bjdrv->attached_aio_context) {
26ba25
+        bjdrv->attached_aio_context(job, new_context);
26ba25
     }
26ba25
 
26ba25
     job_resume(&job->job);
26ba25
@@ -115,10 +117,12 @@ static void block_job_attached_aio_context(AioContext *new_context,
26ba25
 void block_job_drain(Job *job)
26ba25
 {
26ba25
     BlockJob *bjob = container_of(job, BlockJob, job);
26ba25
+    const JobDriver *drv = job->driver;
26ba25
+    BlockJobDriver *bjdrv = container_of(drv, BlockJobDriver, job_driver);
26ba25
 
26ba25
     blk_drain(bjob->blk);
26ba25
-    if (bjob->driver->drain) {
26ba25
-        bjob->driver->drain(bjob);
26ba25
+    if (bjdrv->drain) {
26ba25
+        bjdrv->drain(bjob);
26ba25
     }
26ba25
 }
26ba25
 
26ba25
@@ -201,7 +205,7 @@ bool block_job_is_internal(BlockJob *job)
26ba25
 
26ba25
 const BlockJobDriver *block_job_driver(BlockJob *job)
26ba25
 {
26ba25
-    return job->driver;
26ba25
+    return container_of(job->job.driver, BlockJobDriver, job_driver);
26ba25
 }
26ba25
 
26ba25
 /* Assumes the job_mutex is held */
26ba25
@@ -386,8 +390,7 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
26ba25
     assert(job->job.driver->user_resume == &block_job_user_resume);
26ba25
     assert(job->job.driver->drain == &block_job_drain);
26ba25
 
26ba25
-    job->driver        = driver;
26ba25
-    job->blk           = blk;
26ba25
+    job->blk = blk;
26ba25
 
26ba25
     job->finalize_cancelled_notifier.notify = block_job_event_cancelled;
26ba25
     job->finalize_completed_notifier.notify = block_job_event_completed;
26ba25
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
26ba25
index 3021d11..32c00b7 100644
26ba25
--- a/include/block/blockjob.h
26ba25
+++ b/include/block/blockjob.h
26ba25
@@ -43,9 +43,6 @@ typedef struct BlockJob {
26ba25
     /** Data belonging to the generic Job infrastructure */
26ba25
     Job job;
26ba25
 
26ba25
-    /** The job type, including the job vtable.  */
26ba25
-    const BlockJobDriver *driver;
26ba25
-
26ba25
     /** The block device on which the job is operating.  */
26ba25
     BlockBackend *blk;
26ba25
 
26ba25
-- 
26ba25
1.8.3.1
26ba25