[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V4 20/30] qcow2: Serialize write requests when dedupli
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V4 20/30] qcow2: Serialize write requests when deduplication is activated. |
Date: |
Wed, 2 Jan 2013 17:16:23 +0100 |
This fix the sub cluster sized writes race conditions while waiting
for a more faster solution.
Signed-off-by: Benoit Canet <address@hidden>
---
block/qcow2.c | 9 +++++++++
block/qcow2.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index 54c8847..13f6a5c 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -521,6 +521,7 @@ static int qcow2_open(BlockDriverState *bs, int flags)
/* Initialise locks */
qemu_co_mutex_init(&s->lock);
+ qemu_co_mutex_init(&s->dedup_lock);
/* Repair image if dirty */
if (!(flags & BDRV_O_CHECK) && !bs->read_only &&
@@ -810,6 +811,10 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState
*bs,
s->cluster_cache_offset = -1; /* disable compressed cache */
+ if (s->has_dedup) {
+ qemu_co_mutex_lock(&s->dedup_lock);
+ }
+
qemu_co_mutex_lock(&s->lock);
if (s->has_dedup) {
@@ -978,6 +983,10 @@ fail:
g_free(l2meta);
}
+ if (s->has_dedup) {
+ qemu_co_mutex_unlock(&s->dedup_lock);
+ }
+
qemu_iovec_destroy(&hd_qiov);
qemu_vfree(cluster_data);
qemu_vfree(dedup_cluster_data);
diff --git a/block/qcow2.h b/block/qcow2.h
index f5576be..fd31f4f 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -224,6 +224,7 @@ typedef struct BDRVQcowState {
GTree *dedup_tree_by_hash;
GTree *dedup_tree_by_sect;
CoMutex lock;
+ CoMutex dedup_lock;
uint32_t crypt_method; /* current crypt method, 0 if no key yet */
uint32_t crypt_method_header;
--
1.7.10.4
- [Qemu-devel] [RFC V4 17/30] block: Add qemu-img dedup create option., (continued)
- [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
- [Qemu-devel] [RFC V4 19/30] qcow2: Integrate deduplication in qcow2_co_writev loop., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 25/30] qcow2: Integrate SKEIN hash algorithm in deduplication., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 24/30] qcow2: Do not overwrite existing entries with QCOW_OFLAG_COPIED., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 30/30] qemu-iotests: Filter dedup=on/off so existing tests don't break., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 29/30] qcow2: init and cleanup deduplication., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 20/30] qcow2: Serialize write requests when deduplication is activated.,
Benoît Canet <=
- [Qemu-devel] [RFC V4 22/30] qcow2: Adapt checking of QCOW_OFLAG_COPIED for dedup., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 28/30] qcow: Set dedup cluster block size to 64KB., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 27/30] qcow2: Use large L2 table for deduplication., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 12/30] qcow2: Load and save deduplication table header extension., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 16/30] qcow2: Extract qcow2_add_feature and qcow2_remove_feature., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 06/30] qcow2: Add qcow2_dedup and related functions, Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 26/30] qcow2: Add lazy refcounts to deduplication to prevent qcow2_cache_set_dependency loops, Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 18/30] qcow2: Behave correctly when refcount reach 0 or 2^16., Benoît Canet, 2013/01/02
- [Qemu-devel] [RFC V4 11/30] qcow2: create function to load deduplication hashes at startup., Benoît Canet, 2013/01/02