From nobody Fri Nov 7 02:11:45 2025 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 1544795114075276.9330127606406; Fri, 14 Dec 2018 05:45:14 -0800 (PST) Received: from localhost ([::1]:33600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXnmD-0003TC-2c for importer@patchew.org; Fri, 14 Dec 2018 08:45:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXnjv-0000vG-UO for qemu-devel@nongnu.org; Fri, 14 Dec 2018 08:42:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXnju-0005jh-V1 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 08:42:51 -0500 Received: from relay.sw.ru ([185.231.240.75]:36732) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXnjq-0005eM-ID; Fri, 14 Dec 2018 08:42:46 -0500 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gXnjm-000251-A2; Fri, 14 Dec 2018 16:42:42 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 16:42:40 +0300 Message-Id: <20181214134240.217870-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181214134240.217870-1-vsementsov@virtuozzo.com> References: <20181214134240.217870-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v4 5/5] qcow2-refcount: don't mask corruptions under internal errors 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" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" No reasons for not reporting found corruptions as corruptions in case of some internal errors, especially in case of just failed to fix l2 entry (and in this case, missed corruptions may influence comparing logic, when we calculate difference between corruptions fields of two results) Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2-refcount.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 8da0e91dd3..b0e006e628 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1639,6 +1639,8 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, =20 /* Correct offsets are cluster aligned */ if (offset_into_cluster(s, offset)) { + res->corruptions++; + if (qcow2_get_cluster_type(l2_entry) =3D=3D QCOW2_CLUSTER_ZERO_ALLOC) { @@ -1674,18 +1676,16 @@ static int check_refcounts_l2(BlockDriverState *bs,= BdrvCheckResult *res, /* Do not abort, continue checking the rest of= this * L2 table's entries */ } else { + res->corruptions--; res->corruptions_fixed++; /* Skip marking the cluster as used * (it is unused now) */ continue; } - } else { - res->corruptions++; } } else { fprintf(stderr, "ERROR offset=3D%" PRIx64 ": Data clus= ter is " "not properly aligned; L2 entry corrupted.\n", off= set); - res->corruptions++; } } =20 @@ -1854,6 +1854,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, continue; } if ((refcount =3D=3D 1) !=3D ((l1_entry & QCOW_OFLAG_COPIED) !=3D = 0)) { + res->corruptions++; fprintf(stderr, "%s OFLAG_COPIED L2 cluster: l1_index=3D%d " "l1_entry=3D%" PRIx64 " refcount=3D%" PRIu64 "\n", repair ? "Repairing" : "ERROR", i, l1_entry, refcount); @@ -1866,9 +1867,8 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, res->check_errors++; goto fail; } + res->corruptions--; res->corruptions_fixed++; - } else { - res->corruptions++; } } =20 @@ -1899,19 +1899,16 @@ static int check_oflag_copied(BlockDriverState *bs,= BdrvCheckResult *res, fprintf(stderr, "%s OFLAG_COPIED data cluster: " "l2_entry=3D%" PRIx64 " refcount=3D%" PRIu64 "= \n", repair ? "Repairing" : "ERROR", l2_entry, refc= ount); - if (repair) { - l2_table[j] =3D cpu_to_be64(refcount =3D=3D 1 - ? l2_entry | QCOW_OFLAG_COPIED - : l2_entry & ~QCOW_OFLAG_COPIED); - l2_dirty++; - } else { - res->corruptions++; - } + l2_table[j] =3D cpu_to_be64(refcount =3D=3D 1 + ? l2_entry | QCOW_OFLAG_COPIED + : l2_entry & ~QCOW_OFLAG_COPIED); + l2_dirty++; } } } =20 - if (l2_dirty > 0) { + res->corruptions +=3D l2_dirty; + if (repair && l2_dirty > 0) { ret =3D qcow2_pre_write_overlap_check(bs, QCOW2_OL_ACTIVE_L2, l2_offset, s->cluster_size= ); if (ret < 0) { @@ -1929,6 +1926,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, res->check_errors++; goto fail; } + res->corruptions -=3D l2_dirty; res->corruptions_fixed +=3D l2_dirty; } } @@ -1967,6 +1965,7 @@ static int check_refblocks(BlockDriverState *bs, Bdrv= CheckResult *res, } =20 if (cluster >=3D *nb_clusters) { + res->corruptions++; fprintf(stderr, "%s refcount block %" PRId64 " is outside imag= e\n", fix & BDRV_FIX_ERRORS ? "Repairing" : "ERROR", i); =20 @@ -2006,6 +2005,7 @@ static int check_refblocks(BlockDriverState *bs, Bdrv= CheckResult *res, goto resize_fail; } =20 + res->corruptions--; res->corruptions_fixed++; ret =3D qcow2_inc_refcounts_imrt(bs, res, refcount_table, nb_clusters, @@ -2019,12 +2019,9 @@ static int check_refblocks(BlockDriverState *bs, Bdr= vCheckResult *res, continue; =20 resize_fail: - res->corruptions++; *rebuild =3D true; fprintf(stderr, "ERROR could not resize image: %s\n", strerror(-ret)); - } else { - res->corruptions++; } continue; } --=20 2.18.0