[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/34] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC
From: |
Max Reitz |
Subject: |
[PULL 19/34] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC |
Date: |
Tue, 25 Aug 2020 10:32:56 +0200 |
From: Alberto Garcia <berto@igalia.com>
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 <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id:
<bf09e2e2439a468a901bb96ace411eed9ee50295.1594396418.git.berto@igalia.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block/qcow2.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 477d60dd71..60192f1be3 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2064,7 +2064,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;
@@ -2072,7 +2073,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) &&
@@ -2235,6 +2237,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);
@@ -2303,7 +2306,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 {
@@ -3858,6 +3862,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);
@@ -3936,6 +3941,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.26.2
- [PULL 09/34] qcow2: Add subcluster-related fields to BDRVQcow2State, (continued)
- [PULL 09/34] qcow2: Add subcluster-related fields to BDRVQcow2State, Max Reitz, 2020/08/25
- [PULL 10/34] qcow2: Add offset_to_sc_index(), Max Reitz, 2020/08/25
- [PULL 11/34] qcow2: Add offset_into_subcluster() and size_to_subclusters(), Max Reitz, 2020/08/25
- [PULL 12/34] qcow2: Add l2_entry_size(), Max Reitz, 2020/08/25
- [PULL 13/34] qcow2: Update get/set_l2_entry() and add get/set_l2_bitmap(), Max Reitz, 2020/08/25
- [PULL 08/34] qcow2: Add dummy has_subclusters() function, Max Reitz, 2020/08/25
- [PULL 15/34] qcow2: Add qcow2_get_subcluster_range_type(), Max Reitz, 2020/08/25
- [PULL 14/34] qcow2: Add QCow2SubclusterType and qcow2_get_subcluster_type(), Max Reitz, 2020/08/25
- [PULL 16/34] qcow2: Add qcow2_cluster_is_allocated(), Max Reitz, 2020/08/25
- [PULL 18/34] qcow2: Replace QCOW2_CLUSTER_* with QCOW2_SUBCLUSTER_*, Max Reitz, 2020/08/25
- [PULL 19/34] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC,
Max Reitz <=
- [PULL 22/34] qcow2: Add subcluster support to zero_in_l2_slice(), Max Reitz, 2020/08/25
- [PULL 21/34] qcow2: Add subcluster support to qcow2_get_host_offset(), Max Reitz, 2020/08/25
- [PULL 23/34] qcow2: Add subcluster support to discard_in_l2_slice(), Max Reitz, 2020/08/25
- [PULL 20/34] qcow2: Add subcluster support to calculate_l2_meta(), Max Reitz, 2020/08/25
- [PULL 27/34] qcow2: Add subcluster support to handle_alloc_space(), Max Reitz, 2020/08/25
- [PULL 25/34] qcow2: Update L2 bitmap in qcow2_alloc_cluster_link_l2(), Max Reitz, 2020/08/25
- [PULL 24/34] qcow2: Add subcluster support to check_refcounts_l2(), Max Reitz, 2020/08/25
- [PULL 28/34] qcow2: Add subcluster support to qcow2_co_pwrite_zeroes(), Max Reitz, 2020/08/25
- [PULL 29/34] qcow2: Add subcluster support to qcow2_measure(), Max Reitz, 2020/08/25
- [PULL 30/34] qcow2: Add prealloc field to QCowL2Meta, Max Reitz, 2020/08/25