From patchwork Mon Feb 8 15:01:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Meyering X-Patchwork-Id: 44796 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 BF48BB7D1A for ; Tue, 9 Feb 2010 02:04:47 +1100 (EST) Received: from localhost ([127.0.0.1]:47146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NeV96-00088c-1d for incoming@patchwork.ozlabs.org; Mon, 08 Feb 2010 10:03:28 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NeV7B-0007wQ-AM for qemu-devel@nongnu.org; Mon, 08 Feb 2010 10:01:29 -0500 Received: from [199.232.76.173] (port=35997 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NeV7A-0007wG-W6 for qemu-devel@nongnu.org; Mon, 08 Feb 2010 10:01:29 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NeV79-00051f-BR for qemu-devel@nongnu.org; Mon, 08 Feb 2010 10:01:28 -0500 Received: from mx.meyering.net ([82.230.74.64]:40521) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NeV78-000513-VF for qemu-devel@nongnu.org; Mon, 08 Feb 2010 10:01:27 -0500 Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 36A0121542; Mon, 8 Feb 2010 16:01:25 +0100 (CET) From: Jim Meyering To: qemu-devel@nongnu.org, kwolf@redhat.com Date: Mon, 08 Feb 2010 16:01:25 +0100 Message-ID: <87hbprsrei.fsf@meyering.net> Lines: 48 MIME-Version: 1.0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Subject: [Qemu-devel] [PATCH] qcow2: don't ignore failed update_refcount 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 update_refcount is marked as a function for which we must use its result, static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs, and rightly so, since doing otherwise would amount to ignoring write failure. However, there are two cases in which the return value is currently ignored. This fixes them: From 107940556a2d0ef1de1d59a5da0c6c3086246817 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 8 Feb 2010 11:50:59 +0100 Subject: [PATCH] qcow2: don't ignore failed update_refcount * block/qcow2-refcount.c (grow_refcount_table): When update_refcount fails, return its negative return code to our caller. (alloc_refcount_block): Likewise. --- block/qcow2-refcount.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) -- 1.7.0.rc2.156.g2ac04 diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 2fdc26b..b9f5093 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -181,7 +181,9 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size) s->refcount_table_size = new_table_size; s->refcount_table_offset = table_offset; - update_refcount(bs, table_offset, new_table_size2, 1); + ret = update_refcount(bs, table_offset, new_table_size2, 1); + if (ret < 0) + goto fail; qcow2_free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t)); return 0; fail: @@ -231,7 +233,9 @@ static int64_t alloc_refcount_block(BlockDriverState *bs, int64_t cluster_index) refcount_block_offset = offset; s->refcount_block_cache_offset = offset; - update_refcount(bs, offset, s->cluster_size, 1); + ret = update_refcount(bs, offset, s->cluster_size, 1); + if (ret < 0) + return ret; cache_refcount_updates = cache; } else { if (refcount_block_offset != s->refcount_block_cache_offset) {