qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/3] qcow2: Support for fixing refcount inconsistencies
Date: Fri, 25 May 2012 16:33:18 +0100	[thread overview]
Message-ID: <CAJSP0QWb0J3GyXQJjRVbig7APF6EdFGBSrY+COuYi3B2h4cOKw@mail.gmail.com> (raw)
In-Reply-To: <1336754931-20058-4-git-send-email-kwolf@redhat.com>

On Fri, May 11, 2012 at 5:48 PM, Kevin Wolf <kwolf@redhat.com> wrote:
> @@ -1205,9 +1206,31 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res)
>
>         refcount2 = refcount_table[i];
>         if (refcount1 != refcount2) {
> +
> +            /* Check if we're allowed to fix the mismatch */
> +            int *num_fixed = NULL;
> +            if (refcount1 > refcount2 && (fix & BDRV_FIX_LEAKS)) {
> +                num_fixed = &res->leaks_fixed;
> +            } else if (refcount1 < refcount2 && (fix & BDRV_FIX_ERRORS)) {
> +                num_fixed = &res->corruptions_fixed;
> +            }
> +
>             fprintf(stderr, "%s cluster %d refcount=%d reference=%d\n",
> -                   refcount1 < refcount2 ? "ERROR" : "Leaked",
> +                   num_fixed != NULL     ? "Repairing" :
> +                   refcount1 < refcount2 ? "ERROR" :
> +                                           "Leaked",
>                    i, refcount1, refcount2);
> +
> +            if (num_fixed) {
> +                ret = update_refcount(bs, i << s->cluster_bits, 1,
> +                                      refcount2 - refcount1);

It would be nicer to use int64_t for i.  I haven't checked but it
makes me nervous to shift ints here.

Stefan

  reply	other threads:[~2012-05-25 15:33 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 ` [Qemu-devel] [PATCH 2/3] qemu-img check: Print fixed clusters and recheck Kevin Wolf
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 [this message]
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=CAJSP0QWb0J3GyXQJjRVbig7APF6EdFGBSrY+COuYi3B2h4cOKw@mail.gmail.com \
    --to=stefanha@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).