yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-vmdk-Use-bdrv_nb_sectors-where-sectors-not-bytes-are.patch

958e1b
From 1d5ecdd5402c43fc20deefe64ee72172cd645486 Mon Sep 17 00:00:00 2001
958e1b
Message-Id: <1d5ecdd5402c43fc20deefe64ee72172cd645486.1418766606.git.jen@redhat.com>
958e1b
In-Reply-To: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
958e1b
References: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
958e1b
From: Fam Zheng <famz@redhat.com>
958e1b
Date: Thu, 4 Dec 2014 00:05:21 -0600
958e1b
Subject: [CHANGE 27/31] vmdk: Use bdrv_nb_sectors() where sectors, not bytes
958e1b
 are wanted
958e1b
MIME-Version: 1.0
958e1b
Content-Type: text/plain; charset=UTF-8
958e1b
Content-Transfer-Encoding: 8bit
958e1b
To: rhvirt-patches@redhat.com,
958e1b
    jen@redhat.com
958e1b
958e1b
RH-Author: Fam Zheng <famz@redhat.com>
958e1b
Message-id: <1417651524-18041-28-git-send-email-famz@redhat.com>
958e1b
Patchwork-id: 62700
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 27/30] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted
958e1b
Bugzilla: 1002493
958e1b
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
958e1b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
958e1b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
958e1b
958e1b
From: Markus Armbruster <armbru@redhat.com>
958e1b
958e1b
Instead of bdrv_getlength().
958e1b
958e1b
Commit 57322b7 did this all over block, but one more bdrv_getlength()
958e1b
has crept in since.
958e1b
958e1b
Signed-off-by: Markus Armbruster <armbru@redhat.com>
958e1b
Reviewed-by: Fam Zheng <famz@redhat.com>
958e1b
Reviewed-by: BenoƮt Canet <benoit.canet@nodalink.com>
958e1b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
958e1b
(cherry picked from commit 0a156f7c750c4e4e1c5dfb2135debcf399e4e2a7)
958e1b
Signed-off-by: Fam Zheng <famz@redhat.com>
958e1b
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
958e1b
---
958e1b
 block/vmdk.c | 11 +++++------
958e1b
 1 file changed, 5 insertions(+), 6 deletions(-)
958e1b
958e1b
diff --git a/block/vmdk.c b/block/vmdk.c
958e1b
index 560dd43..b9ab89b 100644
958e1b
--- a/block/vmdk.c
958e1b
+++ b/block/vmdk.c
958e1b
@@ -397,7 +397,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
958e1b
 {
958e1b
     VmdkExtent *extent;
958e1b
     BDRVVmdkState *s = bs->opaque;
958e1b
-    int64_t length;
958e1b
+    int64_t nb_sectors;
958e1b
 
958e1b
     if (cluster_sectors > 0x200000) {
958e1b
         /* 0x200000 * 512Bytes = 1GB for one cluster is unrealistic */
958e1b
@@ -413,9 +413,9 @@ static int vmdk_add_extent(BlockDriverState *bs,
958e1b
         return -EFBIG;
958e1b
     }
958e1b
 
958e1b
-    length = bdrv_getlength(file);
958e1b
-    if (length < 0) {
958e1b
-        return length;
958e1b
+    nb_sectors = bdrv_nb_sectors(file);
958e1b
+    if (nb_sectors < 0) {
958e1b
+        return nb_sectors;
958e1b
     }
958e1b
 
958e1b
     s->extents = g_realloc(s->extents,
958e1b
@@ -433,8 +433,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
958e1b
     extent->l1_entry_sectors = l2_size * cluster_sectors;
958e1b
     extent->l2_size = l2_size;
958e1b
     extent->cluster_sectors = flat ? sectors : cluster_sectors;
958e1b
-    extent->next_cluster_sector =
958e1b
-        ROUND_UP(DIV_ROUND_UP(length, BDRV_SECTOR_SIZE), cluster_sectors);
958e1b
+    extent->next_cluster_sector = ROUND_UP(nb_sectors, cluster_sectors);
958e1b
 
958e1b
     if (s->num_extents > 1) {
958e1b
         extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
958e1b
-- 
958e1b
2.1.0
958e1b