From: Fam Zheng <famz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-block@nongnu.org, mreitz@redhat.com, pbonzini@redhat.com,
slp@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 03/14] test-blockjob: Acquire AioContext around job_finish_sync()
Date: Tue, 11 Sep 2018 16:11:29 +0800 [thread overview]
Message-ID: <20180911081129.GD19292@lemon.usersys.redhat.com> (raw)
In-Reply-To: <20180907161520.26349-4-kwolf@redhat.com>
On Fri, 09/07 18:15, Kevin Wolf wrote:
> All callers in QEMU proper hold the AioContext lock when calling
> job_finish_sync(). test-blockjob should do the same.
I think s/job_finish_sync/job_cancel_sync/ in the subject is more accurate?
Reviewed-by: Fam Zheng <famz@redhat.com>
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> include/qemu/job.h | 6 ++++++
> tests/test-blockjob.c | 6 ++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/include/qemu/job.h b/include/qemu/job.h
> index 0dae5b8481..8ac48dbd28 100644
> --- a/include/qemu/job.h
> +++ b/include/qemu/job.h
> @@ -520,6 +520,8 @@ void job_user_cancel(Job *job, bool force, Error **errp);
> *
> * Returns the return value from the job if the job actually completed
> * during the call, or -ECANCELED if it was canceled.
> + *
> + * Callers must hold the AioContext lock of job->aio_context.
> */
> int job_cancel_sync(Job *job);
>
> @@ -537,6 +539,8 @@ void job_cancel_sync_all(void);
> * function).
> *
> * Returns the return value from the job.
> + *
> + * Callers must hold the AioContext lock of job->aio_context.
> */
> int job_complete_sync(Job *job, Error **errp);
>
> @@ -579,6 +583,8 @@ void job_defer_to_main_loop(Job *job, JobDeferToMainLoopFn *fn, void *opaque);
> *
> * Returns 0 if the job is successfully completed, -ECANCELED if the job was
> * cancelled before completing, and -errno in other error cases.
> + *
> + * Callers must hold the AioContext lock of job->aio_context.
> */
> int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp);
>
> diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
> index cb42f06e61..8c2babbe35 100644
> --- a/tests/test-blockjob.c
> +++ b/tests/test-blockjob.c
> @@ -230,6 +230,10 @@ static void cancel_common(CancelJob *s)
> BlockJob *job = &s->common;
> BlockBackend *blk = s->blk;
> JobStatus sts = job->job.status;
> + AioContext *ctx;
> +
> + ctx = job->job.aio_context;
> + aio_context_acquire(ctx);
>
> job_cancel_sync(&job->job);
> if (sts != JOB_STATUS_CREATED && sts != JOB_STATUS_CONCLUDED) {
> @@ -239,6 +243,8 @@ static void cancel_common(CancelJob *s)
> assert(job->job.status == JOB_STATUS_NULL);
> job_unref(&job->job);
> destroy_blk(blk);
> +
> + aio_context_release(ctx);
> }
>
> static void test_cancel_created(void)
> --
> 2.13.6
>
next prev parent reply other threads:[~2018-09-11 8:11 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-07 16:15 [Qemu-devel] [PATCH 00/14] Fix some jobs/drain/aio_poll related hangs Kevin Wolf
2018-09-07 16:15 ` [Qemu-devel] [PATCH 01/14] blockjob: Wake up BDS when job becomes idle Kevin Wolf
2018-09-11 7:58 ` Fam Zheng
2018-09-07 16:15 ` [Qemu-devel] [PATCH 02/14] test-bdrv-drain: Drain with block jobs in an I/O thread Kevin Wolf
2018-09-11 8:09 ` Fam Zheng
2018-09-07 16:15 ` [Qemu-devel] [PATCH 03/14] test-blockjob: Acquire AioContext around job_finish_sync() Kevin Wolf
2018-09-11 8:11 ` Fam Zheng [this message]
2018-09-07 16:15 ` [Qemu-devel] [PATCH 04/14] job: Use AIO_WAIT_WHILE() in job_finish_sync() Kevin Wolf
2018-09-11 8:17 ` Fam Zheng
2018-09-07 16:15 ` [Qemu-devel] [PATCH 05/14] test-bdrv-drain: Test AIO_WAIT_WHILE() in completion callback Kevin Wolf
2018-09-11 8:17 ` Fam Zheng
2018-09-07 16:15 ` [Qemu-devel] [PATCH 06/14] block: Add missing locking in bdrv_co_drain_bh_cb() Kevin Wolf
2018-09-11 8:23 ` Fam Zheng
2018-09-11 9:17 ` Kevin Wolf
2018-09-11 9:28 ` Sergio Lopez
2018-09-11 10:22 ` Kevin Wolf
2018-09-07 16:15 ` [Qemu-devel] [PATCH 07/14] aio-wait: Increase num_waiters even in home thread Kevin Wolf
2018-09-11 8:25 ` Fam Zheng
2018-09-07 16:15 ` [Qemu-devel] [PATCH 08/14] block-backend: Add .drained_poll callback Kevin Wolf
2018-09-11 8:26 ` Fam Zheng
2018-09-07 16:15 ` [Qemu-devel] [PATCH 09/14] block-backend: Fix potential double blk_delete() Kevin Wolf
2018-09-11 8:27 ` Fam Zheng
2018-09-07 16:15 ` [Qemu-devel] [PATCH 10/14] block-backend: Decrease in_flight only after callback Kevin Wolf
2018-09-11 8:29 ` Fam Zheng
2018-09-07 16:15 ` [Qemu-devel] [PATCH 11/14] mirror: Fix potential use-after-free in active commit Kevin Wolf
2018-09-11 8:31 ` Fam Zheng
2018-09-11 9:32 ` Kevin Wolf
2018-09-07 16:15 ` [Qemu-devel] [PATCH 12/14] blockjob: Lie better in child_job_drained_poll() Kevin Wolf
2018-09-11 8:34 ` Fam Zheng
2018-09-07 16:15 ` [Qemu-devel] [PATCH 13/14] block: Remove aio_poll() in bdrv_drain_poll variants Kevin Wolf
2018-09-11 8:35 ` Fam Zheng
2018-09-07 16:15 ` [Qemu-devel] [PATCH 14/14] test-bdrv-drain: Test nested poll in bdrv_drain_poll_top_level() Kevin Wolf
2018-09-11 8:37 ` 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=20180911081129.GD19292@lemon.usersys.redhat.com \
--to=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=slp@redhat.com \
/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).