qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qemu-io: Fix 'map' output
Date: Thu, 16 May 2013 11:24:01 +0200	[thread overview]
Message-ID: <20130516092401.GD2467@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <20130516091421.GJ1597@stefanha-thinkpad.redhat.com>

Am 16.05.2013 um 11:14 hat Stefan Hajnoczi geschrieben:
> On Wed, May 15, 2013 at 01:47:12PM +0200, Kevin Wolf wrote:
> > +static int map_is_allocated(int64_t sector_num, int64_t nb_sectors, int64_t *pnum)
> > +{
> > +    int num, num_checked;
> > +    int ret, firstret;
> > +
> > +    num_checked = MIN(nb_sectors, INT_MAX);
> > +    ret = bdrv_is_allocated(bs, sector_num, num_checked, &num);
> > +    if (ret < 0) {
> > +        return ret;
> > +    }
> > +
> > +    firstret = ret;
> > +    *pnum = num;
> > +
> > +    while (nb_sectors > 0 && ret == firstret) {
> > +        sector_num += num;
> > +        nb_sectors -= num;
> > +
> > +        num_checked = MIN(nb_sectors, INT_MAX);
> > +        ret = bdrv_is_allocated(bs, sector_num, num_checked, &num);
> > +        if (ret == firstret) {
> > +            *pnum += num;
> > +        } else {
> > +            break;
> > +        }
> 
> The break makes && ret == firstret redundant above.  I suggest just
> while (nb_sectors > 0) { ... } which is easier to read.

Okay. I wasn't sure which was better. Don't know though how it came that
I have both checks now...

> Also, if you respin the patch please tweak the commit message.
> "Coalesce 'map' output" is more specific than "Fix 'map' output" -
> unless this really fixes a bug which you didn't mention in the commit
> description.

I'll change the title. It makes different formats behave the same even
if they work in different granularities. I think QED was bitten by this
in qemu-iotests somwhere because it could give different results than
qcow2, possibly also dependent on timing. Maybe I should mention that as
well in the commit message.

Kevin

  reply	other threads:[~2013-05-16  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-15 11:47 [Qemu-devel] [PATCH] qemu-io: Fix 'map' output Kevin Wolf
2013-05-16  9:14 ` Stefan Hajnoczi
2013-05-16  9:24   ` Kevin Wolf [this message]
2013-05-16 12:15     ` 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=20130516092401.GD2467@dhcp-200-207.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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).