qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com
Subject: [Qemu-devel] [PATCH 09/10] blockjob: Remove AioContext notifiers
Date: Mon,  6 May 2019 19:18:04 +0200	[thread overview]
Message-ID: <20190506171805.14236-10-kwolf@redhat.com> (raw)
In-Reply-To: <20190506171805.14236-1-kwolf@redhat.com>

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>
---
 blockjob.c | 43 ++-----------------------------------------
 1 file changed, 2 insertions(+), 41 deletions(-)

diff --git a/blockjob.c b/blockjob.c
index 24e6093a9c..9ca942ba01 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 */
-- 
2.20.1



  parent reply	other threads:[~2019-05-06 17:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-06 17:17 [Qemu-devel] [PATCH 00/10] block: AioContext management, part 1 Kevin Wolf
2019-05-06 17:17 ` [Qemu-devel] [PATCH 01/10] block: Add bdrv_try_set_aio_context() Kevin Wolf
2019-05-06 17:17 ` [Qemu-devel] [PATCH 02/10] block: Make bdrv_attach/detach_aio_context() static Kevin Wolf
2019-05-06 17:17 ` [Qemu-devel] [PATCH 03/10] block: Move recursion to bdrv_set_aio_context() Kevin Wolf
2019-05-06 17:17 ` [Qemu-devel] [PATCH 04/10] block: Propagate AioContext change to parents Kevin Wolf
2019-05-06 17:18 ` [Qemu-devel] [PATCH 05/10] test-block-iothread: Test AioContext propagation through the tree Kevin Wolf
2019-05-06 17:18 ` [Qemu-devel] [PATCH 06/10] block: Implement .(can_)set_aio_ctx for BlockBackend Kevin Wolf
2019-05-06 17:18 ` [Qemu-devel] [PATCH 07/10] block: Add blk_set_allow_aio_context_change() Kevin Wolf
2019-05-06 17:18 ` [Qemu-devel] [PATCH 08/10] blockjob: Propagate AioContext change to all job nodes Kevin Wolf
2019-05-06 17:18 ` Kevin Wolf [this message]
2019-05-06 17:18 ` [Qemu-devel] [PATCH 10/10] test-block-iothread: Test AioContext propagation for block jobs Kevin Wolf
2019-05-20 11:08 ` [Qemu-devel] [PATCH 00/10] block: AioContext management, part 1 Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190506171805.14236-10-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).