yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-vmdk-Use-vmdk_find_index_in_cluster-everywhere.patch

34b321
From f7f34dfdb448a0344210f6bfa77b67c637ffea56 Mon Sep 17 00:00:00 2001
34b321
From: Fam Zheng <famz@redhat.com>
34b321
Date: Mon, 15 Feb 2016 09:28:27 +0100
34b321
Subject: [PATCH 14/18] vmdk: Use vmdk_find_index_in_cluster everywhere
34b321
34b321
RH-Author: Fam Zheng <famz@redhat.com>
34b321
Message-id: <1455528511-9357-15-git-send-email-famz@redhat.com>
34b321
Patchwork-id: 69180
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH 14/18] vmdk: Use vmdk_find_index_in_cluster everywhere
34b321
Bugzilla: 1299250
34b321
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
34b321
RH-Acked-by: Max Reitz <mreitz@redhat.com>
34b321
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
34b321
34b321
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1299250
34b321
34b321
Signed-off-by: Fam Zheng <famz@redhat.com>
34b321
Reviewed-by: Max Reitz <mreitz@redhat.com>
34b321
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
34b321
(cherry picked from commit 90df601f06de14f062d2e8dc1bc57f0decf86fd1)
34b321
Signed-off-by: Fam Zheng <famz@redhat.com>
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
---
34b321
 block/vmdk.c | 10 ++--------
34b321
 1 file changed, 2 insertions(+), 8 deletions(-)
34b321
34b321
diff --git a/block/vmdk.c b/block/vmdk.c
34b321
index 10c08f3..cb5255c 100644
34b321
--- a/block/vmdk.c
34b321
+++ b/block/vmdk.c
34b321
@@ -1418,7 +1418,6 @@ static int vmdk_read(BlockDriverState *bs, int64_t sector_num,
34b321
     BDRVVmdkState *s = bs->opaque;
34b321
     int ret;
34b321
     uint64_t n, index_in_cluster;
34b321
-    uint64_t extent_begin_sector, extent_relative_sector_num;
34b321
     VmdkExtent *extent = NULL;
34b321
     uint64_t cluster_offset;
34b321
 
34b321
@@ -1430,9 +1429,7 @@ static int vmdk_read(BlockDriverState *bs, int64_t sector_num,
34b321
         ret = get_cluster_offset(bs, extent, NULL,
34b321
                                  sector_num << 9, false, &cluster_offset,
34b321
                                  0, 0);
34b321
-        extent_begin_sector = extent->end_sector - extent->sectors;
34b321
-        extent_relative_sector_num = sector_num - extent_begin_sector;
34b321
-        index_in_cluster = extent_relative_sector_num % extent->cluster_sectors;
34b321
+        index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num);
34b321
         n = extent->cluster_sectors - index_in_cluster;
34b321
         if (n > nb_sectors) {
34b321
             n = nb_sectors;
34b321
@@ -1494,7 +1491,6 @@ static int vmdk_write(BlockDriverState *bs, int64_t sector_num,
34b321
     VmdkExtent *extent = NULL;
34b321
     int ret;
34b321
     int64_t index_in_cluster, n;
34b321
-    uint64_t extent_begin_sector, extent_relative_sector_num;
34b321
     uint64_t cluster_offset;
34b321
     VmdkMetaData m_data;
34b321
 
34b321
@@ -1510,9 +1506,7 @@ static int vmdk_write(BlockDriverState *bs, int64_t sector_num,
34b321
         if (!extent) {
34b321
             return -EIO;
34b321
         }
34b321
-        extent_begin_sector = extent->end_sector - extent->sectors;
34b321
-        extent_relative_sector_num = sector_num - extent_begin_sector;
34b321
-        index_in_cluster = extent_relative_sector_num % extent->cluster_sectors;
34b321
+        index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num);
34b321
         n = extent->cluster_sectors - index_in_cluster;
34b321
         if (n > nb_sectors) {
34b321
             n = nb_sectors;
34b321
-- 
34b321
1.8.3.1
34b321