From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrThJ-0007fw-RI for qemu-devel@nongnu.org; Mon, 02 Jun 2014 10:58:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrTh8-0000Pp-8w for qemu-devel@nongnu.org; Mon, 02 Jun 2014 10:58:49 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:38629 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrTh8-0000Pa-3f for qemu-devel@nongnu.org; Mon, 02 Jun 2014 10:58:38 -0400 Date: Mon, 2 Jun 2014 16:58:37 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140602145836.GD8181@irqsave.net> References: <1401473631-10724-1-git-send-email-armbru@redhat.com> <1401473631-10724-5-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1401473631-10724-5-git-send-email-armbru@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 04/10] block: Use bdrv_nb_sectors() in bdrv_aligned_preadv() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com The Friday 30 May 2014 =E0 20:13:45 (+0200), Markus Armbruster wrote : > Instead of bdrv_getlength(). Eliminate variable len. >=20 > Signed-off-by: Markus Armbruster > Reviewed-by: Eric Blake > --- > block.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) >=20 > diff --git a/block.c b/block.c > index 9517108..6639d09 100644 > --- a/block.c > +++ b/block.c > @@ -3081,15 +3081,14 @@ static int coroutine_fn bdrv_aligned_preadv(Blo= ckDriverState *bs, > ret =3D drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov); > } else { > /* Read zeros after EOF of growable BDSes */ > - int64_t len, total_sectors, max_nb_sectors; > + int64_t total_sectors, max_nb_sectors; > =20 > - len =3D bdrv_getlength(bs); > - if (len < 0) { > - ret =3D len; > + total_sectors =3D bdrv_nb_sectors(bs); > + if (total_sectors < 0) { > + ret =3D total_sectors; > goto out; > } > =20 > - total_sectors =3D DIV_ROUND_UP(len, BDRV_SECTOR_SIZE); > max_nb_sectors =3D ROUND_UP(MAX(0, total_sectors - sector_num)= , > align >> BDRV_SECTOR_BITS); > if (max_nb_sectors > 0) { > --=20 > 1.9.3 >=20 >=20 Reviewed-by: Benoit Canet