qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@gmail.com
Subject: [Qemu-devel] [PATCH 2/3] qemu-img check: Print fixed clusters and recheck
Date: Fri, 11 May 2012 18:48:50 +0200	[thread overview]
Message-ID: <1336754931-20058-3-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1336754931-20058-1-git-send-email-kwolf@redhat.com>

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 <kwolf@redhat.com>
---
 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 b151076..e74be21 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 {
-- 
1.7.6.5

  parent reply	other threads:[~2012-05-11 18:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-11 16:48 [Qemu-devel] [PATCH block-next 0/3] qemu-img check/qcow2: Allow fixing refcounts Kevin Wolf
2012-05-11 16:48 ` [Qemu-devel] [PATCH 1/3] qemu-img check -r for repairing images Kevin Wolf
2012-05-11 16:48 ` Kevin Wolf [this message]
2012-05-11 16:48 ` [Qemu-devel] [PATCH 3/3] qcow2: Support for fixing refcount inconsistencies Kevin Wolf
2012-05-25 15:33   ` Stefan Hajnoczi
2012-05-25 16:28     ` Kevin Wolf
2012-05-25 15:34 ` [Qemu-devel] [PATCH block-next 0/3] qemu-img check/qcow2: Allow fixing refcounts Stefan Hajnoczi
     [not found] ` <CAEH94Lj24QE5SS5EyYUy1+BGqn=LihGVn8SRbxt8t9X+RVQ6-A@mail.gmail.com>
     [not found]   ` <CAJSP0QW1Er9wQ8syyKyWc7p=_QSmN4Qj-ekSZZ++Zg=--UjkmA@mail.gmail.com>
2012-06-01  5:22     ` Zhi Yong Wu
2012-06-01  8:06       ` Stefan Hajnoczi
2012-06-01  8:26         ` Zhi Yong Wu
2012-06-06 10:32           ` Stefan Hajnoczi
2012-06-06 14:53             ` Zhi Yong Wu
2012-06-07 15:07               ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336754931-20058-3-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).