From e51b6bd58c6396e3111c6ecaa9e81fe5ecd9855b Mon Sep 17 00:00:00 2001 From: Kevin Wolf <kwolf@redhat.com> Date: Fri, 18 Jun 2010 15:22:27 -0300 Subject: [PATCH 09/18] qcow2: Return right error code in write_refcount_block_entries RH-Author: Kevin Wolf <kwolf@redhat.com> Message-id: <1276874554-9820-10-git-send-email-kwolf@redhat.com> Patchwork-id: 9984 O-Subject: [RHEL-5.6 KVM PATCH 09/16] qcow2: Return right error code in write_refcount_block_entries Bugzilla: 605701 RH-Acked-by: Juan Quintela <quintela@redhat.com> RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com> RH-Acked-by: Christoph Hellwig <chellwig@redhat.com> RH-Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com> Bugzilla: 605701 Upstream commit: ed0df867d93341289d085ed9e9d44907e342c7ff write_refcount_block_entries used to return -EIO for any errors. Change this to return the real error code. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- qemu/block-qcow2.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- qemu/block-qcow2.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-) diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c index 1a9a98d..75c6759 100644 --- a/qemu/block-qcow2.c +++ b/qemu/block-qcow2.c @@ -2997,17 +2997,19 @@ static int write_refcount_block_entries(BDRVQcowState *s, int64_t refcount_block_offset, int first_index, int last_index) { size_t size; + int ret; first_index &= ~(REFCOUNTS_PER_SECTOR - 1); last_index = (last_index + REFCOUNTS_PER_SECTOR) & ~(REFCOUNTS_PER_SECTOR - 1); size = (last_index - first_index) << REFCOUNT_SHIFT; - if (bdrv_pwrite(s->hd, + + ret = bdrv_pwrite(s->hd, 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; @@ -3049,10 +3051,10 @@ static int 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(s, refcount_block_offset, - first_index, last_index) < 0) - { - return -EIO; + ret = write_refcount_block_entries(s, refcount_block_offset, + first_index, last_index); + if (ret < 0) { + return ret; } first_index = -1; @@ -3094,10 +3096,11 @@ fail: /* Write last changed block to disk */ if (refcount_block_offset != 0) { - if (write_refcount_block_entries(s, refcount_block_offset, - first_index, last_index) < 0) - { - return ret < 0 ? ret : -EIO; + int wret; + wret = write_refcount_block_entries(s, refcount_block_offset, + first_index, last_index); + if (wret < 0) { + return ret < 0 ? ret : wret; } } -- 1.7.0.3