From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdCl8-0005Sp-UL for qemu-devel@nongnu.org; Fri, 17 May 2013 00:59:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UdCl6-0000RA-Hg for qemu-devel@nongnu.org; Fri, 17 May 2013 00:59:14 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:51421) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdCl5-0000Qo-TH for qemu-devel@nongnu.org; Fri, 17 May 2013 00:59:12 -0400 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 May 2013 10:23:25 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 8453AE004F for ; Fri, 17 May 2013 10:31:30 +0530 (IST) Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4H4wsF09241016 for ; Fri, 17 May 2013 10:28:55 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4H4x1hc005476 for ; Fri, 17 May 2013 14:59:02 +1000 Message-ID: <5195B8FF.6000902@linux.vnet.ibm.com> Date: Fri, 17 May 2013 12:58:39 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1368607419-15178-1-git-send-email-xiawenc@linux.vnet.ibm.com> <20130516093239.GB8853@stefanha-thinkpad.redhat.com> In-Reply-To: <20130516093239.GB8853@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 1/2] qcow2: free allocated cluster on fail in qcow2_write_snapshots() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org 于 2013-5-16 17:32, Stefan Hajnoczi 写道: > On Wed, May 15, 2013 at 04:43:38PM +0800, Wenchao Xia wrote: >> Signed-off-by: Wenchao Xia >> --- >> block/qcow2-snapshot.c | 2 ++ >> 1 files changed, 2 insertions(+), 0 deletions(-) >> >> diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c >> index 992a5c8..a6065a9 100644 >> --- a/block/qcow2-snapshot.c >> +++ b/block/qcow2-snapshot.c >> @@ -268,6 +268,8 @@ static int qcow2_write_snapshots(BlockDriverState *bs) >> return 0; >> >> fail: >> + /* free the new snapshot table */ >> + qcow2_free_clusters(bs, snapshots_offset, snapshots_size); >> return ret; >> } > > snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size); > offset = snapshots_offset; > if (offset < 0) { > return offset; > } > ret = bdrv_flush(bs); > if (ret < 0) { > return ret; > } > > For completeness the bdrv_flush() return ret should be change to a goto > fail so that we cover all failure cases. > Ok, will add those. -- Best Regards Wenchao Xia