From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFQOZ-0001A0-Qw for qemu-devel@nongnu.org; Tue, 12 Mar 2013 10:41:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UFQOV-0002OE-26 for qemu-devel@nongnu.org; Tue, 12 Mar 2013 10:41:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16643) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UFQOU-0002O6-Qm for qemu-devel@nongnu.org; Tue, 12 Mar 2013 10:41:34 -0400 From: Kevin Wolf Date: Tue, 12 Mar 2013 15:41:15 +0100 Message-Id: <1363099279-403-10-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 09/13] qcow2: flush refcount cache correctly in qcow2_write_snapshots() 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 Since qcow2 metadata is cached we need to flush the caches, not just the underlying file. Use bdrv_flush(bs) instead of bdrv_flush(bs->file). Also add the error return path when bdrv_flush() fails and move the flush after checking for qcow2_alloc_clusters() failure so that the qcow2_alloc_clusters() error return value takes precedence. Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/qcow2-snapshot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index eb8fcd5..f4719d9 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -180,11 +180,14 @@ static int qcow2_write_snapshots(BlockDriverState *bs) /* Allocate space for the new snapshot list */ snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size); - bdrv_flush(bs->file); offset = snapshots_offset; if (offset < 0) { return offset; } + ret = bdrv_flush(bs); + if (ret < 0) { + return ret; + } /* Write all snapshots to the new list */ for(i = 0; i < s->nb_snapshots; i++) { -- 1.8.1.4