From nobody Wed Nov 5 10:42:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534127541102576.0296188112264; Sun, 12 Aug 2018 19:32:21 -0700 (PDT) Received: from localhost ([::1]:37225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp2eZ-0005Jo-Sv for importer@patchew.org; Sun, 12 Aug 2018 22:32:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fp2TF-0003aU-Tn for qemu-devel@nongnu.org; Sun, 12 Aug 2018 22:20:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fp2TE-0008Do-U3 for qemu-devel@nongnu.org; Sun, 12 Aug 2018 22:20:37 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36808 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fp2TC-0008Cs-Qb; Sun, 12 Aug 2018 22:20:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59A328163C60; Mon, 13 Aug 2018 02:20:34 +0000 (UTC) Received: from localhost (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 356D610073A7; Mon, 13 Aug 2018 02:20:32 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 13 Aug 2018 04:19:58 +0200 Message-Id: <20180813022006.7216-10-mreitz@redhat.com> In-Reply-To: <20180813022006.7216-1-mreitz@redhat.com> References: <20180813022006.7216-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 13 Aug 2018 02:20:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 13 Aug 2018 02:20:34 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 09/17] mirror: Lock AioContext in mirror_co_perform() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Jeff Cody , Fam Zheng , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Max Reitz --- 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 =3D op->s; =20 - aio_context_acquire(blk_get_aio_context(s->common.blk)); if (ret < 0) { BlockErrorAction action; =20 @@ -207,14 +206,12 @@ static void coroutine_fn mirror_write_complete(Mirror= Op *op, int ret) } } mirror_iteration_done(op, ret); - aio_context_release(blk_get_aio_context(s->common.blk)); } =20 static void coroutine_fn mirror_read_complete(MirrorOp *op, int ret) { MirrorBlockJob *s =3D op->s; =20 - aio_context_acquire(blk_get_aio_context(s->common.blk)); if (ret < 0) { BlockErrorAction action; =20 @@ -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)); } =20 /* Clip bytes relative to offset to not exceed end-of-file */ @@ -387,12 +383,16 @@ static void coroutine_fn mirror_co_perform(void *opaq= ue) { MirrorOp *op =3D opaque; MirrorBlockJob *s =3D op->s; + AioContext *aio_context; int ret; =20 + aio_context =3D 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 =3D mirror_co_zero(s, op->offset, op->bytes); break; @@ -404,6 +404,9 @@ static void coroutine_fn mirror_co_perform(void *opaque) } =20 mirror_write_complete(op, ret); + +done: + aio_context_release(aio_context); } =20 /* If mirror_method =3D=3D MIRROR_METHOD_COPY, *offset and *bytes will be --=20 2.17.1