From nobody Mon Feb 9 04:46:14 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=1565187289; cv=none; d=zoho.com; s=zohoarc; b=aMXWPmDp61h9YA5EogYmoFI9/brNGC6KxjWej50Ag3cbfB1fDAKwCoQ6YACFHxduj1DK9caOJWvqigH9SXsSJdQd3mPjeMt23rntwfaOKfHez+8bl9Yv2sHOrDXZT+pwh0Ql+NzqPr1SDWqrMFtrKYaibMDY3h/glbIWifOfDLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565187289; 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=qQq/pLLAAjd7nStwwpYlo4ConsIrAWYA5wj+P4u3s70=; b=kWTZwzrr+t53x4Wvr58JheW7YBHWagv2S36dhbI5NJ43Tf20Jr8ypuvSG1Y6qy5bOb8oQCBkziY9XLt9mKD/qkl0Ky1romFlWBzeLCRF2xcZ+kRcJWTWmMKUKD5pupbfyViUbeo3+nMv+gMpG2BWO6/qbtHb63jtrNie+fV2etw= 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 1565187289741749.1778220616944; Wed, 7 Aug 2019 07:14:49 -0700 (PDT) Received: from localhost ([::1]:41636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvMiG-0004ko-QN for importer@patchew.org; Wed, 07 Aug 2019 10:14:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36630) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvMg8-0007mi-Gb for qemu-devel@nongnu.org; Wed, 07 Aug 2019 10:12:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvMg7-0003KS-5e for qemu-devel@nongnu.org; Wed, 07 Aug 2019 10:12:36 -0400 Received: from relay.sw.ru ([185.231.240.75]:40658) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvMg4-0003Cx-1h; Wed, 07 Aug 2019 10:12:32 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hvMg0-0005oH-BO; Wed, 07 Aug 2019 17:12:28 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Date: Wed, 7 Aug 2019 17:12:26 +0300 Message-Id: <20190807141226.193501-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190807141226.193501-1-vsementsov@virtuozzo.com> References: <20190807141226.193501-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 v4 10/10] qcow2-bitmap: move bitmap reopen-rw code to qcow2_reopen_commit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.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" The only reason I can imagine for this strange code at the very-end of bdrv_reopen_commit is the fact that bs->read_only updated after calling drv->bdrv_reopen_commit in bdrv_reopen_commit. And in the same time, prior to previous commit, qcow2_reopen_bitmaps_rw did a wrong check for being writable, when actually it only need writable file child not self. So, as it's fixed, let's move things to correct place. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Max Reitz Reviewed-by: John Snow --- include/block/block_int.h | 6 ------ block.c | 19 ------------------- block/qcow2.c | 15 ++++++++++++++- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 3aa1e832a8..18a1e81194 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -531,12 +531,6 @@ struct BlockDriver { uint64_t parent_perm, uint64_t parent_shared, uint64_t *nperm, uint64_t *nshared); =20 - /** - * Bitmaps should be marked as 'IN_USE' in the image on reopening image - * as rw. This handler should realize it. It also should unset readonly - * field of BlockDirtyBitmap's in case of success. - */ - int (*bdrv_reopen_bitmaps_rw)(BlockDriverState *bs, Error **errp); bool (*bdrv_can_store_new_dirty_bitmap)(BlockDriverState *bs, const char *name, uint32_t granularity, diff --git a/block.c b/block.c index d59f9f97cb..395bc88045 100644 --- a/block.c +++ b/block.c @@ -3925,16 +3925,12 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_sta= te) BlockDriver *drv; BlockDriverState *bs; BdrvChild *child; - bool old_can_write, new_can_write; =20 assert(reopen_state !=3D NULL); bs =3D reopen_state->bs; drv =3D bs->drv; assert(drv !=3D NULL); =20 - old_can_write =3D - !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE); - /* If there are any driver level actions to take */ if (drv->bdrv_reopen_commit) { drv->bdrv_reopen_commit(reopen_state); @@ -3978,21 +3974,6 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_stat= e) } =20 bdrv_refresh_limits(bs, NULL); - - new_can_write =3D - !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE); - if (!old_can_write && new_can_write && drv->bdrv_reopen_bitmaps_rw) { - Error *local_err =3D NULL; - if (drv->bdrv_reopen_bitmaps_rw(bs, &local_err) < 0) { - /* This is not fatal, bitmaps just left read-only, so all foll= owing - * writes will fail. User can remove read-only bitmaps to unbl= ock - * writes. - */ - error_reportf_err(local_err, - "%s: Failed to make dirty bitmaps writable: = ", - bdrv_get_node_name(bs)); - } - } } =20 /* diff --git a/block/qcow2.c b/block/qcow2.c index 5c1187e2f9..9e6210c282 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1828,6 +1828,20 @@ fail: static void qcow2_reopen_commit(BDRVReopenState *state) { qcow2_update_options_commit(state->bs, state->opaque); + if (state->flags & BDRV_O_RDWR) { + Error *local_err =3D NULL; + + if (qcow2_reopen_bitmaps_rw(state->bs, &local_err) < 0) { + /* + * This is not fatal, bitmaps just left read-only, so all foll= owing + * writes will fail. User can remove read-only bitmaps to unbl= ock + * writes or retry reopen. + */ + error_reportf_err(local_err, + "%s: Failed to make dirty bitmaps writable: = ", + bdrv_get_node_name(state->bs)); + } + } g_free(state->opaque); } =20 @@ -5229,7 +5243,6 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_detach_aio_context =3D qcow2_detach_aio_context, .bdrv_attach_aio_context =3D qcow2_attach_aio_context, =20 - .bdrv_reopen_bitmaps_rw =3D qcow2_reopen_bitmaps_rw, .bdrv_can_store_new_dirty_bitmap =3D qcow2_can_store_new_dirty_bitmap, .bdrv_remove_persistent_dirty_bitmap =3D qcow2_remove_persistent_dirty= _bitmap, }; --=20 2.18.0