qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC V8 12/24] qcow2: Do allocate on rewrite on the dedup c


From: Benoît Canet
Subject: [Qemu-devel] [RFC V8 12/24] qcow2: Do allocate on rewrite on the dedup case.
Date: Thu, 20 Jun 2013 16:26:20 +0200

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 <address@hidden>
---
 block/qcow2-cluster.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index d6db0b9..41c4bc2 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -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);
     }
 
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]