From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtGnJ-0000tr-Nw for qemu-devel@nongnu.org; Tue, 25 Nov 2014 09:08:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtGnD-0006nN-Tu for qemu-devel@nongnu.org; Tue, 25 Nov 2014 09:08:41 -0500 From: Max Reitz Date: Tue, 25 Nov 2014 15:08:03 +0100 Message-Id: <1416924485-13304-11-git-send-email-mreitz@redhat.com> In-Reply-To: <1416924485-13304-1-git-send-email-mreitz@redhat.com> References: <1416924485-13304-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH 10/12] qcow2: Flushing the caches in qcow2_close may fail List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Lieven , qemu-stable@nongnu.org, Markus Armbruster , Stefan Hajnoczi , Max Reitz qcow2_cache_flush() may fail; if one of the caches failed to be flushed successfully to disk in qcow2_close() the image should not be marked clean, and we should emit a warning. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz --- block/qcow2.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index d120494..2bd2a53 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1428,10 +1428,23 @@ static void qcow2_close(BlockDriverState *bs) s->l1_table = NULL; if (!(bs->open_flags & BDRV_O_INCOMING)) { - qcow2_cache_flush(bs, s->l2_table_cache); - qcow2_cache_flush(bs, s->refcount_block_cache); + int ret1, ret2; - qcow2_mark_clean(bs); + ret1 = qcow2_cache_flush(bs, s->l2_table_cache); + ret2 = qcow2_cache_flush(bs, s->refcount_block_cache); + + if (ret1) { + error_report("Failed to flush the L2 table cache: %s", + strerror(-ret1)); + } + if (ret2) { + error_report("Failed to flush the refcount block cache: %s", + strerror(-ret2)); + } + + if (!ret1 && !ret2) { + qcow2_mark_clean(bs); + } } qcow2_cache_destroy(bs, s->l2_table_cache); -- 1.9.3