From 69e2d1b3ddb208481ac2b88323c1f8e293ef5b86 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 8 Jun 2010 11:12:47 -0300 Subject: [PATCH 05/13] qcow2: Return right error code in write_refcount_block_entries RH-Author: Kevin Wolf Message-id: <1275995574-17666-5-git-send-email-kwolf@redhat.com> Patchwork-id: 9769 O-Subject: [RHEL-6 qemu-kvm PATCH v2 04/11] qcow2: Return right error code in write_refcount_block_entries Bugzilla: 598507 RH-Acked-by: Christoph Hellwig RH-Acked-by: Jes Sorensen RH-Acked-by: Juan Quintela Bugzilla: 598507 Upstream status: Submitted write_refcount_block_entries used to return -EIO for any errors. Change this to return the real error code. Signed-off-by: Kevin Wolf (cherry picked from commit ce4f2b9981cebf0046dd488c10021e397391ab1f) --- block/qcow2-refcount.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-) Signed-off-by: Eduardo Habkost --- block/qcow2-refcount.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index dc57e16..6ae4d78 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -411,6 +411,7 @@ static int write_refcount_block_entries(BlockDriverState *bs, { BDRVQcowState *s = bs->opaque; size_t size; + int ret; if (cache_refcount_updates) { return 0; @@ -425,12 +426,13 @@ static int write_refcount_block_entries(BlockDriverState *bs, & ~(REFCOUNTS_PER_SECTOR - 1); size = (last_index - first_index) << REFCOUNT_SHIFT; + BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_UPDATE_PART); - if (bdrv_pwrite(bs->file, + ret = bdrv_pwrite(bs->file, refcount_block_offset + (first_index << REFCOUNT_SHIFT), - &s->refcount_block_cache[first_index], size) != size) - { - return -EIO; + &s->refcount_block_cache[first_index], size); + if (ret < 0) { + return ret; } return 0; @@ -471,10 +473,10 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT); if ((old_table_index >= 0) && (table_index != old_table_index)) { - if (write_refcount_block_entries(bs, refcount_block_offset, - first_index, last_index) < 0) - { - return -EIO; + ret = write_refcount_block_entries(bs, refcount_block_offset, + first_index, last_index); + if (ret < 0) { + return ret; } first_index = -1; @@ -516,10 +518,11 @@ fail: /* Write last changed block to disk */ if (refcount_block_offset != 0) { - if (write_refcount_block_entries(bs, refcount_block_offset, - first_index, last_index) < 0) - { - return ret < 0 ? ret : -EIO; + int wret; + wret = write_refcount_block_entries(bs, refcount_block_offset, + first_index, last_index); + if (wret < 0) { + return ret < 0 ? ret : wret; } } -- 1.7.0.3