[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V4 05/30] qcow2: Create a way to link to l2 tables whe
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V4 05/30] qcow2: Create a way to link to l2 tables when deduplicating. |
Date: |
Wed, 2 Jan 2013 17:16:08 +0100 |
Signed-off-by: Benoit Canet <address@hidden>
---
block/qcow2-cluster.c | 8 ++++++--
block/qcow2.h | 9 +++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 56fccf9..63a7241 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -693,7 +693,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));
}
@@ -706,7 +707,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);
}
@@ -1006,6 +1007,9 @@ again:
.offset = nb_sectors * BDRV_SECTOR_SIZE,
.nb_sectors = avail_sectors - nb_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.h b/block/qcow2.h
index 3307481..9403431 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -59,6 +59,10 @@
#define DEFAULT_CLUSTER_SIZE 65536
#define HASH_LENGTH 32
+/* indicate that the hash structure is empty and miss offset */
+#define QCOW_FLAG_EMPTY (1LL << 62)
+/* indicate that the cluster for this hash has QCOW_OFLAG_COPIED on disk */
+#define QCOW_FLAG_FIRST (1LL << 63)
typedef enum {
QCOW_HASH_SHA256 = 0,
@@ -289,6 +293,11 @@ typedef struct QCowL2Meta
*/
CoQueue dependent_requests;
+ /* set to true if QCOW_OFLAG_COPIED must be set in the L2 table entry */
+ bool oflag_copied;
+ /* set to true if we are overwriting an L2 table entry */
+ bool overwrite;
+
/**
* The COW Region between the start of the first allocated cluster and the
* area the guest actually writes to.
--
1.7.10.4
- [Qemu-devel] [RFC V4 00/30] QCOW2 deduplication, Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 02/30] qcow2: Add deduplication structures and fields., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 04/30] qcow2: Make update_refcount public., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 05/30] qcow2: Create a way to link to l2 tables when deduplicating.,
Benoît Canet <=
- [Qemu-devel] [RFC V4 03/30] qcow2: Add qcow2_de dup_read_missing_and_concatenate, Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 07/30] qcow2: Add qcow2_dedup_store_new_hashes., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 08/30] qcow2: Implement qcow2_compute_cluster_hash., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 09/30] qcow2: Extract qcow2_dedup_grow_table, Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 10/30] qcow2: Add qcow2_dedup_grow_table and use it., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 14/30] qcow2-cache: Allow to choose table size at creation., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 15/30] qcow2: Add qcow2_dedup_init and qcow2_dedup_close., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 17/30] block: Add qemu-img dedup create option., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 21/30] qcow2: Add verification of dedup table., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 23/30] qcow2: Add check_dedup_l2 in order to check l2 of dedup table., Benoît Canet, 2013/01/02