[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 19/32] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC
From: |
Alberto Garcia |
Subject: |
[PATCH v7 19/32] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC |
Date: |
Mon, 25 May 2020 20:08:44 +0200 |
When dealing with subcluster types there is a new value called
QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC that has no equivalent in
QCow2ClusterType.
This patch handles that value in all places where subcluster types
are processed.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
block/qcow2.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 5303b0070b..8126ad8fa0 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2054,7 +2054,8 @@ static int coroutine_fn
qcow2_co_block_status(BlockDriverState *bs,
*pnum = bytes;
if ((type == QCOW2_SUBCLUSTER_NORMAL ||
- type == QCOW2_SUBCLUSTER_ZERO_ALLOC) && !s->crypto) {
+ type == QCOW2_SUBCLUSTER_ZERO_ALLOC ||
+ type == QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC) && !s->crypto) {
*map = host_offset;
*file = s->data_file->bs;
status |= BDRV_BLOCK_OFFSET_VALID;
@@ -2062,7 +2063,8 @@ static int coroutine_fn
qcow2_co_block_status(BlockDriverState *bs,
if (type == QCOW2_SUBCLUSTER_ZERO_PLAIN ||
type == QCOW2_SUBCLUSTER_ZERO_ALLOC) {
status |= BDRV_BLOCK_ZERO;
- } else if (type != QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN) {
+ } else if (type != QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN &&
+ type != QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC) {
status |= BDRV_BLOCK_DATA;
}
if (s->metadata_preallocation && (status & BDRV_BLOCK_DATA) &&
@@ -2225,6 +2227,7 @@ static coroutine_fn int
qcow2_co_preadv_task(BlockDriverState *bs,
g_assert_not_reached();
case QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN:
+ case QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC:
assert(bs->backing); /* otherwise handled in qcow2_co_preadv_part */
BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
@@ -2293,7 +2296,8 @@ static coroutine_fn int
qcow2_co_preadv_part(BlockDriverState *bs,
if (type == QCOW2_SUBCLUSTER_ZERO_PLAIN ||
type == QCOW2_SUBCLUSTER_ZERO_ALLOC ||
- (type == QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN && !bs->backing))
+ (type == QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN && !bs->backing) ||
+ (type == QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC && !bs->backing))
{
qemu_iovec_memset(qiov, qiov_offset, 0, cur_bytes);
} else {
@@ -3865,6 +3869,7 @@ static coroutine_fn int
qcow2_co_pwrite_zeroes(BlockDriverState *bs,
ret = qcow2_get_host_offset(bs, offset, &nr, &off, &type);
if (ret < 0 ||
(type != QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN &&
+ type != QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC &&
type != QCOW2_SUBCLUSTER_ZERO_PLAIN &&
type != QCOW2_SUBCLUSTER_ZERO_ALLOC)) {
qemu_co_mutex_unlock(&s->lock);
@@ -3943,6 +3948,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs,
switch (type) {
case QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN:
+ case QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC:
if (bs->backing && bs->backing->bs) {
int64_t backing_length = bdrv_getlength(bs->backing->bs);
if (src_offset >= backing_length) {
--
2.20.1
- Re: [PATCH v7 14/32] qcow2: Add QCow2SubclusterType and qcow2_get_subcluster_type(), (continued)
- [PATCH v7 08/32] qcow2: Add dummy has_subclusters() function, Alberto Garcia, 2020/05/25
- [PATCH v7 10/32] qcow2: Add offset_to_sc_index(), Alberto Garcia, 2020/05/25
- [PATCH v7 11/32] qcow2: Add offset_into_subcluster() and size_to_subclusters(), Alberto Garcia, 2020/05/25
- [PATCH v7 24/32] qcow2: Add subcluster support to check_refcounts_l2(), Alberto Garcia, 2020/05/25
- [PATCH v7 27/32] qcow2: Add subcluster support to handle_alloc_space(), Alberto Garcia, 2020/05/25
- [PATCH v7 18/32] qcow2: Replace QCOW2_CLUSTER_* with QCOW2_SUBCLUSTER_*, Alberto Garcia, 2020/05/25
- [PATCH v7 31/32] qcow2: Assert that expand_zero_clusters_in_l1() does not support subclusters, Alberto Garcia, 2020/05/25
- [PATCH v7 25/32] qcow2: Update L2 bitmap in qcow2_alloc_cluster_link_l2(), Alberto Garcia, 2020/05/25
- [PATCH v7 19/32] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC,
Alberto Garcia <=
- [PATCH v7 03/32] qcow2: Add calculate_l2_meta(), Alberto Garcia, 2020/05/25
- [PATCH v7 02/32] qcow2: Convert qcow2_get_cluster_offset() into qcow2_get_host_offset(), Alberto Garcia, 2020/05/25
- [PATCH v7 12/32] qcow2: Add l2_entry_size(), Alberto Garcia, 2020/05/25
- [PATCH v7 29/32] qcow2: Add subcluster support to qcow2_measure(), Alberto Garcia, 2020/05/25
- [PATCH v7 32/32] iotests: Add tests for qcow2 images with extended L2 entries, Alberto Garcia, 2020/05/25
- [PATCH v7 17/32] qcow2: Add cluster type parameter to qcow2_get_host_offset(), Alberto Garcia, 2020/05/25
- [PATCH v7 05/32] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in handle_copied(), Alberto Garcia, 2020/05/25