From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82EE9C433ED for ; Tue, 11 May 2021 17:11:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05BE761352 for ; Tue, 11 May 2021 17:11:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05BE761352 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgVud-0002rn-VT for qemu-devel@archiver.kernel.org; Tue, 11 May 2021 13:11:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgVt1-0001N9-5h; Tue, 11 May 2021 13:09:35 -0400 Received: from relay.sw.ru ([185.231.240.75]:40416) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgVsy-0003YJ-Es; Tue, 11 May 2021 13:09:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Content-Type:MIME-Version:Date:Message-ID:From: Subject; bh=mNYbtKzz7jcp841Z9dCAsnKf3QUUA9156kWnEVzPKEc=; b=ef8Xylbok/XKlqkjd Tm+S1sUn4/G5fTmdduzMKaKl2gY/B7YTNAdmtPunYbW+nZxtIR8FosN2uqcxXcZD1DxEi0Basi+jW hxa1fF3zmuApZp0jARgLMmLMC/f+nN/t5sVgwzkpy/sW3YuhnY18k3mzghkSyOsJsBwarxjJEuqsY =; Received: from [192.168.15.129] by relay.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1lgVsn-0027oM-IO; Tue, 11 May 2021 20:09:21 +0300 Subject: Re: [PATCH v2 10/10] qcow2-refcount: check_refblocks(): add separate message for reserved To: Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, mreitz@redhat.com, kwolf@redhat.com, den@openvz.org, eblake@redhat.com, berto@igalia.com References: <20210505065955.13964-1-vsementsov@virtuozzo.com> <20210505065955.13964-11-vsementsov@virtuozzo.com> From: Kirill Tkhai Message-ID: Date: Tue, 11 May 2021 20:09:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210505065955.13964-11-vsementsov@virtuozzo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=185.231.240.75; envelope-from=ktkhai@virtuozzo.com; helo=relay.sw.ru X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 05.05.2021 09:59, Vladimir Sementsov-Ogievskiy wrote: > Split checking for reserved bits out of aligned offset check. > > Signed-off-by: Vladimir Sementsov-Ogievskiy > Reviewed-by: Eric Blake Tested-by: Kirill Tkhai > --- > block/qcow2.h | 1 + > block/qcow2-refcount.c | 10 +++++++++- > 2 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/block/qcow2.h b/block/qcow2.h > index 58fd7f1678..fd48a89d45 100644 > --- a/block/qcow2.h > +++ b/block/qcow2.h > @@ -591,6 +591,7 @@ typedef enum QCow2MetadataOverlap { > #define L2E_STD_RESERVED_MASK 0x3f000000000001feULL > > #define REFT_OFFSET_MASK 0xfffffffffffffe00ULL > +#define REFT_RESERVED_MASK 0x1ffULL > > #define INV_OFFSET (-1ULL) > > diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c > index 15c4f6b075..472a7026db 100644 > --- a/block/qcow2-refcount.c > +++ b/block/qcow2-refcount.c > @@ -2091,9 +2091,17 @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, > > for(i = 0; i < s->refcount_table_size; i++) { > uint64_t offset, cluster; > - offset = s->refcount_table[i]; > + offset = s->refcount_table[i] & REFT_OFFSET_MASK; > cluster = offset >> s->cluster_bits; > > + if (s->refcount_table[i] & REFT_RESERVED_MASK) { > + fprintf(stderr, "ERROR refcount table entry %" PRId64 " has " > + "reserved bits set\n", i); > + res->corruptions++; > + *rebuild = true; > + continue; > + } > + > /* Refcount blocks are cluster aligned */ > if (offset_into_cluster(s, offset)) { > fprintf(stderr, "ERROR refcount block %" PRId64 " is not " >