From nobody Fri Nov 7 01:56:06 2025 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551275741489102.95171356857793; Wed, 27 Feb 2019 05:55:41 -0800 (PST) Received: from localhost ([127.0.0.1]:44161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyzgO-0006hT-Rs for importer@patchew.org; Wed, 27 Feb 2019 08:55:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyzUt-00064R-Qt for qemu-devel@nongnu.org; Wed, 27 Feb 2019 08:43:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyzIg-0003nw-L2 for qemu-devel@nongnu.org; Wed, 27 Feb 2019 08:31:07 -0500 Received: from relay.sw.ru ([185.231.240.75]:33468) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gyzIg-0003mR-BU; Wed, 27 Feb 2019 08:31:06 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gyz2f-0004Qy-IS; Wed, 27 Feb 2019 16:14:33 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Wed, 27 Feb 2019 16:14:31 +0300 Message-Id: <20190227131433.197063-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190227131433.197063-1-vsementsov@virtuozzo.com> References: <20190227131433.197063-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 v5 3/5] qcow2-refcount: check_refcounts_l2: reduce ignored overlaps 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, vsementsov@virtuozzo.com, den@virtuozzo.com, mreitz@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" Reduce number of structures ignored in overlap check: when checking active table ignore active tables, when checking inactive table ignore inactive ones. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/qcow2-refcount.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index add1bbf54f..00a922edfa 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1579,7 +1579,7 @@ enum { static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, void **refcount_table, int64_t *refcount_table_size, int64_t l2_off= set, - int flags, BdrvCheckMode fix) + int flags, BdrvCheckMode fix, bool active) { BDRVQcow2State *s =3D bs->opaque; uint64_t *l2_table, l2_entry; @@ -1663,11 +1663,12 @@ static int check_refcounts_l2(BlockDriverState *bs,= BdrvCheckResult *res, if (fix & BDRV_FIX_ERRORS) { uint64_t l2e_offset =3D l2_offset + (uint64_t)i * sizeof(uint64_t); + int ign =3D active ? QCOW2_OL_ACTIVE_L2 : + QCOW2_OL_INACTIVE_L2; =20 l2_entry =3D QCOW_OFLAG_ZERO; l2_table[i] =3D cpu_to_be64(l2_entry); - ret =3D qcow2_pre_write_overlap_check(bs, - QCOW2_OL_ACTIVE_L2 | QCOW2_OL_INACTIVE_L2, + ret =3D qcow2_pre_write_overlap_check(bs, ign, l2e_offset, sizeof(uint64_t)); if (ret < 0) { fprintf(stderr, "ERROR: Overlap check failed\n= "); @@ -1741,7 +1742,7 @@ static int check_refcounts_l1(BlockDriverState *bs, void **refcount_table, int64_t *refcount_table_size, int64_t l1_table_offset, int l1_size, - int flags, BdrvCheckMode fix) + int flags, BdrvCheckMode fix, bool active) { BDRVQcow2State *s =3D bs->opaque; uint64_t *l1_table =3D NULL, l2_offset, l1_size2; @@ -1797,7 +1798,7 @@ static int check_refcounts_l1(BlockDriverState *bs, /* Process and check L2 entries */ ret =3D check_refcounts_l2(bs, res, refcount_table, refcount_table_size, l2_offset, flags, - fix); + fix, active); if (ret < 0) { goto fail; } @@ -2083,7 +2084,7 @@ static int calculate_refcounts(BlockDriverState *bs, = BdrvCheckResult *res, /* current L1 table */ ret =3D check_refcounts_l1(bs, res, refcount_table, nb_clusters, s->l1_table_offset, s->l1_size, CHECK_FRAG_IN= FO, - fix); + fix, true); if (ret < 0) { return ret; } @@ -2106,7 +2107,8 @@ static int calculate_refcounts(BlockDriverState *bs, = BdrvCheckResult *res, continue; } ret =3D check_refcounts_l1(bs, res, refcount_table, nb_clusters, - sn->l1_table_offset, sn->l1_size, 0, fix); + sn->l1_table_offset, sn->l1_size, 0, fix, + false); if (ret < 0) { return ret; } --=20 2.18.0