[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 12/23] qcow2: Handle QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER
From: |
Alberto Garcia |
Subject: |
[RFC PATCH 12/23] qcow2: Handle QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER |
Date: |
Tue, 15 Oct 2019 18:23:23 +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 | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 131711d6fa..c222cd261d 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1922,8 +1922,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;
@@ -1931,7 +1931,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) &&
@@ -2009,6 +2010,7 @@ static coroutine_fn int
qcow2_co_preadv_part(BlockDriverState *bs,
switch (ret) {
case QCOW2_CLUSTER_UNALLOCATED:
+ case QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER:
if (bs->backing) {
BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO);
@@ -3542,6 +3544,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);
@@ -3612,6 +3615,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 00/23] Add subcluster allocation to qcow2, Alberto Garcia, 2019/10/15
- [RFC PATCH 10/23] qcow2: Update get/set_l2_entry() and add get/set_l2_bitmap(), Alberto Garcia, 2019/10/15
- [RFC PATCH 01/23] qcow2: Add calculate_l2_meta(), Alberto Garcia, 2019/10/15
- [RFC PATCH 16/23] qcow2: Add subcluster support to discard_in_l2_slice(), Alberto Garcia, 2019/10/15
- [RFC PATCH 06/23] qcow2: Add dummy has_subclusters() function, Alberto Garcia, 2019/10/15
- [RFC PATCH 12/23] qcow2: Handle QCOW2_CLUSTER_UNALLOCATED_SUBCLUSTER,
Alberto Garcia <=
- [RFC PATCH 09/23] qcow2: Add l2_entry_size(), Alberto Garcia, 2019/10/15
- [RFC PATCH 03/23] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in handle_copied(), Alberto Garcia, 2019/10/15
- [RFC PATCH 05/23] qcow2: Document the Extended L2 Entries feature, Alberto Garcia, 2019/10/15
- [RFC PATCH 04/23] qcow2: Add get_l2_entry() and set_l2_entry(), Alberto Garcia, 2019/10/15
- [RFC PATCH 23/23] qcow2: Add the 'extended_l2' option and the QCOW2_INCOMPAT_EXTL2 bit, Alberto Garcia, 2019/10/15
- [RFC PATCH 11/23] qcow2: Add qcow2_get_subcluster_type(), Alberto Garcia, 2019/10/15
- [RFC PATCH 08/23] qcow2: Add offset_to_sc_index(), Alberto Garcia, 2019/10/15
- [RFC PATCH 19/23] qcow2: Fix offset calculation in handle_dependencies(), Alberto Garcia, 2019/10/15
- [RFC PATCH 02/23] qcow2: Split cluster_needs_cow() out of count_cow_clusters(), Alberto Garcia, 2019/10/15