From patchwork Tue Jun 12 17:26:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 928429 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 414xdJ5BjYz9s0W for ; Wed, 13 Jun 2018 03:26:44 +1000 (AEST) Received: from localhost ([::1]:57628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSn46-00072W-Eg for incoming@patchwork.ozlabs.org; Tue, 12 Jun 2018 13:26:42 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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(BlockDriverState *bs, QDict *options, { qcow2_reopen_bitmaps_rw_hint(bs, &header_updated, &local_err); } - } else { + } else if (s->nb_bitmaps > 0) { header_updated = qcow2_load_dirty_bitmaps(bs, &local_err); s->dirty_bitmaps_loaded = true; } @@ -2178,6 +2178,7 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs, QDict *options; Error *local_err = NULL; int ret; + bool dirty_bitmaps_loaded = s->dirty_bitmaps_loaded; /* * Backing files are read-only which makes all of their metadata immutable, @@ -2190,6 +2191,7 @@ static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs, qcow2_close(bs); memset(s, 0, sizeof(BDRVQcow2State)); + s->dirty_bitmaps_loaded = dirty_bitmaps_loaded; options = qdict_clone_shallow(bs->options); flags &= ~BDRV_O_INACTIVE;