From patchwork Wed Oct 9 08:44:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 281741 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 5E7742C00B8 for ; Wed, 9 Oct 2013 19:45:02 +1100 (EST) Received: from localhost ([::1]:40710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTpO8-0008AD-Ax for incoming@patchwork.ozlabs.org; Wed, 09 Oct 2013 04:45:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTpNn-00089t-3X for qemu-devel@nongnu.org; Wed, 09 Oct 2013 04:44:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTpNh-0007nr-3u for qemu-devel@nongnu.org; Wed, 09 Oct 2013 04:44:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTpNg-0007nm-SE for qemu-devel@nongnu.org; Wed, 09 Oct 2013 04:44:33 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r998iV4g015313 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 Oct 2013 04:44:31 -0400 Received: from localhost (dhcp-200-247.str.redhat.com [10.33.200.247]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r998iSGs030116 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Wed, 9 Oct 2013 04:44:30 -0400 From: Max Reitz To: qemu-devel@nongnu.org Date: Wed, 9 Oct 2013 10:44:28 +0200 Message-Id: <1381308268-23235-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH] qcow2: Free preallocated zero clusters 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 In qcow2_free_any_clusters, preallocated zero clusters should be freed just as normal clusters are. Signed-off-by: Max Reitz --- block/qcow2-refcount.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 2d67885..9dd5e44 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -796,11 +796,13 @@ void qcow2_free_any_clusters(BlockDriverState *bs, uint64_t l2_entry, } break; case QCOW2_CLUSTER_NORMAL: - qcow2_free_clusters(bs, l2_entry & L2E_OFFSET_MASK, - nb_clusters << s->cluster_bits, type); + case QCOW2_CLUSTER_ZERO: + if (l2_entry & L2E_OFFSET_MASK) { + qcow2_free_clusters(bs, l2_entry & L2E_OFFSET_MASK, + nb_clusters << s->cluster_bits, type); + } break; case QCOW2_CLUSTER_UNALLOCATED: - case QCOW2_CLUSTER_ZERO: break; default: abort();