aboutsummaryrefslogtreecommitdiff
path: root/blockjob.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2019-05-06 19:18:04 +0200
committerKevin Wolf <kwolf@redhat.com>2019-05-20 17:08:56 +0200
commit657e1203203ccb48cb041ecb3f1799bec8349744 (patch)
tree4bf522411fbbc8908b83eef0fc621b65396b1df7 /blockjob.c
parent9ff7f0df8757c1c6ca582935c27db377a1eaeb22 (diff)
downloadqemu-657e1203203ccb48cb041ecb3f1799bec8349744.zip
qemu-657e1203203ccb48cb041ecb3f1799bec8349744.tar.gz
qemu-657e1203203ccb48cb041ecb3f1799bec8349744.tar.bz2
blockjob: Remove AioContext notifiers
The notifiers made sure that the job is quiesced and that the job->aio_context field is updated. The first part is unnecessary today since bdrv_set_aio_context_ignore() drains the block node, and this means drainig the block job, too. The second part can be done in the .set_aio_ctx callback of the block job BdrvChildRole. The notifiers were problematic because they poll the AioContext while the graph is in an inconsistent state with some nodes already in the new context, but others still in the old context. So removing the notifiers not only simplifies the code, but actually makes the code safer. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockjob.c')
-rw-r--r--blockjob.c43
1 files changed, 2 insertions, 41 deletions
diff --git a/blockjob.c b/blockjob.c
index 24e6093..9ca942b 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -81,10 +81,6 @@ BlockJob *block_job_get(const char *id)
}
}
-static void block_job_attached_aio_context(AioContext *new_context,
- void *opaque);
-static void block_job_detach_aio_context(void *opaque);
-
void block_job_free(Job *job)
{
BlockJob *bjob = container_of(job, BlockJob, job);
@@ -92,28 +88,10 @@ void block_job_free(Job *job)
bs->job = NULL;
block_job_remove_all_bdrv(bjob);
- blk_remove_aio_context_notifier(bjob->blk,
- block_job_attached_aio_context,
- block_job_detach_aio_context, bjob);
blk_unref(bjob->blk);
error_free(bjob->blocker);
}
-static void block_job_attached_aio_context(AioContext *new_context,
- void *opaque)
-{
- BlockJob *job = opaque;
- const JobDriver *drv = job->job.driver;
- BlockJobDriver *bjdrv = container_of(drv, BlockJobDriver, job_driver);
-
- job->job.aio_context = new_context;
- if (bjdrv->attached_aio_context) {
- bjdrv->attached_aio_context(job, new_context);
- }
-
- job_resume(&job->job);
-}
-
void block_job_drain(Job *job)
{
BlockJob *bjob = container_of(job, BlockJob, job);
@@ -126,23 +104,6 @@ void block_job_drain(Job *job)
}
}
-static void block_job_detach_aio_context(void *opaque)
-{
- BlockJob *job = opaque;
-
- /* In case the job terminates during aio_poll()... */
- job_ref(&job->job);
-
- job_pause(&job->job);
-
- while (!job->job.paused && !job_is_completed(&job->job)) {
- job_drain(&job->job);
- }
-
- job->job.aio_context = NULL;
- job_unref(&job->job);
-}
-
static char *child_job_get_parent_desc(BdrvChild *c)
{
BlockJob *job = c->opaque;
@@ -212,6 +173,8 @@ static void child_job_set_aio_ctx(BdrvChild *c, AioContext *ctx,
*ignore = g_slist_prepend(*ignore, sibling);
bdrv_set_aio_context_ignore(sibling->bs, ctx, ignore);
}
+
+ job->job.aio_context = ctx;
}
static const BdrvChildRole child_job = {
@@ -471,8 +434,6 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker);
- blk_add_aio_context_notifier(blk, block_job_attached_aio_context,
- block_job_detach_aio_context, job);
blk_set_allow_aio_context_change(blk, true);
/* Only set speed when necessary to avoid NotSupported error */