From: Paolo Bonzini <pbonzini@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 09/17] mirror: Lock AioContext in mirror_co_perform()
Date: Mon, 13 Aug 2018 16:43:26 +0200 [thread overview]
Message-ID: <400a8b57-a930-2eee-a4a0-bf5a0733db1a@redhat.com> (raw)
In-Reply-To: <20180813022006.7216-10-mreitz@redhat.com>
On 13/08/2018 04:19, Max Reitz wrote:
> Signed-off-by: Max Reitz <mreitz@redhat.com>
Locking AioContext should not be needed anywhere here. mirror_run is
called via aio_co_enter or aio_co_wake, so the lock is actually already
taken every time you call aio_context_acquire.
It was needed only because AIO callbacks do *not* take the lock, but
it's not needed anymore since the conversion to coroutines.
Paolo
> block/mirror.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/block/mirror.c b/block/mirror.c
> index 85b08086cc..6330269156 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -196,7 +196,6 @@ static void coroutine_fn mirror_write_complete(MirrorOp *op, int ret)
> {
> MirrorBlockJob *s = op->s;
>
> - aio_context_acquire(blk_get_aio_context(s->common.blk));
> if (ret < 0) {
> BlockErrorAction action;
>
> @@ -207,14 +206,12 @@ static void coroutine_fn mirror_write_complete(MirrorOp *op, int ret)
> }
> }
> mirror_iteration_done(op, ret);
> - aio_context_release(blk_get_aio_context(s->common.blk));
> }
>
> static void coroutine_fn mirror_read_complete(MirrorOp *op, int ret)
> {
> MirrorBlockJob *s = op->s;
>
> - aio_context_acquire(blk_get_aio_context(s->common.blk));
> if (ret < 0) {
> BlockErrorAction action;
>
> @@ -230,7 +227,6 @@ static void coroutine_fn mirror_read_complete(MirrorOp *op, int ret)
> op->qiov.size, &op->qiov, 0);
> mirror_write_complete(op, ret);
> }
> - aio_context_release(blk_get_aio_context(s->common.blk));
> }
>
> /* Clip bytes relative to offset to not exceed end-of-file */
> @@ -387,12 +383,16 @@ static void coroutine_fn mirror_co_perform(void *opaque)
> {
> MirrorOp *op = opaque;
> MirrorBlockJob *s = op->s;
> + AioContext *aio_context;
> int ret;
>
> + aio_context = blk_get_aio_context(s->common.blk);
> + aio_context_acquire(aio_context);
> +
> switch (op->mirror_method) {
> case MIRROR_METHOD_COPY:
> mirror_co_read(opaque);
> - return;
> + goto done;
> case MIRROR_METHOD_ZERO:
> ret = mirror_co_zero(s, op->offset, op->bytes);
> break;
> @@ -404,6 +404,9 @@ static void coroutine_fn mirror_co_perform(void *opaque)
> }
>
> mirror_write_complete(op, ret);
> +
> +done:
> + aio_context_release(aio_context);
> }
>
> /* If mirror_method == MIRROR_METHOD_COPY, *offset and *bytes will be
>
next prev parent reply other threads:[~2018-08-13 14:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 2:19 [Qemu-devel] [PATCH 00/17] mirror: Mainly coroutine refinements Max Reitz
2018-08-13 2:19 ` [Qemu-devel] [PATCH 01/17] iotests: Try reading while mirroring in 156 Max Reitz
2018-08-14 3:39 ` Jeff Cody
2018-08-13 2:19 ` [Qemu-devel] [PATCH 02/17] mirror: Make wait_for_any_operation() coroutine_fn Max Reitz
2018-08-13 12:54 ` Murilo Opsfelder Araujo
2018-08-13 15:20 ` Max Reitz
2018-08-14 3:36 ` Jeff Cody
2018-08-13 2:19 ` [Qemu-devel] [PATCH 03/17] mirror: Pull *_align_for_copy() from *_co_read() Max Reitz
2018-08-14 3:39 ` Jeff Cody
2018-08-13 2:19 ` [Qemu-devel] [PATCH 04/17] mirror: Remove bytes_handled, part 1 Max Reitz
2018-08-13 2:19 ` [Qemu-devel] [PATCH 05/17] mirror: Remove bytes_handled, part 2 Max Reitz
2018-08-13 2:19 ` [Qemu-devel] [PATCH 06/17] mirror: Create mirror_co_perform() Max Reitz
2018-08-13 2:19 ` [Qemu-devel] [PATCH 07/17] mirror: Make mirror_co_zero() nicer Max Reitz
2018-08-13 2:19 ` [Qemu-devel] [PATCH 08/17] mirror: Make mirror_co_discard() nicer Max Reitz
2018-08-13 2:19 ` [Qemu-devel] [PATCH 09/17] mirror: Lock AioContext in mirror_co_perform() Max Reitz
2018-08-13 14:43 ` Paolo Bonzini [this message]
2018-08-13 15:21 ` [Qemu-devel] [Qemu-block] " Max Reitz
2018-08-13 2:19 ` [Qemu-devel] [PATCH 10/17] mirror: Create mirror_co_alloc_qiov() Max Reitz
2018-08-13 2:20 ` [Qemu-devel] [PATCH 11/17] mirror: Inline mirror_write_complete(), part 1 Max Reitz
2018-08-13 2:20 ` [Qemu-devel] [PATCH 12/17] mirror: Put QIOV locally into mirror_co_read Max Reitz
2018-08-13 2:20 ` [Qemu-devel] [PATCH 13/17] mirror: Linearize mirror_co_read() Max Reitz
2018-08-13 2:20 ` [Qemu-devel] [PATCH 14/17] mirror: Inline mirror_iteration_done() Max Reitz
2018-08-13 2:20 ` [Qemu-devel] [PATCH 15/17] mirror: Release AioCtx before queue_restart_all() Max Reitz
2018-08-13 2:20 ` [Qemu-devel] [PATCH 16/17] mirror: Support COR with write-blocking Max Reitz
2018-08-13 2:20 ` [Qemu-devel] [PATCH 17/17] iotests: Add test for active mirror with COR Max Reitz
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=400a8b57-a930-2eee-a4a0-bf5a0733db1a@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@redhat.com \
--cc=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 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.