[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 18/31] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC
From: |
Alberto Garcia |
Subject: |
[PATCH v5 18/31] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC |
Date: |
Tue, 5 May 2020 19:38:18 +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 13965f2e1d..63e952b89a 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1994,7 +1994,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;
@@ -2002,7 +2003,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) &&
@@ -2165,6 +2167,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);
@@ -2233,7 +2236,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 {
@@ -3761,6 +3765,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);
@@ -3839,6 +3844,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
- [PATCH v5 00/31] Add subcluster allocation to qcow2, Alberto Garcia, 2020/05/05
- [PATCH v5 10/31] qcow2: Add offset_to_sc_index(), Alberto Garcia, 2020/05/05
- [PATCH v5 08/31] qcow2: Add dummy has_subclusters() function, Alberto Garcia, 2020/05/05
- [PATCH v5 11/31] qcow2: Add offset_into_subcluster() and size_to_subclusters(), Alberto Garcia, 2020/05/05
- [PATCH v5 03/31] qcow2: Add calculate_l2_meta(), Alberto Garcia, 2020/05/05
- [PATCH v5 22/31] qcow2: Add subcluster support to discard_in_l2_slice(), Alberto Garcia, 2020/05/05
- [PATCH v5 18/31] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC,
Alberto Garcia <=
- [PATCH v5 01/31] qcow2: Make Qcow2AioTask store the full host offset, Alberto Garcia, 2020/05/05
- [PATCH v5 02/31] qcow2: Convert qcow2_get_cluster_offset() into qcow2_get_host_offset(), Alberto Garcia, 2020/05/05
- [PATCH v5 09/31] qcow2: Add subcluster-related fields to BDRVQcow2State, Alberto Garcia, 2020/05/05
- [PATCH v5 12/31] qcow2: Add l2_entry_size(), Alberto Garcia, 2020/05/05
- [PATCH v5 24/31] qcow2: Update L2 bitmap in qcow2_alloc_cluster_link_l2(), Alberto Garcia, 2020/05/05
- [PATCH v5 06/31] qcow2: Add get_l2_entry() and set_l2_entry(), Alberto Garcia, 2020/05/05
- [PATCH v5 21/31] qcow2: Add subcluster support to zero_in_l2_slice(), Alberto Garcia, 2020/05/05
- [PATCH v5 27/31] qcow2: Add subcluster support to qcow2_co_pwrite_zeroes(), Alberto Garcia, 2020/05/05
- [PATCH v5 30/31] qcow2: Add subcluster support to qcow2_measure(), Alberto Garcia, 2020/05/05