[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V5 19/62] qcow2: Add a deduplication boolean to update
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V5 19/62] qcow2: Add a deduplication boolean to update_refcount. |
Date: |
Wed, 16 Jan 2013 16:47:58 +0100 |
This is needed for next commit which handle the deduplication refcount overflow
case.
Signed-off-by: Benoit Canet <address@hidden>
---
block/qcow2-dedup.c | 2 +-
block/qcow2-refcount.c | 20 +++++++++++---------
block/qcow2.h | 2 +-
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/block/qcow2-dedup.c b/block/qcow2-dedup.c
index 7049bd8..25ecefa 100644
--- a/block/qcow2-dedup.c
+++ b/block/qcow2-dedup.c
@@ -386,7 +386,7 @@ static int qcow2_deduplicate_cluster(BlockDriverState *bs,
return update_refcount(bs,
(hash_node->physical_sect /
s->cluster_sectors) << s->cluster_bits,
- 1, 1);
+ 1, 1, true);
}
/* This function tries to deduplicate a given cluster.
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 75c2bde..b1ad112 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -245,7 +245,7 @@ static int alloc_refcount_block(BlockDriverState *bs,
} else {
/* Described somewhere else. This can recurse at most twice before we
* arrive at a block that describes itself. */
- ret = update_refcount(bs, new_block, s->cluster_size, 1);
+ ret = update_refcount(bs, new_block, s->cluster_size, 1, false);
if (ret < 0) {
goto fail_block;
}
@@ -427,7 +427,7 @@ fail_block:
/* XXX: cache several refcount block clusters ? */
int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
- int64_t offset, int64_t length, int addend)
+ int64_t offset, int64_t length, int addend, bool deduplication)
{
BDRVQcowState *s = bs->opaque;
int64_t start, last, cluster_offset;
@@ -513,7 +513,8 @@ fail:
*/
if (ret < 0) {
int dummy;
- dummy = update_refcount(bs, offset, cluster_offset - offset, -addend);
+ dummy = update_refcount(bs, offset, cluster_offset - offset, -addend,
+ deduplication);
(void)dummy;
}
@@ -534,7 +535,8 @@ static int update_cluster_refcount(BlockDriverState *bs,
BDRVQcowState *s = bs->opaque;
int ret;
- ret = update_refcount(bs, cluster_index << s->cluster_bits, 1, addend);
+ ret = update_refcount(bs, cluster_index << s->cluster_bits, 1, addend,
+ false);
if (ret < 0) {
return ret;
}
@@ -588,7 +590,7 @@ int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t
size)
return offset;
}
- ret = update_refcount(bs, offset, size, 1);
+ ret = update_refcount(bs, offset, size, 1, false);
if (ret < 0) {
return ret;
}
@@ -620,7 +622,7 @@ int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t
offset,
old_free_cluster_index = s->free_cluster_index;
s->free_cluster_index = cluster_index + i;
- ret = update_refcount(bs, offset, i << s->cluster_bits, 1);
+ ret = update_refcount(bs, offset, i << s->cluster_bits, 1, false);
if (ret < 0) {
return ret;
}
@@ -686,7 +688,7 @@ void qcow2_free_clusters(BlockDriverState *bs,
int ret;
BLKDBG_EVENT(bs->file, BLKDBG_CLUSTER_FREE);
- ret = update_refcount(bs, offset, size, -1);
+ ret = update_refcount(bs, offset, size, -1, false);
if (ret < 0) {
fprintf(stderr, "qcow2_free_clusters failed: %s\n", strerror(-ret));
/* TODO Remember the clusters to free them later and avoid leaking */
@@ -795,7 +797,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
int ret;
ret = update_refcount(bs,
(offset & s->cluster_offset_mask) & ~511,
- nb_csectors * 512, addend);
+ nb_csectors * 512, addend, false);
if (ret < 0) {
goto fail;
}
@@ -1228,7 +1230,7 @@ int qcow2_check_refcounts(BlockDriverState *bs,
BdrvCheckResult *res,
if (num_fixed) {
ret = update_refcount(bs, i << s->cluster_bits, 1,
- refcount2 - refcount1);
+ refcount2 - refcount1, false);
if (ret >= 0) {
(*num_fixed)++;
continue;
diff --git a/block/qcow2.h b/block/qcow2.h
index f987328..5c126be 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -418,7 +418,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
BdrvCheckMode fix);
int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
- int64_t offset, int64_t length, int addend);
+ int64_t offset, int64_t length, int addend, bool deduplication);
/* qcow2-cluster.c functions */
typedef int (*qcow2_save_table)(BlockDriverState *bs,
--
1.7.10.4
- [Qemu-devel] [RFC V5 07/62] qcow2: Add qcow2_dedup_store_new_hashes., (continued)
- [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, 2013/01/16
- [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 <=
- [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
- [Qemu-devel] [RFC V5 32/62] qcow: Set large dedup hash block size., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 34/62] qcow2: Add qcow2_dedup_init and qcow2_dedup_close., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 36/62] qcow2: Enable the deduplication feature., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 38/62] qcow2: Initialize deduplication metrics., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 35/62] qcow2: Add qcow2_co_dedup_resume to restart deduplication., Benoît Canet, 2013/01/16