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