From nobody Mon Apr 14 05:07:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513608243990963.4162941135487; Mon, 18 Dec 2017 06:44:03 -0800 (PST) Received: from localhost ([::1]:41414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQwdz-0004LK-5V for importer@patchew.org; Mon, 18 Dec 2017 09:43:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQwWv-0006hr-1S for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:36:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQwWu-00078c-2L for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:36:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35288) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eQwWt-00078E-QB for qemu-devel@nongnu.org; Mon, 18 Dec 2017 09:36:31 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E45937F41D; Mon, 18 Dec 2017 14:36:30 +0000 (UTC) Received: from localhost (ovpn-116-227.ams2.redhat.com [10.36.116.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67BC9703AA; Mon, 18 Dec 2017 14:36:30 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 18 Dec 2017 14:35:17 +0000 Message-Id: <20171218143530.12082-11-stefanha@redhat.com> In-Reply-To: <20171218143530.12082-1-stefanha@redhat.com> References: <20171218143530.12082-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Dec 2017 14:36:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/23] block: don't keep AioContext acquired after blockdev_backup_prepare() 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: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: 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: Stefan Hajnoczi Reviewed-by: Kevin Wolf Reviewed-by: Eric Blake Message-id: 20171206144550.22295-5-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- blockdev.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index 5a56a1abf2..d7ad76416e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1936,7 +1936,6 @@ typedef struct BlockdevBackupState { BlkActionState common; BlockDriverState *bs; BlockJob *job; - AioContext *aio_context; } BlockdevBackupState; =20 static BlockJob *do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *t= xn, @@ -1947,6 +1946,7 @@ static void blockdev_backup_prepare(BlkActionState *c= ommon, Error **errp) BlockdevBackupState *state =3D DO_UPCAST(BlockdevBackupState, common, = common); BlockdevBackup *backup; BlockDriverState *bs, *target; + AioContext *aio_context; Error *local_err =3D NULL; =20 assert(common->action->type =3D=3D TRANSACTION_ACTION_KIND_BLOCKDEV_BA= CKUP); @@ -1962,29 +1962,39 @@ static void blockdev_backup_prepare(BlkActionState = *common, Error **errp) return; } =20 - /* AioContext is released in .clean() */ - state->aio_context =3D bdrv_get_aio_context(bs); - if (state->aio_context !=3D bdrv_get_aio_context(target)) { - state->aio_context =3D NULL; + aio_context =3D bdrv_get_aio_context(bs); + if (aio_context !=3D bdrv_get_aio_context(target)) { error_setg(errp, "Backup between two IO threads is not implemented= "); return; } - aio_context_acquire(state->aio_context); + aio_context_acquire(aio_context); state->bs =3D bs; + + /* Paired with .clean() */ bdrv_drained_begin(state->bs); =20 state->job =3D do_blockdev_backup(backup, common->block_job_txn, &loca= l_err); if (local_err) { error_propagate(errp, local_err); - return; + goto out; } + +out: + aio_context_release(aio_context); } =20 static void blockdev_backup_commit(BlkActionState *common) { BlockdevBackupState *state =3D DO_UPCAST(BlockdevBackupState, common, = common); + AioContext *aio_context; + + aio_context =3D bdrv_get_aio_context(state->bs); + aio_context_acquire(aio_context); + assert(state->job); block_job_start(state->job); + + aio_context_release(aio_context); } =20 static void blockdev_backup_abort(BlkActionState *common) @@ -1992,18 +2002,32 @@ static void blockdev_backup_abort(BlkActionState *c= ommon) BlockdevBackupState *state =3D DO_UPCAST(BlockdevBackupState, common, = common); =20 if (state->job) { + AioContext *aio_context; + + aio_context =3D bdrv_get_aio_context(state->bs); + aio_context_acquire(aio_context); + block_job_cancel_sync(state->job); + + aio_context_release(aio_context); } } =20 static void blockdev_backup_clean(BlkActionState *common) { BlockdevBackupState *state =3D DO_UPCAST(BlockdevBackupState, common, = common); + AioContext *aio_context; =20 - if (state->aio_context) { - bdrv_drained_end(state->bs); - aio_context_release(state->aio_context); + if (!state->bs) { + return; } + + aio_context =3D bdrv_get_aio_context(state->bs); + aio_context_acquire(aio_context); + + bdrv_drained_end(state->bs); + + aio_context_release(aio_context); } =20 typedef struct BlockDirtyBitmapState { --=20 2.14.3