From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFQOY-00017y-Vt for qemu-devel@nongnu.org; Tue, 12 Mar 2013 10:41:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFQOW-0002OZ-4h for qemu-devel@nongnu.org; Tue, 12 Mar 2013 10:41:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFQOV-0002OO-Qt for qemu-devel@nongnu.org; Tue, 12 Mar 2013 10:41:36 -0400 From: Kevin Wolf Date: Tue, 12 Mar 2013 15:41:16 +0100 Message-Id: <1363099279-403-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1363099279-403-1-git-send-email-kwolf@redhat.com> References: <1363099279-403-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 10/13] qcow2: set L2 cache dependency in qcow2_alloc_bytes() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Stefan Hajnoczi 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 Signed-off-by: Kevin Wolf --- block/qcow2-refcount.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index e8b5d0a..4d9df5f 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -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; } -- 1.8.1.4