From nobody Fri Apr 19 07:20:45 2024 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=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528824448215138.59946790241872; Tue, 12 Jun 2018 10:27:28 -0700 (PDT) Received: from localhost ([::1]:57632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSn4l-0007TT-0H for importer@patchew.org; Tue, 12 Jun 2018 13:27:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSn3o-00072A-Ly for qemu-devel@nongnu.org; Tue, 12 Jun 2018 13:26:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSn3j-0004u9-Ok for qemu-devel@nongnu.org; Tue, 12 Jun 2018 13:26:24 -0400 Received: from relay.sw.ru ([195.214.232.25]:60334) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fSn3j-0004sl-G7; Tue, 12 Jun 2018 13:26:19 -0400 Received: from msk-vpn.virtuozzo.com ([195.214.232.6] helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1fSn3e-0000Zm-SA; Tue, 12 Jun 2018 20:26:14 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 12 Jun 2018 20:26:14 +0300 Message-Id: <20180612172614.60107-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH] block/qcow2: fix logic around dirty_bitmaps_loaded 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, den@openvz.org, vsementsov@virtuozzo.com, mreitz@redhat.com 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" First: this variable was introduced to handle reopens. We need it on following qcow2_do_open, to don't try loading bitmaps again. So, we are fixing qcow2_invalidate_cache(). However, if we fix only qcow2_invalidate_cache, iotest 169 fails on case test__persistent__not_migbitmap__online_shared, because on first target open, source is not yet closed, and is not yet stored bitmaps, so, we are load nothing. And on second open, dirty_bitmaps_loaded is already true, but we have no bitmaps to reopen with qcow2_reopen_bitmaps_rw_hint(). So, we are fixing qcow2_do_open() too. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: John Snow --- block/qcow2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index 6fa5e1d71a..b4216a5830 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1499,7 +1499,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverStat= e *bs, QDict *options, { qcow2_reopen_bitmaps_rw_hint(bs, &header_updated, &local_err); } - } else { + } else if (s->nb_bitmaps > 0) { header_updated =3D qcow2_load_dirty_bitmaps(bs, &local_err); s->dirty_bitmaps_loaded =3D true; } @@ -2178,6 +2178,7 @@ static void coroutine_fn qcow2_co_invalidate_cache(Bl= ockDriverState *bs, QDict *options; Error *local_err =3D NULL; int ret; + bool dirty_bitmaps_loaded =3D s->dirty_bitmaps_loaded; =20 /* * Backing files are read-only which makes all of their metadata immut= able, @@ -2190,6 +2191,7 @@ static void coroutine_fn qcow2_co_invalidate_cache(Bl= ockDriverState *bs, qcow2_close(bs); =20 memset(s, 0, sizeof(BDRVQcow2State)); + s->dirty_bitmaps_loaded =3D dirty_bitmaps_loaded; options =3D qdict_clone_shallow(bs->options); =20 flags &=3D ~BDRV_O_INACTIVE; --=20 2.11.1