[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC V5 28/62] qcow2: Do not overwrite existing entries wit
From: |
Benoît Canet |
Subject: |
[Qemu-devel] [RFC V5 28/62] qcow2: Do not overwrite existing entries with QCOW_OFLAG_COPIED. |
Date: |
Wed, 16 Jan 2013 16:48:07 +0100 |
In the case of a race condition between two writes a l2 entry can be written
without QCOW_OFLAG_COPIED before the first write fill it.
This patch simply check if the l2 entry has the correct offset without
QCOW_OFLAG_COPIED and do nothing.
Signed-off-by: Benoit Canet <address@hidden>
---
block/qcow2-cluster.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index fedcf57..c016e85 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -763,6 +763,11 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,
QCowL2Meta *m)
for (i = 0; i < m->nb_clusters; i++) {
uint64_t flags = 0;
uint64_t offset = cluster_offset + (i << s->cluster_bits);
+
+ if (be64_to_cpu(l2_table[l2_index + i]) == offset) {
+ continue;
+ }
+
/* if two concurrent writes happen to the same unallocated cluster
* each write allocates separate cluster and writes data concurrently.
* The first one to complete updates l2 table with pointer to its
--
1.7.10.4
- [Qemu-devel] [RFC V5 21/62] qcow2: Remove hash when cluster is deleted., (continued)
- [Qemu-devel] [RFC V5 21/62] qcow2: Remove hash when cluster is deleted., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 51/62] block: Add BlockDriver function prototype to pause and resume deduplication., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 37/62] qcow2: Add deduplication metrics structures., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 24/62] qcow2: Serialize write requests when deduplication is activated., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 26/62] qcow2: Adapt checking of QCOW_OFLAG_COPIED for dedup., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 40/62] qcow2: Collect deduplicated cluster metric., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 57/62] qcow2: Add qcow2_pause_dedup., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 16/62] qcow2-cache: Allow to choose table size at creation., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 58/62] qcow2: Add qcow2_resume_dedup., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 60/62] qerror: Add QERR_DEVICE_NOT_DEDUPLICATED., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 28/62] qcow2: Do not overwrite existing entries with QCOW_OFLAG_COPIED.,
Benoît Canet <=
- [Qemu-devel] [RFC V5 15/62] qcow2: Extract qcow2_do_table_init., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 43/62] qcow2: Count QCowHashNode removal from tree for metrics., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 23/62] qcow2: Integrate deduplication in qcow2_co_writev loop., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 14/62] qcow2: Load and save deduplication table header extension., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 13/62] qcow2: Create qcow2_is_cluster_to_dedup., Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 44/62] qcow2: Count cluster deleted metric, Benoît Canet, 2013/01/16
- [Qemu-devel] [RFC V5 56/62] block: Add bdrv_pause_dedup., Benoît Canet, 2013/01/16