qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2] vmdk: Use bdrv_nb_sectors() where sectors, n


From: Benoît Canet
Subject: Re: [Qemu-devel] [PATCH v2] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
Date: Thu, 21 Aug 2014 19:38:16 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

The Thursday 21 Aug 2014 à 14:36:19 (+0200), Markus Armbruster wrote :
> Instead of bdrv_getlength().
> 
> Commit 57322b7 did this all over block, but one more bdrv_getlength()
> has crept in since.
> 
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> v2: Actually use bdrv_nb_sectors() as advertized [Fam]
> Passes ./check -T -vmdk -g quick
> 
>  block/vmdk.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> 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 = bs->opaque;
> -    int64_t length;
> +    int64_t nb_sectors;
>  
>      if (cluster_sectors > 0x200000) {
>          /* 0x200000 * 512Bytes = 1GB for one cluster is unrealistic */
> @@ -413,9 +413,9 @@ static int vmdk_add_extent(BlockDriverState *bs,
>          return -EFBIG;
>      }
>  
> -    length = bdrv_getlength(file);
> -    if (length < 0) {
> -        return length;
> +    nb_sectors = bdrv_nb_sectors(file);
> +    if (nb_sectors < 0) {
> +        return nb_sectors;
>      }
>  
>      s->extents = g_realloc(s->extents,
> @@ -433,8 +433,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
>      extent->l1_entry_sectors = l2_size * cluster_sectors;
>      extent->l2_size = l2_size;
>      extent->cluster_sectors = flat ? sectors : cluster_sectors;
> -    extent->next_cluster_sector =
> -        ROUND_UP(DIV_ROUND_UP(length, BDRV_SECTOR_SIZE), cluster_sectors);
> +    extent->next_cluster_sector = ROUND_UP(nb_sectors, cluster_sectors);
>  
>      if (s->num_extents > 1) {
>          extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
> -- 
> 1.9.3
> 
> 
Reviewed-by: Benoît Canet <address@hidden>



reply via email to

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