From nobody Wed Nov 5 10:33:20 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 1499359264526184.46211808361045; Thu, 6 Jul 2017 09:41:04 -0700 (PDT) Received: from localhost ([::1]:52391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dT9pr-0006TW-29 for importer@patchew.org; Thu, 06 Jul 2017 12:40:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dT9nz-00058U-H0 for qemu-devel@nongnu.org; Thu, 06 Jul 2017 12:39:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dT9nu-0006At-Im for qemu-devel@nongnu.org; Thu, 06 Jul 2017 12:39:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38756) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dT9nr-00068F-63; Thu, 06 Jul 2017 12:38:55 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 207BB90907; Thu, 6 Jul 2017 16:38:54 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-229.ams2.redhat.com [10.36.117.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84A7353CD1; Thu, 6 Jul 2017 16:38:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 207BB90907 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=pbonzini@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 207BB90907 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 6 Jul 2017 18:38:27 +0200 Message-Id: <20170706163828.24082-11-pbonzini@redhat.com> In-Reply-To: <20170706163828.24082-1-pbonzini@redhat.com> References: <20170706163828.24082-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 06 Jul 2017 16:38:54 +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] [PATCH 10/11] block: do not take AioContext around reopen 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: famz@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org 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" Reopen needs to handle AioContext carefully due to calling bdrv_drain_all_begin/end. By not taking AioContext around calls to bdrv_reopen_multiple, we can drop the function's release/acquire pair and the AioContext argument too. Signed-off-by: Paolo Bonzini --- block.c | 6 ++---- block/block-backend.c | 5 ----- block/commit.c | 2 +- block/mirror.c | 9 --------- block/replication.c | 3 +-- blockdev.c | 19 ++++++------------- include/block/block.h | 2 +- qemu-io-cmds.c | 2 +- 8 files changed, 12 insertions(+), 36 deletions(-) diff --git a/block.c b/block.c index af0a9a1c22..4bf6ab11f7 100644 --- a/block.c +++ b/block.c @@ -2793,7 +2793,7 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue = *bs_queue, * to all devices. * */ -int bdrv_reopen_multiple(AioContext *ctx, BlockReopenQueue *bs_queue, Erro= r **errp) +int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp) { int ret =3D -1; BlockReopenQueueEntry *bs_entry, *next; @@ -2801,9 +2801,7 @@ int bdrv_reopen_multiple(AioContext *ctx, BlockReopen= Queue *bs_queue, Error **er =20 assert(bs_queue !=3D NULL); =20 - aio_context_release(ctx); bdrv_drain_all_begin(); - aio_context_acquire(ctx); =20 QSIMPLEQ_FOREACH(bs_entry, bs_queue, entry) { if (bdrv_reopen_prepare(&bs_entry->state, bs_queue, &local_err)) { @@ -2847,7 +2845,7 @@ int bdrv_reopen(BlockDriverState *bs, int bdrv_flags,= Error **errp) Error *local_err =3D NULL; BlockReopenQueue *queue =3D bdrv_reopen_queue(NULL, bs, NULL, bdrv_fla= gs); =20 - ret =3D bdrv_reopen_multiple(bdrv_get_aio_context(bs), queue, &local_e= rr); + ret =3D bdrv_reopen_multiple(queue, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); } diff --git a/block/block-backend.c b/block/block-backend.c index 0df3457a09..0ce1fb1c26 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1888,17 +1888,12 @@ int blk_commit_all(void) BlockBackend *blk =3D NULL; =20 while ((blk =3D blk_all_next(blk)) !=3D NULL) { - AioContext *aio_context =3D blk_get_aio_context(blk); - - aio_context_acquire(aio_context); if (blk_is_inserted(blk) && blk->root->bs->backing) { int ret =3D bdrv_commit(blk->root->bs); if (ret < 0) { - aio_context_release(aio_context); return ret; } } - aio_context_release(aio_context); } return 0; } diff --git a/block/commit.c b/block/commit.c index 8c09c3dbcd..1fe67fa8db 100644 --- a/block/commit.c +++ b/block/commit.c @@ -335,7 +335,7 @@ void commit_start(const char *job_id, BlockDriverState = *bs, orig_overlay_flags | BDRV_O_RDWR); } if (reopen_queue) { - bdrv_reopen_multiple(bdrv_get_aio_context(bs), reopen_queue, &loca= l_err); + bdrv_reopen_multiple(reopen_queue, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); goto fail; diff --git a/block/mirror.c b/block/mirror.c index 68744a17e8..804edbad21 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -505,7 +505,6 @@ static void mirror_exit(BlockJob *job, void *opaque) { MirrorBlockJob *s =3D container_of(job, MirrorBlockJob, common); MirrorExitData *data =3D opaque; - AioContext *replace_aio_context =3D NULL; BlockDriverState *src =3D s->source; BlockDriverState *target_bs =3D blk_bs(s->target); BlockDriverState *mirror_top_bs =3D s->mirror_top_bs; @@ -545,11 +544,6 @@ static void mirror_exit(BlockJob *job, void *opaque) } } =20 - if (s->to_replace) { - replace_aio_context =3D bdrv_get_aio_context(s->to_replace); - aio_context_acquire(replace_aio_context); - } - if (s->should_complete && data->ret =3D=3D 0) { BlockDriverState *to_replace =3D src; if (s->to_replace) { @@ -575,9 +569,6 @@ static void mirror_exit(BlockJob *job, void *opaque) error_free(s->replace_blocker); bdrv_unref(s->to_replace); } - if (replace_aio_context) { - aio_context_release(replace_aio_context); - } g_free(s->replaces); bdrv_unref(target_bs); =20 diff --git a/block/replication.c b/block/replication.c index 7a3b94b90f..9350ef100b 100644 --- a/block/replication.c +++ b/block/replication.c @@ -381,8 +381,7 @@ static void reopen_backing_file(BlockDriverState *bs, b= ool writable, } =20 if (reopen_queue) { - bdrv_reopen_multiple(bdrv_get_aio_context(bs), - reopen_queue, &local_err); + bdrv_reopen_multiple(reopen_queue, &local_err); error_propagate(errp, local_err); } } diff --git a/blockdev.c b/blockdev.c index b2c305402d..88ab606949 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3710,7 +3710,6 @@ void qmp_change_backing_file(const char *device, Error **errp) { BlockDriverState *bs =3D NULL; - AioContext *aio_context; BlockDriverState *image_bs =3D NULL; Error *local_err =3D NULL; bool ro; @@ -3722,37 +3721,34 @@ void qmp_change_backing_file(const char *device, return; } =20 - aio_context =3D bdrv_get_aio_context(bs); - aio_context_acquire(aio_context); - image_bs =3D bdrv_lookup_bs(NULL, image_node_name, &local_err); if (local_err) { error_propagate(errp, local_err); - goto out; + return; } =20 if (!image_bs) { error_setg(errp, "image file not found"); - goto out; + return; } =20 if (bdrv_find_base(image_bs) =3D=3D image_bs) { error_setg(errp, "not allowing backing file change on an image " "without a backing file"); - goto out; + return; } =20 /* even though we are not necessarily operating on bs, we need it to * determine if block ops are currently prohibited on the chain */ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_CHANGE, errp)) { - goto out; + return; } =20 /* final sanity check */ if (!bdrv_chain_contains(bs, image_bs)) { error_setg(errp, "'%s' and image file are not in the same chain", device); - goto out; + return; } =20 /* if not r/w, reopen to make r/w */ @@ -3763,7 +3759,7 @@ void qmp_change_backing_file(const char *device, bdrv_reopen(image_bs, open_flags | BDRV_O_RDWR, &local_err); if (local_err) { error_propagate(errp, local_err); - goto out; + return; } } =20 @@ -3781,9 +3777,6 @@ void qmp_change_backing_file(const char *device, bdrv_reopen(image_bs, open_flags, &local_err); error_propagate(errp, local_err); } - -out: - aio_context_release(aio_context); } =20 void hmp_drive_add_node(Monitor *mon, const char *optstr) diff --git a/include/block/block.h b/include/block/block.h index 85e4be7462..f533f80f1f 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -265,7 +265,7 @@ BlockDriverState *bdrv_new_open_driver(BlockDriver *drv= , const char *node_name, BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, BlockDriverState *bs, QDict *options, int flags); -int bdrv_reopen_multiple(AioContext *ctx, BlockReopenQueue *bs_queue, Erro= r **errp); +int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp); int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp); int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, Error **errp); diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index b0ea327024..19d3114542 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -2006,7 +2006,7 @@ static int reopen_f(BlockBackend *blk, int argc, char= **argv) qemu_opts_reset(&reopen_opts); =20 brq =3D bdrv_reopen_queue(NULL, bs, opts, flags); - bdrv_reopen_multiple(bdrv_get_aio_context(bs), brq, &local_err); + bdrv_reopen_multiple(brq, &local_err); if (local_err) { error_report_err(local_err); } else { --=20 2.13.0