From patchwork Fri Mar 15 14:49:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Canet?= X-Patchwork-Id: 228037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EDB782C0077 for ; Sat, 16 Mar 2013 02:05:04 +1100 (EST) Received: from localhost ([::1]:55831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGWBr-0006nG-1y for incoming@patchwork.ozlabs.org; Fri, 15 Mar 2013 11:05:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGVz9-0001qw-9I for qemu-devel@nongnu.org; Fri, 15 Mar 2013 10:52:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UGVz4-0005Di-SR for qemu-devel@nongnu.org; Fri, 15 Mar 2013 10:51:55 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:59634 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UGVz4-0005Ce-If for qemu-devel@nongnu.org; Fri, 15 Mar 2013 10:51:50 -0400 Received: by paradis.irqsave.net (Postfix, from userid 1002) id 8FCBE874354; Fri, 15 Mar 2013 15:51:49 +0100 (CET) Received: from localhost.localdomain (unknown [192.168.77.1]) by paradis.irqsave.net (Postfix) with ESMTP id 86934874365; Fri, 15 Mar 2013 15:48:48 +0100 (CET) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Fri, 15 Mar 2013 15:49:39 +0100 Message-Id: <1363358986-8360-26-git-send-email-benoit@irqsave.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1363358986-8360-1-git-send-email-benoit@irqsave.net> References: <1363358986-8360-1-git-send-email-benoit@irqsave.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 62.212.105.220 Cc: kwolf@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com Subject: [Qemu-devel] [RFC V7 25/32] qcow2: Adapt checking of QCOW_OFLAG_COPIED for dedup. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Benoit Canet --- block/qcow2-refcount.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index ffb8d3a..7a53983 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1029,7 +1029,19 @@ static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, PRIx64 ": %s\n", l2_entry, strerror(-refcount)); goto fail; } - if ((refcount == 1) != ((l2_entry & QCOW_OFLAG_COPIED) != 0)) { + /* QCOW_OFLAG_COPIED is not garanteed to be here when + * refcount == 1 when dedup is enabled since it would be + * too expensive to set it back everytime refcount is + * decremented to 1. + */ + if (!s->has_dedup && + (refcount == 1) != ((l2_entry & QCOW_OFLAG_COPIED) != 0)) { + fprintf(stderr, "ERROR OFLAG_COPIED: offset=%" + PRIx64 " refcount=%d\n", l2_entry, refcount); + res->corruptions++; + } + if (s->has_dedup && refcount > 1 && + ((l2_entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED: offset=%" PRIx64 " refcount=%d\n", l2_entry, refcount); res->corruptions++;