qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qemu-io: Fix 'map' output


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] qemu-io: Fix 'map' output
Date: Thu, 16 May 2013 14:15:00 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, May 16, 2013 at 11:24:01AM +0200, Kevin Wolf wrote:
> 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.

Yes, please.  I didn't think of that.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]