[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V8 08/24] qcow2: Create a way to link to l2 tables whe
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V8 08/24] qcow2: Create a way to link to l2 tables when deduplicating. |
Date: |
Thu, 20 Jun 2013 16:26:16 +0200 |
Signed-off-by: Benoit Canet <address@hidden>
---
block/qcow2-cluster.c | 6 ++++--
block/qcow2.h | 6 ++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index c71470a..d6db0b9 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -696,7 +696,7 @@ 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->l2_entry_flags);
}
@@ -709,7 +709,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);
}
@@ -1098,6 +1098,8 @@ static int handle_alloc(BlockDriverState *bs, uint64_t
guest_offset,
.offset = nb_sectors * BDRV_SECTOR_SIZE,
.nb_sectors = avail_sectors - nb_sectors,
},
+ .l2_entry_flags = QCOW_OFLAG_COPIED,
+ .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 9a9abd3..7754065 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -438,6 +438,12 @@ typedef struct QCowL2Meta
*/
CoQueue dependent_requests;
+ /* contains the flags to apply to the l2 entry */
+ uint64_t l2_entry_flags;
+
+ /* 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 V8 00/24] QCOW2 deduplication core functionality, Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 01/24] qcow2: Add journal specification., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 02/24] qcow2: Add deduplication structures and fields., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 03/24] qcow2: Add journal., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 04/24] qcow2: Create the log store., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 07/24] qcow2: Add qcow2_de dup_read_missing_and_concatenate, Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 08/24] qcow2: Create a way to link to l2 tables when deduplicating.,
Benoît Canet <=
- [Qemu-devel] [RFC V8 06/24] qcow2: Add the dedupl ication store., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 05/24] qcow2: Add the hash s tore., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 09/24] qcow2: Make qcow2_update_cluster_refcount public., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 12/24] qcow2: Do allocate on rewrite on the dedup case., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 10/24] qcow2: Add qcow2_dedup and related functions, Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 11/24] qcow2: Add qcow2_dedup_store_new_hashes., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 14/24] qcow2: Load and save deduplication table header extension., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 13/24] qcow2: Implement qcow2_compute_cluster_hash., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 17/24] qcow2: Drop hash for a given cluster when dedup makes refcount > 2^16/2., Benoît Canet, 2013/06/20
- [Qemu-devel] [RFC V8 15/24] qcow2: Extract qcow2_set_incompat_feature and qcow2_clear_incompat_feature., Benoît Canet, 2013/06/20