From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upfqb-0002wP-Hl for qemu-devel@nongnu.org; Thu, 20 Jun 2013 10:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UpfqU-0001Fj-5h for qemu-devel@nongnu.org; Thu, 20 Jun 2013 10:28:25 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:37597 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpfqT-0001FY-9B for qemu-devel@nongnu.org; Thu, 20 Jun 2013 10:28:17 -0400 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Thu, 20 Jun 2013 16:26:20 +0200 Message-Id: <1371738392-9594-13-git-send-email-benoit@irqsave.net> In-Reply-To: <1371738392-9594-1-git-send-email-benoit@irqsave.net> References: <1371738392-9594-1-git-send-email-benoit@irqsave.net> Subject: [Qemu-devel] [RFC V8 12/24] qcow2: Do allocate on rewrite on the dedup case. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com 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 --- 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