* [Qemu-devel] [PATCH v2] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
@ 2014-08-21 12:36 Markus Armbruster
2014-08-21 17:38 ` Benoît Canet
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Markus Armbruster @ 2014-08-21 12:36 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>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
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
2014-08-22 9:10 ` Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Benoît Canet @ 2014-08-21 17:38 UTC (permalink / raw)
To: Markus Armbruster; +Cc: kwolf, famz, qemu-devel, stefanha
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 <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: Benoît Canet <benoit.canet@nodalink.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
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
2014-08-22 9:10 ` Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Fam Zheng @ 2014-08-22 0:43 UTC (permalink / raw)
To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
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
@ 2014-08-22 9:10 ` Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2014-08-22 9:10 UTC (permalink / raw)
To: Markus Armbruster; +Cc: famz, qemu-devel, stefanha
Am 21.08.2014 um 14:36 hat Markus Armbruster geschrieben:
> 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
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-22 9:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2014-08-22 9:10 ` Kevin Wolf
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).