[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V3 05/24] qcow2: Create a way to link to l2 tables in
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V3 05/24] qcow2: Create a way to link to l2 tables in dedup. |
Date: |
Mon, 26 Nov 2012 14:05:04 +0100 |
Signed-off-by: Benoit Canet <address@hidden>
---
block/qcow2-cluster.c | 9 +++++++--
block/qcow2.c | 2 ++
block/qcow2.h | 2 ++
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index e179211..9a07191 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -683,7 +683,8 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,
QCowL2Meta *m)
old_cluster[j++] = l2_table[l2_index + i];
l2_table[l2_index + i] = cpu_to_be64((cluster_offset +
- (i << s->cluster_bits)) | QCOW_OFLAG_COPIED);
+ (i << s->cluster_bits)) |
+ (m->oflag_copied ? QCOW_OFLAG_COPIED : 0));
}
@@ -696,7 +697,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,
QCowL2Meta *m)
* If this was a COW, we need to decrease the refcount of the old cluster.
* Also flush bs->file to get the right order for L2 and refcount update.
*/
- if (j != 0) {
+ if (!m->overwrite && j != 0) {
for (i = 0; i < j; i++) {
qcow2_free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1);
}
@@ -922,6 +923,8 @@ again:
*m = (QCowL2Meta) {
.cluster_offset = cluster_offset,
.nb_clusters = 0,
+ .oflag_copied = true,
+ .overwrite = false,
};
qemu_co_queue_init(&m->dependent_requests);
@@ -970,6 +973,8 @@ again:
.n_start = keep_clusters == 0 ? n_start : 0,
.nb_clusters = nb_clusters,
.nb_available = MIN(requested_sectors, avail_sectors),
+ .oflag_copied = true,
+ .overwrite = false,
};
qemu_co_queue_init(&m->dependent_requests);
QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight);
diff --git a/block/qcow2.c b/block/qcow2.c
index c1ff31f..b5276c0 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -776,6 +776,8 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState
*bs,
uint8_t *cluster_data = NULL;
QCowL2Meta l2meta = {
.nb_clusters = 0,
+ .oflag_copied = true,
+ .overwrite = false,
};
trace_qcow2_writev_start_req(qemu_coroutine_self(), sector_num,
diff --git a/block/qcow2.h b/block/qcow2.h
index ee9aecc..ccb24ad 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -231,6 +231,8 @@ typedef struct QCowL2Meta
int n_start;
int nb_available;
int nb_clusters;
+ bool oflag_copied;
+ bool overwrite;
CoQueue dependent_requests;
QLIST_ENTRY(QCowL2Meta) next_in_flight;
--
1.7.10.4
- [Qemu-devel] [RFC V3 00/24] QCOW2 deduplication, Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 02/24] qcow2: Add deduplication structures and fields., Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 01/24] qcow2: Add deduplication to the qcow2 specification., Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 04/24] qcow2: Make update_cluster_refcount public., Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 05/24] qcow2: Create a way to link to l2 tables in dedup.,
Benoît Canet <=
- [Qemu-devel] [RFC V3 03/24] qcow2: Add qcow2_de dup_read_missing_and_concatenate, Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 06/24] qcow2: Add qcow2_dedup and related functions., Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 09/24] qcow2: Extract qcow2_dedup_grow_table, Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 13/24] qcow2: Add qcow2_dedup_init and qcow2_dedup_close., Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 12/24] qcow2: Extract qcow2_do_table_init., Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 11/24] qcow2: Load and save deduplication table header extension., Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 14/24] qcow2: Extract qcow2_add_feature and qcow2_remove_feature., Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 16/24] qcow2: Allow creation of images using deduplication., Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 17/24] qcow2: Behave correctly when refcount reach 0 or 2^16., Benoît Canet, 2012/11/26
- [Qemu-devel] [RFC V3 19/24] qcow2: Add verification of dedup table., Benoît Canet, 2012/11/26