qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
Date: Fri, 22 Aug 2014 08:43:49 +0800	[thread overview]
Message-ID: <20140822004349.GA3410@T430.redhat.com> (raw)
In-Reply-To: <1408624579-22382-1-git-send-email-armbru@redhat.com>

On Thu, 08/21 14:36, 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 <armbru@redhat.com>
> ---
> 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: Fam Zheng <famz@redhat.com>

  parent reply	other threads:[~2014-08-22  0:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-21 12:36 [Qemu-devel] [PATCH v2] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted Markus Armbruster
2014-08-21 17:38 ` Benoît Canet
2014-08-22  0:43 ` Fam Zheng [this message]
2014-08-22  9:10 ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140822004349.GA3410@T430.redhat.com \
    --to=famz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).