[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v2 12/26] qcow2: Handle QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER
From: |
Alberto Garcia |
Subject: |
[RFC PATCH v2 12/26] qcow2: Handle QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER |
Date: |
Sun, 27 Oct 2019 00:25:14 +0300 |
In the previous patch we added a new QCow2ClusterType named
QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER. There is a couple of places
where this new value needs to be handled, and that is what this patch
does.
Signed-off-by: Alberto Garcia <address@hidden>
---
block/qcow2.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index ab40ae36ea..0261e87709 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1938,8 +1938,8 @@ static int coroutine_fn
qcow2_co_block_status(BlockDriverState *bs,
*pnum = bytes;
- if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC) &&
- !s->crypto) {
+ if ((ret == QCOW2_CLUSTER_NORMAL || ret == QCOW2_CLUSTER_ZERO_ALLOC ||
+ ret == QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER) && !s->crypto) {
index_in_cluster = offset & (s->cluster_size - 1);
*map = cluster_offset | index_in_cluster;
*file = s->data_file->bs;
@@ -1947,7 +1947,8 @@ static int coroutine_fn
qcow2_co_block_status(BlockDriverState *bs,
}
if (ret == QCOW2_CLUSTER_ZERO_PLAIN || ret == QCOW2_CLUSTER_ZERO_ALLOC) {
status |= BDRV_BLOCK_ZERO;
- } else if (ret != QCOW2_CLUSTER_UNALLOCATED) {
+ } else if (ret != QCOW2_CLUSTER_UNALLOCATED &&
+ ret != QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER) {
status |= BDRV_BLOCK_DATA;
}
if (s->metadata_preallocation && (status & BDRV_BLOCK_DATA) &&
@@ -2117,6 +2118,7 @@ static coroutine_fn int
qcow2_co_preadv_task(BlockDriverState *bs,
g_assert_not_reached();
case QCOW2_CLUSTER_UNALLOCATED:
+ case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER:
assert(bs->backing); /* otherwise handled in qcow2_co_preadv_part */
BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
@@ -2187,7 +2189,8 @@ static coroutine_fn int
qcow2_co_preadv_part(BlockDriverState *bs,
if (ret == QCOW2_CLUSTER_ZERO_PLAIN ||
ret == QCOW2_CLUSTER_ZERO_ALLOC ||
- (ret == QCOW2_CLUSTER_UNALLOCATED && !bs->backing))
+ (ret == QCOW2_CLUSTER_UNALLOCATED && !bs->backing) ||
+ (ret == QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER && !bs->backing))
{
qemu_iovec_memset(qiov, qiov_offset, 0, cur_bytes);
} else {
@@ -3701,6 +3704,7 @@ static coroutine_fn int
qcow2_co_pwrite_zeroes(BlockDriverState *bs,
nr = s->cluster_size;
ret = qcow2_get_cluster_offset(bs, offset, &nr, &off);
if (ret != QCOW2_CLUSTER_UNALLOCATED &&
+ ret != QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER &&
ret != QCOW2_CLUSTER_ZERO_PLAIN &&
ret != QCOW2_CLUSTER_ZERO_ALLOC) {
qemu_co_mutex_unlock(&s->lock);
@@ -3771,6 +3775,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs,
switch (ret) {
case QCOW2_CLUSTER_UNALLOCATED:
+ case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER:
if (bs->backing && bs->backing->bs) {
int64_t backing_length = bdrv_getlength(bs->backing->bs);
if (src_offset >= backing_length) {
--
2.20.1
- [RFC PATCH v2 01/26] qcow2: Add calculate_l2_meta(), (continued)
- [RFC PATCH v2 01/26] qcow2: Add calculate_l2_meta(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 15/26] qcow2: Add subcluster support to zero_in_l2_slice(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 07/26] qcow2: Add subcluster-related fields to BDRVQcow2State, Alberto Garcia, 2019/10/26
- [RFC PATCH v2 09/26] qcow2: Add l2_entry_size(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 17/26] qcow2: Add subcluster support to check_refcounts_l2(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 02/26] qcow2: Split cluster_needs_cow() out of count_cow_clusters(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 20/26] qcow2: Update L2 bitmap in qcow2_alloc_cluster_link_l2(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 12/26] qcow2: Handle QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER,
Alberto Garcia <=
- [RFC PATCH v2 23/26] qcow2: Restrict qcow2_co_pwrite_zeroes() to full clusters only, Alberto Garcia, 2019/10/26
- [RFC PATCH v2 11/26] qcow2: Add qcow2_get_subcluster_type(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 19/26] qcow2: Fix offset calculation in handle_dependencies(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 03/26] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in handle_copied(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 04/26] qcow2: Add get_l2_entry() and set_l2_entry(), Alberto Garcia, 2019/10/26
- [RFC PATCH v2 24/26] qcow2: Add the 'extended_l2' option and the QCOW2_INCOMPAT_EXTL2 bit, Alberto Garcia, 2019/10/26
- [RFC PATCH v2 26/26] iotests: Add tests for qcow2 images with extended L2 entries, Alberto Garcia, 2019/10/26
- [RFC PATCH v2 18/26] qcow2: Add subcluster support to expand_zero_clusters_in_l1(), Alberto Garcia, 2019/10/26