aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/qcow2.c')
-rw-r--r--block/qcow2.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index 5ab1f45fe2..6738daa247 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2036,7 +2036,7 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,
BlockDriverState **file)
{
BDRVQcow2State *s = bs->opaque;
- uint64_t cluster_offset;
+ uint64_t host_offset;
unsigned int bytes;
int ret, status = 0;
@@ -2049,7 +2049,7 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,
}
bytes = MIN(INT_MAX, count);
- ret = qcow2_get_cluster_offset(bs, offset, &bytes, &cluster_offset);
+ ret = qcow2_get_host_offset(bs, offset, &bytes, &host_offset);
qemu_co_mutex_unlock(&s->lock);
if (ret < 0) {
return ret;
@@ -2059,7 +2059,7 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,
if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC) &&
!s->crypto) {
- *map = cluster_offset | offset_into_cluster(s, offset);
+ *map = host_offset;
*file = s->data_file->bs;
status |= BDRV_BLOCK_OFFSET_VALID;
}
@@ -2273,7 +2273,7 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,
BDRVQcow2State *s = bs->opaque;
int ret = 0;
unsigned int cur_bytes; /* number of bytes in current iteration */
- uint64_t cluster_offset = 0;
+ uint64_t host_offset = 0;
AioTaskPool *aio = NULL;
while (bytes != 0 && aio_task_pool_status(aio) == 0) {
@@ -2285,7 +2285,7 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,
}
qemu_co_mutex_lock(&s->lock);
- ret = qcow2_get_cluster_offset(bs, offset, &cur_bytes, &cluster_offset);
+ ret = qcow2_get_host_offset(bs, offset, &cur_bytes, &host_offset);
qemu_co_mutex_unlock(&s->lock);
if (ret < 0) {
goto out;
@@ -2297,15 +2297,6 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,
{
qemu_iovec_memset(qiov, qiov_offset, 0, cur_bytes);
} else {
- /*
- * For compressed clusters the variable cluster_offset
- * does not actually store the offset but the full
- * descriptor. We need to leave it unchanged because
- * that's what qcow2_co_preadv_compressed() expects.
- */
- uint64_t host_offset = (ret == QCOW2_CLUSTER_COMPRESSED) ?
- cluster_offset :
- cluster_offset + offset_into_cluster(s, offset);
if (!aio && cur_bytes != bytes) {
aio = aio_task_pool_new(QCOW2_MAX_WORKERS);
}
@@ -3853,7 +3844,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs,
offset = QEMU_ALIGN_DOWN(offset, s->cluster_size);
bytes = s->cluster_size;
nr = s->cluster_size;
- ret = qcow2_get_cluster_offset(bs, offset, &nr, &off);
+ ret = qcow2_get_host_offset(bs, offset, &nr, &off);
if (ret != QCOW2_CLUSTER_UNALLOCATED &&
ret != QCOW2_CLUSTER_ZERO_PLAIN &&
ret != QCOW2_CLUSTER_ZERO_ALLOC) {
@@ -3924,7 +3915,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs,
cur_bytes = MIN(bytes, INT_MAX);
cur_write_flags = write_flags;
- ret = qcow2_get_cluster_offset(bs, src_offset, &cur_bytes, &copy_offset);
+ ret = qcow2_get_host_offset(bs, src_offset, &cur_bytes, &copy_offset);
if (ret < 0) {
goto out;
}
@@ -3956,7 +3947,6 @@ qcow2_co_copy_range_from(BlockDriverState *bs,
case QCOW2_CLUSTER_NORMAL:
child = s->data_file;
- copy_offset += offset_into_cluster(s, src_offset);
break;
default: