From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVxYz-0003RC-Od for qemu-devel@nongnu.org; Tue, 15 Oct 2013 01:53:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVxYq-0003tJ-8i for qemu-devel@nongnu.org; Tue, 15 Oct 2013 01:53:01 -0400 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:43783) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVxYp-0003sJ-J1 for qemu-devel@nongnu.org; Tue, 15 Oct 2013 01:52:52 -0400 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 15 Oct 2013 11:22:45 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id 831051258051 for ; Tue, 15 Oct 2013 11:23:09 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r9F5qemq48758808 for ; Tue, 15 Oct 2013 11:22:40 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r9F5qfik000696 for ; Tue, 15 Oct 2013 11:22:41 +0530 From: Wenchao Xia Date: Tue, 15 Oct 2013 05:52:30 +0800 Message-Id: <1381787553-12497-4-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1381787553-12497-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1381787553-12497-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V4 3/6] qcow2: do not free clusters when fail in header update in qcow2_write_snapshots List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@gmail.com, mreitz@redhat.com, pbonzini@redhat.com, Wenchao Xia Signed-off-by: Wenchao Xia --- block/qcow2-snapshot.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 4bd494b..c933b7f 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -304,6 +304,13 @@ static int qcow2_write_snapshots(BlockDriverState *bs, Error **errp) PRIi64 " with size %" PRIu64 ":%d (%s)", offsetof(QCowHeader, nb_snapshots), sizeof(header_data), ret, strerror(-ret)); + /* + * If the snapshot data part have been updated on disk, Then the + * clusters at snapshot_offset may be used in next snapshot operation. + * If we free those clusters in fail path, they may be allocated and + * made dirty causing damage, so skip cluster free for safe. + */ + snapshots_offset = 0; goto fail; } -- 1.7.1