All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
@ 2014-08-20 17:07 Markus Armbruster
  2014-08-20 18:55 ` Eric Blake
  2014-08-21  1:15 ` Fam Zheng
  0 siblings, 2 replies; 8+ messages in thread
From: Markus Armbruster @ 2014-08-20 17:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, famz, stefanha

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>
---
 block/vmdk.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 01412a8..3b74e85 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_getlength(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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
  2014-08-20 17:07 [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted Markus Armbruster
@ 2014-08-20 18:55 ` Eric Blake
  2014-08-21  1:15 ` Fam Zheng
  1 sibling, 0 replies; 8+ messages in thread
From: Eric Blake @ 2014-08-20 18:55 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: kwolf, famz, stefanha

[-- Attachment #1: Type: text/plain, Size: 497 bytes --]

On 08/20/2014 11:07 AM, 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>
> ---
>  block/vmdk.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
  2014-08-20 17:07 [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted Markus Armbruster
  2014-08-20 18:55 ` Eric Blake
@ 2014-08-21  1:15 ` Fam Zheng
  2014-08-21  6:43   ` Markus Armbruster
  1 sibling, 1 reply; 8+ messages in thread
From: Fam Zheng @ 2014-08-21  1:15 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha

On Wed, 08/20 19:07, 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>
> ---
>  block/vmdk.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 01412a8..3b74e85 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_getlength(file);

Should be bdrv_nb_sectors.

Fam

> +    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
> 
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
  2014-08-21  1:15 ` Fam Zheng
@ 2014-08-21  6:43   ` Markus Armbruster
  2014-08-21  7:09     ` Fam Zheng
  2014-08-21  8:35     ` Kevin Wolf
  0 siblings, 2 replies; 8+ messages in thread
From: Markus Armbruster @ 2014-08-21  6:43 UTC (permalink / raw)
  To: Fam Zheng; +Cc: kwolf, qemu-devel, stefanha

Fam Zheng <famz@redhat.com> writes:

> On Wed, 08/20 19:07, 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>
>> ---
>>  block/vmdk.c | 11 +++++------
>>  1 file changed, 5 insertions(+), 6 deletions(-)
>> 
>> diff --git a/block/vmdk.c b/block/vmdk.c
>> index 01412a8..3b74e85 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_getlength(file);
>
> Should be bdrv_nb_sectors.

Brown paperbag...  I shouldn't do "trivial" patches when tired.

I wish "make check-block" covered a bit more, or there was something
that does while being trivial enough for me to run it unthinkingly.

Thanks!

[...]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
  2014-08-21  6:43   ` Markus Armbruster
@ 2014-08-21  7:09     ` Fam Zheng
  2014-08-21  8:35     ` Kevin Wolf
  1 sibling, 0 replies; 8+ messages in thread
From: Fam Zheng @ 2014-08-21  7:09 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha

On Thu, 08/21 08:43, Markus Armbruster wrote:
> Fam Zheng <famz@redhat.com> writes:
> 
> > On Wed, 08/20 19:07, 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>
> >> ---
> >>  block/vmdk.c | 11 +++++------
> >>  1 file changed, 5 insertions(+), 6 deletions(-)
> >> 
> >> diff --git a/block/vmdk.c b/block/vmdk.c
> >> index 01412a8..3b74e85 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_getlength(file);
> >
> > Should be bdrv_nb_sectors.
> 
> Brown paperbag...  I shouldn't do "trivial" patches when tired.
> 
> I wish "make check-block" covered a bit more, or there was something
> that does while being trivial enough for me to run it unthinkingly.
> 

The test case here would be "write a little more data to the image, assert that
the file size (EOF offset) doesn't explode". :)

Fam

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
  2014-08-21  6:43   ` Markus Armbruster
  2014-08-21  7:09     ` Fam Zheng
@ 2014-08-21  8:35     ` Kevin Wolf
  2014-08-21 12:22       ` Markus Armbruster
  1 sibling, 1 reply; 8+ messages in thread
From: Kevin Wolf @ 2014-08-21  8:35 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Fam Zheng, qemu-devel, stefanha

Am 21.08.2014 um 08:43 hat Markus Armbruster geschrieben:
> Fam Zheng <famz@redhat.com> writes:
> 
> > On Wed, 08/20 19:07, 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>
> >> ---
> >>  block/vmdk.c | 11 +++++------
> >>  1 file changed, 5 insertions(+), 6 deletions(-)
> >> 
> >> diff --git a/block/vmdk.c b/block/vmdk.c
> >> index 01412a8..3b74e85 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_getlength(file);
> >
> > Should be bdrv_nb_sectors.
> 
> Brown paperbag...  I shouldn't do "trivial" patches when tired.

The worst part is that it got a Reviewed-by which might just have fooled
me if Fam hadn't reviewed it as well. :-/

> I wish "make check-block" covered a bit more, or there was something
> that does while being trivial enough for me to run it unthinkingly.

Well, you know what you have to do for v2, right? qemu-iotests is
in-tree for a reason.

Kevin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
  2014-08-21  8:35     ` Kevin Wolf
@ 2014-08-21 12:22       ` Markus Armbruster
  2014-08-21 12:33         ` Eric Blake
  0 siblings, 1 reply; 8+ messages in thread
From: Markus Armbruster @ 2014-08-21 12:22 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Fam Zheng, qemu-devel, stefanha

Kevin Wolf <kwolf@redhat.com> writes:

> Am 21.08.2014 um 08:43 hat Markus Armbruster geschrieben:
>> Fam Zheng <famz@redhat.com> writes:
>> 
>> > On Wed, 08/20 19:07, 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>
>> >> ---
>> >>  block/vmdk.c | 11 +++++------
>> >>  1 file changed, 5 insertions(+), 6 deletions(-)
>> >> 
>> >> diff --git a/block/vmdk.c b/block/vmdk.c
>> >> index 01412a8..3b74e85 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_getlength(file);
>> >
>> > Should be bdrv_nb_sectors.
>> 
>> Brown paperbag...  I shouldn't do "trivial" patches when tired.
>
> The worst part is that it got a Reviewed-by which might just have fooled
> me if Fam hadn't reviewed it as well. :-/

This kind of idiotic error is hard to spot in review for the same reason
it's easy to make when tired.

>> I wish "make check-block" covered a bit more, or there was something
>> that does while being trivial enough for me to run it unthinkingly.
>
> Well, you know what you have to do for v2, right? qemu-iotests is
> in-tree for a reason.

All right, "./check -T -vmdk -g quick" would've caught this.

I tried it with -nocache first, because that's how tests/check-block.sh
runs it, but that fails due to a bug we traced back to raw-posix in
#qemu.  Stefan is taking care of it.

Looks like check-block.sh hasn't been used much lately.  I didn't know
it existed until it showed up in a grep.

I'll respin this patch.  I'll discuss improving "make check-block" in a
new thread.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
  2014-08-21 12:22       ` Markus Armbruster
@ 2014-08-21 12:33         ` Eric Blake
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Blake @ 2014-08-21 12:33 UTC (permalink / raw)
  To: Markus Armbruster, Kevin Wolf; +Cc: Fam Zheng, qemu-devel, stefanha

[-- Attachment #1: Type: text/plain, Size: 761 bytes --]

On 08/21/2014 06:22 AM, Markus Armbruster wrote:
> Kevin Wolf <kwolf@redhat.com> writes:
> 

>> The worst part is that it got a Reviewed-by which might just have fooled
>> me if Fam hadn't reviewed it as well. :-/
> 
> This kind of idiotic error is hard to spot in review for the same reason
> it's easy to make when tired.

Indeed; I had merely reviewed that the patch looked sane, and not
actually tested against a testsuite, so I'm glad Fam caught it.  There's
a reason I've been sticking with Reviewed-by and not Tested-by, although
I agree that enhancing the testsuite to make sure dumb things like this
get caught is worthwhile.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-08-21 12:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-20 17:07 [Qemu-devel] [PATCH 1/1] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted Markus Armbruster
2014-08-20 18:55 ` Eric Blake
2014-08-21  1:15 ` Fam Zheng
2014-08-21  6:43   ` Markus Armbruster
2014-08-21  7:09     ` Fam Zheng
2014-08-21  8:35     ` Kevin Wolf
2014-08-21 12:22       ` Markus Armbruster
2014-08-21 12:33         ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.