From patchwork Fri Jun 15 13:33:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 165158 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 934CAB707D for ; Sat, 16 Jun 2012 01:37:41 +1000 (EST) Received: from localhost ([::1]:38882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfWgT-00039v-On for incoming@patchwork.ozlabs.org; Fri, 15 Jun 2012 09:35:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfWf6-0000nN-Eo for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfWf0-0004h0-5l for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10376) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfWez-0004gn-V0 for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:33:58 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5FDXtH5003682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 15 Jun 2012 09:33:55 -0400 Received: from dhcp-5-188.str.redhat.com (vpn1-6-30.ams2.redhat.com [10.36.6.30]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5FDXep4016743; Fri, 15 Jun 2012 09:33:54 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 15 Jun 2012 15:33:10 +0200 Message-Id: <1339767219-24297-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1339767219-24297-1-git-send-email-kwolf@redhat.com> References: <1339767219-24297-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 10/39] qemu-img check: Print fixed clusters and recheck 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 When any inconsistencies have been fixed, print the statistics and run another check to make sure everything is correct now. Signed-off-by: Kevin Wolf --- block.h | 2 ++ block/qed-check.c | 2 ++ qemu-img.c | 10 ++++++++++ 3 files changed, 14 insertions(+), 0 deletions(-) diff --git a/block.h b/block.h index 61b7e8e..f8200eb 100644 --- a/block.h +++ b/block.h @@ -187,6 +187,8 @@ typedef struct BdrvCheckResult { int corruptions; int leaks; int check_errors; + int corruptions_fixed; + int leaks_fixed; BlockFragInfo bfi; } BdrvCheckResult; diff --git a/block/qed-check.c b/block/qed-check.c index 94327ff..5edf607 100644 --- a/block/qed-check.c +++ b/block/qed-check.c @@ -87,6 +87,7 @@ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table) if (!qed_check_cluster_offset(s, offset)) { if (check->fix) { table->offsets[i] = 0; + check->result->corruptions_fixed++; } else { check->result->corruptions++; } @@ -127,6 +128,7 @@ static int qed_check_l1_table(QEDCheck *check, QEDTable *table) /* Clear invalid offset */ if (check->fix) { table->offsets[i] = 0; + check->result->corruptions_fixed++; } else { check->result->corruptions++; } diff --git a/qemu-img.c b/qemu-img.c index c45ff62..9336c86 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -425,6 +425,16 @@ static int img_check(int argc, char **argv) return 1; } + if (result.corruptions_fixed || result.leaks_fixed) { + printf("The following inconsistencies were found and repaired:\n\n" + " %d leaked clusters\n" + " %d corruptions\n\n" + "Double checking the fixed image now...\n", + result.leaks_fixed, + result.corruptions_fixed); + ret = bdrv_check(bs, &result, 0); + } + if (!(result.corruptions || result.leaks || result.check_errors)) { printf("No errors were found on the image.\n"); } else {