From patchwork Fri May 28 11:22:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 53885 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EC6BAB7D1F for ; Fri, 28 May 2010 21:29:14 +1000 (EST) Received: from localhost ([127.0.0.1]:54368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHxkM-0008Pw-E1 for incoming@patchwork.ozlabs.org; Fri, 28 May 2010 07:29:02 -0400 Received: from [140.186.70.92] (port=33623 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHxex-0004vU-C9 for qemu-devel@nongnu.org; Fri, 28 May 2010 07:23:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHxew-0004KH-CH for qemu-devel@nongnu.org; Fri, 28 May 2010 07:23:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27991) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHxew-0004K8-49 for qemu-devel@nongnu.org; Fri, 28 May 2010 07:23:26 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4SBNJoO030892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 May 2010 07:23:19 -0400 Received: from localhost.localdomain (vpn1-4-101.ams2.redhat.com [10.36.4.101]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4SBN9a8026938; Fri, 28 May 2010 07:23:18 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Fri, 28 May 2010 13:22:51 +0200 Message-Id: <1275045773-26963-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1275045773-26963-1-git-send-email-kwolf@redhat.com> References: <1275045773-26963-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 3/5] qcow2: Return right error code in write_refcount_block_entries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org write_refcount_block_entries used to return -EIO for any errors. Change this to return the real error code. Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi --- 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 744107c..a7f295d 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -404,6 +404,7 @@ static int write_refcount_block_entries(BlockDriverState *bs, { BDRVQcowState *s = bs->opaque; size_t size; + int ret; if (cache_refcount_updates) { return 0; @@ -414,12 +415,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; @@ -460,10 +462,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; @@ -505,10 +507,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; } }