From nobody Sun Feb 8 20:12:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1559564344; cv=none; d=zoho.com; s=zohoarc; b=Ri6nHEE0H/b59XNV6pBgvotSMrKE5oSwluVocdHBqRVG+i0afxhTpG5+SADzhclDu7YRxI17ny7xq0o04g6w/2Y63JEQlqQf/VyTTW4xDo7pLZKmI6UIY2vBYdIOjhgM39rkaMmujuddiN2OxAjIKQfrrmBLKvBoc86cIRJX33o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559564344; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KPkAgZWlaU4LpKbQFXd6hJVmHsnBJCLnKELa2ymyPIk=; b=fxSU4X6XauqYqphnzk3xLha4n1hNK4+2K8ka8yMuazjy4f90+7sWf8n+ScGCpbrOtyADVPbJdGoVDMbO+ypFUkBMrXM3xRxfIuVHBx1Mm1wx/Paii2sRWTAgZ9U++ydNAEuVUkopZ1+sosoJy4DQZemre4C4cJ7xTU0b5EYDjtw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559564344864814.8550041655209; Mon, 3 Jun 2019 05:19:04 -0700 (PDT) Received: from localhost ([127.0.0.1]:34329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXlvU-0001dX-Ow for importer@patchew.org; Mon, 03 Jun 2019 08:18:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXlqU-00063n-QW for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:13:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXldf-00025a-7T for qemu-devel@nongnu.org; Mon, 03 Jun 2019 08:00:34 -0400 Received: from relay.sw.ru ([185.231.240.75]:39508) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hXldZ-00012A-M5; Mon, 03 Jun 2019 08:00:27 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hXldG-0002hc-AA; Mon, 03 Jun 2019 15:00:06 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 3 Jun 2019 15:00:02 +0300 Message-Id: <20190603120005.37394-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190603120005.37394-1-vsementsov@virtuozzo.com> References: <20190603120005.37394-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH 1/4] blockdev: reduce aio_context locked sections in bitmap add/remove 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: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, nshirokovskiy@virtuozzo.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 0a6c86d024c52 returned these locks back to add/remove functionality, to protect from intersection of persistent bitmap related IO with other IO. But other bitmap-related functions called here are unrelated to the problem, and there are no needs to keep these calls inside critical sections. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: John Snow --- blockdev.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/blockdev.c b/blockdev.c index 17c2d801d7..5b3eef0d3e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2812,7 +2812,6 @@ void qmp_block_dirty_bitmap_add(const char *node, con= st char *name, { BlockDriverState *bs; BdrvDirtyBitmap *bitmap; - AioContext *aio_context =3D NULL; =20 if (!name || name[0] =3D=3D '\0') { error_setg(errp, "Bitmap name cannot be empty"); @@ -2848,16 +2847,20 @@ void qmp_block_dirty_bitmap_add(const char *node, c= onst char *name, } =20 if (persistent) { - aio_context =3D bdrv_get_aio_context(bs); + AioContext *aio_context =3D bdrv_get_aio_context(bs); + bool ok; + aio_context_acquire(aio_context); - if (!bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp))= { - goto out; + ok =3D bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp= ); + aio_context_release(aio_context); + if (!ok) { + return; } } =20 bitmap =3D bdrv_create_dirty_bitmap(bs, granularity, name, errp); if (bitmap =3D=3D NULL) { - goto out; + return; } =20 if (disabled) { @@ -2865,10 +2868,6 @@ void qmp_block_dirty_bitmap_add(const char *node, co= nst char *name, } =20 bdrv_dirty_bitmap_set_persistence(bitmap, persistent); - out: - if (aio_context) { - aio_context_release(aio_context); - } } =20 void qmp_block_dirty_bitmap_remove(const char *node, const char *name, @@ -2876,8 +2875,6 @@ void qmp_block_dirty_bitmap_remove(const char *node, = const char *name, { BlockDriverState *bs; BdrvDirtyBitmap *bitmap; - Error *local_err =3D NULL; - AioContext *aio_context =3D NULL; =20 bitmap =3D block_dirty_bitmap_lookup(node, name, &bs, errp); if (!bitmap || !bs) { @@ -2890,20 +2887,19 @@ void qmp_block_dirty_bitmap_remove(const char *node= , const char *name, } =20 if (bdrv_dirty_bitmap_get_persistence(bitmap)) { - aio_context =3D bdrv_get_aio_context(bs); + AioContext *aio_context =3D bdrv_get_aio_context(bs); + Error *local_err =3D NULL; + aio_context_acquire(aio_context); bdrv_remove_persistent_dirty_bitmap(bs, name, &local_err); + aio_context_release(aio_context); if (local_err !=3D NULL) { error_propagate(errp, local_err); - goto out; + return; } } =20 bdrv_release_dirty_bitmap(bs, bitmap); - out: - if (aio_context) { - aio_context_release(aio_context); - } } =20 /** --=20 2.18.0