@@ -878,7 +878,8 @@ static int handle_copied(BlockDriverState *bs, uint64_t guest_offset,
cluster_offset = be64_to_cpu(l2_table[l2_index]);
/* Check how many clusters are already allocated and don't need COW */
- if (qcow2_get_cluster_type(cluster_offset) == QCOW2_CLUSTER_NORMAL
+ if (!s->has_dedup &&
+ qcow2_get_cluster_type(cluster_offset) == QCOW2_CLUSTER_NORMAL
&& (cluster_offset & QCOW_OFLAG_COPIED))
{
/* If a specific host_offset is required, check it */
@@ -1028,7 +1029,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
/* For the moment, overwrite compressed clusters one by one */
if (entry & QCOW_OFLAG_COMPRESSED) {
nb_clusters = 1;
- } else {
+ } else if (!s->has_dedup) {
nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index);
}
This patch does allocate on rewrite when deduplication is on. This get rid of the need of removing the old hash of the lookup structure when a cluster get rewritten. The old data is left in place and will be collected/deleted when it's cluster will reach 0. Signed-off-by: Benoit Canet <benoit@irqsave.net> --- block/qcow2-cluster.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)