From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKWKJ-0005U6-TC for qemu-devel@nongnu.org; Thu, 21 Aug 2014 13:39:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKWKE-00007e-Qv for qemu-devel@nongnu.org; Thu, 21 Aug 2014 13:39:07 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:59371 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKWKE-00007G-KI for qemu-devel@nongnu.org; Thu, 21 Aug 2014 13:39:02 -0400 Date: Thu, 21 Aug 2014 19:38:16 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140821173816.GC26320@irqsave.net> References: <1408624579-22382-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1408624579-22382-1-git-send-email-armbru@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, famz@redhat.com.com, qemu-devel@nongnu.org, stefanha@redhat.com The Thursday 21 Aug 2014 =E0 14:36:19 (+0200), Markus Armbruster wrote : > Instead of bdrv_getlength(). >=20 > Commit 57322b7 did this all over block, but one more bdrv_getlength() > has crept in since. >=20 > Signed-off-by: Markus Armbruster > --- > v2: Actually use bdrv_nb_sectors() as advertized [Fam] > Passes ./check -T -vmdk -g quick >=20 > block/vmdk.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) >=20 > diff --git a/block/vmdk.c b/block/vmdk.c > index 01412a8..6ca8684 100644 > --- a/block/vmdk.c > +++ b/block/vmdk.c > @@ -397,7 +397,7 @@ static int vmdk_add_extent(BlockDriverState *bs, > { > VmdkExtent *extent; > BDRVVmdkState *s =3D bs->opaque; > - int64_t length; > + int64_t nb_sectors; > =20 > if (cluster_sectors > 0x200000) { > /* 0x200000 * 512Bytes =3D 1GB for one cluster is unrealistic = */ > @@ -413,9 +413,9 @@ static int vmdk_add_extent(BlockDriverState *bs, > return -EFBIG; > } > =20 > - length =3D bdrv_getlength(file); > - if (length < 0) { > - return length; > + nb_sectors =3D bdrv_nb_sectors(file); > + if (nb_sectors < 0) { > + return nb_sectors; > } > =20 > s->extents =3D g_realloc(s->extents, > @@ -433,8 +433,7 @@ static int vmdk_add_extent(BlockDriverState *bs, > extent->l1_entry_sectors =3D l2_size * cluster_sectors; > extent->l2_size =3D l2_size; > extent->cluster_sectors =3D flat ? sectors : cluster_sectors; > - extent->next_cluster_sector =3D > - ROUND_UP(DIV_ROUND_UP(length, BDRV_SECTOR_SIZE), cluster_secto= rs); > + extent->next_cluster_sector =3D ROUND_UP(nb_sectors, cluster_secto= rs); > =20 > if (s->num_extents > 1) { > extent->end_sector =3D (*(extent - 1)).end_sector + extent->se= ctors; > --=20 > 1.9.3 >=20 >=20 Reviewed-by: Beno=EEt Canet