]> git.proxmox.com Git - qemu.git/commitdiff
qcow2: set L2 cache dependency in qcow2_alloc_bytes()
authorStefan Hajnoczi <stefanha@redhat.com>
Mon, 4 Mar 2013 14:02:32 +0000 (15:02 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 15 Mar 2013 15:07:50 +0000 (16:07 +0100)
Compressed writes use qcow2_alloc_bytes() to allocate space with byte
granularity.  The affected clusters' refcounts will be incremented but
we do not need to flush yet.

Set a L2 cache dependency on the refcount block cache, so that the
refcounts get written out before the L2 updates.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2-refcount.c

index e8b5d0a4ac43e07adf31b5dfcafd133065642608..4d9df5fe95d891520f9a15c1103ad19cd8879b51 100644 (file)
@@ -669,7 +669,11 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
         }
     }
 
-    bdrv_flush(bs->file);
+    /* The cluster refcount was incremented, either by qcow2_alloc_clusters()
+     * or explicitly by update_cluster_refcount().  Refcount blocks must be
+     * flushed before the caller's L2 table updates.
+     */
+    qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache);
     return offset;
 }