[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/25] vmdk: Use vmdk_find_index_in_cluster everywher
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 07/25] vmdk: Use vmdk_find_index_in_cluster everywhere |
Date: |
Fri, 12 Jun 2015 18:23:16 +0200 |
From: Fam Zheng <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vmdk.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index 3e4d84b..56626b0 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1424,7 +1424,6 @@ static int vmdk_read(BlockDriverState *bs, int64_t
sector_num,
BDRVVmdkState *s = bs->opaque;
int ret;
uint64_t n, index_in_cluster;
- uint64_t extent_begin_sector, extent_relative_sector_num;
VmdkExtent *extent = NULL;
uint64_t cluster_offset;
@@ -1436,9 +1435,7 @@ static int vmdk_read(BlockDriverState *bs, int64_t
sector_num,
ret = get_cluster_offset(bs, extent, NULL,
sector_num << 9, false, &cluster_offset,
0, 0);
- extent_begin_sector = extent->end_sector - extent->sectors;
- extent_relative_sector_num = sector_num - extent_begin_sector;
- index_in_cluster = extent_relative_sector_num %
extent->cluster_sectors;
+ index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num);
n = extent->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
@@ -1500,7 +1497,6 @@ static int vmdk_write(BlockDriverState *bs, int64_t
sector_num,
VmdkExtent *extent = NULL;
int ret;
int64_t index_in_cluster, n;
- uint64_t extent_begin_sector, extent_relative_sector_num;
uint64_t cluster_offset;
VmdkMetaData m_data;
@@ -1516,9 +1512,7 @@ static int vmdk_write(BlockDriverState *bs, int64_t
sector_num,
if (!extent) {
return -EIO;
}
- extent_begin_sector = extent->end_sector - extent->sectors;
- extent_relative_sector_num = sector_num - extent_begin_sector;
- index_in_cluster = extent_relative_sector_num %
extent->cluster_sectors;
+ index_in_cluster = vmdk_find_index_in_cluster(extent, sector_num);
n = extent->cluster_sectors - index_in_cluster;
if (n > nb_sectors) {
n = nb_sectors;
--
1.8.3.1
- [Qemu-devel] [PULL 00/25] Block layer core and image format patches, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 01/25] iotests: remove assertIsNotNone call, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 02/25] qemu-iotests: Fix 128 if sudo required, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 03/25] qcow2: Set MIN_L2_CACHE_SIZE to 2, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 04/25] iotests: qcow2 COW with minimal L2 cache size, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 05/25] qcow2: Add DEFAULT_L2_CACHE_CLUSTERS, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 06/25] vmdk: Fix index_in_cluster calculation in vmdk_co_get_block_status, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 08/25] raw-posix: Fix .bdrv_co_get_block_status() for unaligned image size, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 07/25] vmdk: Use vmdk_find_index_in_cluster everywhere,
Kevin Wolf <=
- [Qemu-devel] [PULL 09/25] block: record new size in bdrv_dirty_bitmap_truncate, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 10/25] block: Change bitmap truncate conditional to assertion, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 11/25] block: driver should override flags in bdrv_open(), Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 12/25] iotests: Add tests for overriding BDRV_O_PROTOCOL, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 13/25] qdict: Add qdict_array_entries(), Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 15/25] check-qdict: Test cases for new functions, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 14/25] qdict: Add qdict_{set,copy}_default(), Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 16/25] quorum: Use bdrv_open_image(), Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 18/25] block: Use macro for cache option names, Kevin Wolf, 2015/06/12
- [Qemu-devel] [PULL 19/25] block: Use QemuOpts in bdrv_open_common(), Kevin Wolf, 2015/06/12