All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, mreitz@redhat.com,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [RFC PATCH 3/5] job: Drop AioContext lock around aio_poll()
Date: Fri, 17 Aug 2018 19:02:44 +0200	[thread overview]
Message-ID: <20180817170246.14641-4-kwolf@redhat.com> (raw)
In-Reply-To: <20180817170246.14641-1-kwolf@redhat.com>

Simimlar to AIO_WAIT_WHILE(), job_finish_sync() needs to release the
AioContext lock of the job before calling aio_poll(). Otherwise,
callbacks called by aio_poll() would possibly take the lock a second
time and run into a deadlock with a nested AIO_WAIT_WHILE() call.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 job.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/job.c b/job.c
index a746bfe70b..6acf55bceb 100644
--- a/job.c
+++ b/job.c
@@ -1016,7 +1016,10 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
         job_drain(job);
     }
     while (!job_is_completed(job)) {
+        AioContext *aio_context = job->aio_context;
+        aio_context_release(aio_context);
         aio_poll(qemu_get_aio_context(), true);
+        aio_context_acquire(aio_context);
     }
     ret = (job_is_cancelled(job) && job->ret == 0) ? -ECANCELED : job->ret;
     job_unref(job);
-- 
2.13.6

  parent reply	other threads:[~2018-08-17 17:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-17 17:02 [Qemu-devel] [RFC PATCH 0/5] Fix some jobs/drain/aio_poll related hangs Kevin Wolf
2018-08-17 17:02 ` [Qemu-devel] [RFC PATCH 1/5] blockjob: Wake up BDS when job becomes idle Kevin Wolf
2018-08-17 17:02 ` [Qemu-devel] [RFC PATCH 2/5] tests: Acquire AioContext around job_finish_sync() Kevin Wolf
2018-08-24  7:15   ` Fam Zheng
2018-08-17 17:02 ` Kevin Wolf [this message]
2018-08-24  7:22   ` [Qemu-devel] [RFC PATCH 3/5] job: Drop AioContext lock around aio_poll() Fam Zheng
2018-09-04 14:44     ` Kevin Wolf
2018-08-17 17:02 ` [Qemu-devel] [RFC PATCH 4/5] block: Drop AioContext lock in bdrv_drain_poll_top_level() Kevin Wolf
2018-08-24  7:24   ` Fam Zheng
2018-09-04 14:50     ` Kevin Wolf
2018-08-17 17:02 ` [Qemu-devel] [RFC PATCH 5/5] [WIP] Lock AioContext in bdrv_co_drain_bh_cb() Kevin Wolf
2018-08-18 10:46 ` [Qemu-devel] [RFC PATCH 0/5] Fix some jobs/drain/aio_poll related hangs no-reply
2018-08-21  6:08 ` Fam Zheng

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=20180817170246.14641-4-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=famz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.