[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V5 12/62] qcow2: make the deduplication forget a clust
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V5 12/62] qcow2: make the deduplication forget a cluster hash when a cluster is to dedupe |
Date: |
Wed, 16 Jan 2013 16:47:51 +0100 |
Signed-off-by: Benoit Canet <address@hidden>
---
block/qcow2-cluster.c | 11 +++++++++--
block/qcow2-dedup.c | 8 +++++++-
block/qcow2.h | 2 ++
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index ef91216..5b1d20d 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -710,6 +710,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,
QCowL2Meta *m)
for (i = 0; i < m->nb_clusters; i++) {
uint64_t flags = 0;
+ uint64_t offset = cluster_offset + (i << s->cluster_bits);
/* if two concurrent writes happen to the same unallocated cluster
* each write allocates separate cluster and writes data concurrently.
* The first one to complete updates l2 table with pointer to its
@@ -722,8 +723,14 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,
QCowL2Meta *m)
flags = m->oflag_copied ? QCOW_OFLAG_COPIED : 0;
flags |= m->to_deduplicate ? QCOW_OFLAG_TO_DEDUP : 0;
- l2_table[l2_index + i] = cpu_to_be64((cluster_offset +
- (i << s->cluster_bits)) | flags);
+ l2_table[l2_index + i] = cpu_to_be64(offset | flags);
+
+ /* make the deduplication forget the cluster to avoid making
+ * the dedup pointing to a cluster that has changed on it's back.
+ */
+ if (m->to_deduplicate) {
+ qcow2_dedup_forget_cluster_by_sector(bs, offset >> 9);
+ }
}
diff --git a/block/qcow2-dedup.c b/block/qcow2-dedup.c
index 3d512e5..7049bd8 100644
--- a/block/qcow2-dedup.c
+++ b/block/qcow2-dedup.c
@@ -824,7 +824,7 @@ static void qcow2_remove_hash_node(BlockDriverState *bs,
* @physical_sect: The physical sector of the cluster corresponding to the hash
*/
static void qcow2_remove_hash_node_by_sector(BlockDriverState *bs,
- uint64_t physical_sect)
+ uint64_t physical_sect)
{
BDRVQcowState *s = bs->opaque;
QCowHashNode *hash_node;
@@ -838,6 +838,12 @@ static void
qcow2_remove_hash_node_by_sector(BlockDriverState *bs,
qcow2_remove_hash_node(bs, hash_node);
}
+void qcow2_dedup_forget_cluster_by_sector(BlockDriverState *bs,
+ uint64_t physical_sect)
+{
+ qcow2_remove_hash_node_by_sector(bs, physical_sect);
+}
+
/* This function store a hash information to disk and RAM
*
* @hash: the QCowHash to process
diff --git a/block/qcow2.h b/block/qcow2.h
index da7e57e..bc1ba33 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -469,6 +469,8 @@ int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c,
void **table);
/* qcow2-dedup.c functions */
bool qcow2_must_deduplicate(BlockDriverState *bs);
+void qcow2_dedup_forget_cluster_by_sector(BlockDriverState *bs,
+ uint64_t physical_sect);
int qcow2_dedup_read_missing_and_concatenate(BlockDriverState *bs,
QEMUIOVector *qiov,
uint64_t sector,
--
1.7.10.4
- Re: [Qemu-devel] [RFC V5 01/62] qcow2: Add deduplication to the qcow2 specification., (continued)
- [Qemu-devel] [RFC V5 04/62] qcow2: Make update_refcount public., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 03/62] qcow2: Add qcow2_de dup_read_missing_and_concatenate, Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 05/62] qcow2: Create a way to link to l2 tables when deduplicating., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 08/62] qcow2: Implement qcow2_compute_cluster_hash., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 07/62] qcow2: Add qcow2_dedup_store_new_hashes., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 06/62] qcow2: Add qcow2_dedup and related functions, Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 10/62] qcow2: Add qcow2_dedup_grow_table and use it., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 09/62] qcow2: Extract qcow2_dedup_grow_table, Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 11/62] qcow2: Makes qcow2_alloc_cluster_link_l2 mark to deduplicate clusters., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 12/62] qcow2: make the deduplication forget a cluster hash when a cluster is to dedupe,
Benoît Canet <=
- [Qemu-devel] [RFC V5 17/62] qcow2: Extract qcow2_add_feature and qcow2_remove_feature., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 18/62] block: Add qemu-img dedup create option., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 22/62] qcow2: Add qcow2_dedup_is_running to probe if dedup is running., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 20/62] qcow2: Drop hash for a given cluster when dedup makes refcount > 2^16/2., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 19/62] qcow2: Add a deduplication boolean to update_refcount., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 27/62] qcow2: Add check_dedup_l2 in order to check l2 of dedup table., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 30/62] qcow2: Add lazy refcounts to deduplication to prevent qcow2_cache_set_dependency loops, Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 29/62] qcow2: Integrate SKEIN hash algorithm in deduplication., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 33/62] qemu-iotests: Filter dedup=on/off so existing tests don't break., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 31/62] qcow2: Use large L2 table for deduplication., Benoît Canet, 2013/01/16