From patchwork Mon Oct 14 21:52:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 283485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 977142C011F for ; Tue, 15 Oct 2013 16:56:41 +1100 (EST) Received: from localhost ([::1]:39906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVxcV-0000BO-JV for incoming@patchwork.ozlabs.org; Tue, 15 Oct 2013 01:56:39 -0400 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 d28dlp03.in.ibm.com (9.184.220.128) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 15 Oct 2013 11:22:42 +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 Received: from RH64wenchao ([9.181.129.59]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r9F5qZHE000390; Tue, 15 Oct 2013 11:22:40 +0530 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Tue, 15 Oct 2013 05:52:30 +0800 Message-Id: <1381787553-12497-4-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 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> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13101505-8878-0000-0000-0000093E7145 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.7 Cc: kwolf@redhat.com, stefanha@gmail.com, mreitz@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V4 3/6] qcow2: do not free clusters when fail in header update in qcow2_write_snapshots X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }