[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/30] qcow2: Use offset_into_cluster()
From: |
Kevin Wolf |
Subject: |
[PULL 12/30] qcow2: Use offset_into_cluster() |
Date: |
Thu, 19 Dec 2019 18:24:23 +0100 |
From: Alberto Garcia <address@hidden>
There's a couple of places left in the qcow2 code that still do the
calculation manually, so let's replace them.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index de0e89cf25..375bbd0ad3 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -367,7 +367,7 @@ static int qcow2_read_extensions(BlockDriverState *bs,
uint64_t start_offset,
return -EINVAL;
}
- if (bitmaps_ext.bitmap_directory_offset & (s->cluster_size - 1)) {
+ if (offset_into_cluster(s, bitmaps_ext.bitmap_directory_offset)) {
error_setg(errp, "bitmaps_ext: "
"invalid bitmap directory offset");
return -EINVAL;
@@ -1959,9 +1959,8 @@ static int coroutine_fn
qcow2_co_block_status(BlockDriverState *bs,
{
BDRVQcow2State *s = bs->opaque;
uint64_t cluster_offset;
- int index_in_cluster, ret;
unsigned int bytes;
- int status = 0;
+ int ret, status = 0;
qemu_co_mutex_lock(&s->lock);
@@ -1982,8 +1981,7 @@ static int coroutine_fn
qcow2_co_block_status(BlockDriverState *bs,
if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC) &&
!s->crypto) {
- index_in_cluster = offset & (s->cluster_size - 1);
- *map = cluster_offset | index_in_cluster;
+ *map = cluster_offset | offset_into_cluster(s, offset);
*file = s->data_file->bs;
status |= BDRV_BLOCK_OFFSET_VALID;
}
--
2.20.1
- [PULL 01/30] iotests: Provide a function for checking the creation of huge files, (continued)
- [PULL 01/30] iotests: Provide a function for checking the creation of huge files, Kevin Wolf, 2019/12/19
- [PULL 03/30] iotests: Skip test 079 if it is not possible to create large files, Kevin Wolf, 2019/12/19
- [PULL 04/30] qapi: better document NVMe blockdev @device parameter, Kevin Wolf, 2019/12/19
- [PULL 06/30] block: Error out on image creation with conflicting size options, Kevin Wolf, 2019/12/19
- [PULL 05/30] qemu-img: fix info --backing-chain --image-opts, Kevin Wolf, 2019/12/19
- [PULL 08/30] qcow2: Declare BDRV_REQ_NO_FALLBACK supported, Kevin Wolf, 2019/12/19
- [PULL 07/30] blockjob: Fix error message for negative speed, Kevin Wolf, 2019/12/19
- [PULL 09/30] iotests: Add qemu_io_log(), Kevin Wolf, 2019/12/19
- [PULL 10/30] iotests: Fix timeout in run_job(), Kevin Wolf, 2019/12/19
- [PULL 11/30] iotests: Support job-complete in run_job(), Kevin Wolf, 2019/12/19
- [PULL 12/30] qcow2: Use offset_into_cluster(),
Kevin Wolf <=
- [PULL 14/30] iotests: Add more "_require_drivers" checks to the shell-based tests, Kevin Wolf, 2019/12/19
- [PULL 13/30] MAINTAINERS: fix qcow2-bitmap.c under Dirty Bitmaps header, Kevin Wolf, 2019/12/19
- [PULL 17/30] qcow2: Move error check of local_err near its assignment, Kevin Wolf, 2019/12/19
- [PULL 15/30] iotests/273: Filter format-specific information, Kevin Wolf, 2019/12/19
- [PULL 16/30] iotests: Fix IMGOPTSSYNTAX for nbd, Kevin Wolf, 2019/12/19
- [PULL 18/30] iotests: Create VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 19/30] iotests: 255: Drop blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 20/30] iotests: 206: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 21/30] iotests: 210: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19
- [PULL 22/30] iotests: 212: Convert to VM.blockdev_create(), Kevin Wolf, 2019/12/19