From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcuPv-000703-5t for qemu-devel@nongnu.org; Thu, 16 May 2013 05:24:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UcuPt-0008Bi-1v for qemu-devel@nongnu.org; Thu, 16 May 2013 05:24:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12489) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcuPs-0008B6-PN for qemu-devel@nongnu.org; Thu, 16 May 2013 05:24:04 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4G9O4ZJ007059 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 16 May 2013 05:24:04 -0400 Date: Thu, 16 May 2013 11:24:01 +0200 From: Kevin Wolf Message-ID: <20130516092401.GD2467@dhcp-200-207.str.redhat.com> References: <1368618432-4431-1-git-send-email-kwolf@redhat.com> <20130516091421.GJ1597@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130516091421.GJ1597@stefanha-thinkpad.redhat.com> Subject: Re: [Qemu-devel] [PATCH] qemu-io: Fix 'map' output List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org 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