From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HYK2d-0005LF-SZ for qemu-devel@nongnu.org; Mon, 02 Apr 2007 06:45:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HYK2c-0005FD-DQ for qemu-devel@nongnu.org; Mon, 02 Apr 2007 06:45:38 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HYK2c-0005E4-1I for qemu-devel@nongnu.org; Mon, 02 Apr 2007 06:45:38 -0400 Received: from kurt.tools.de ([192.76.135.70]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HYJzZ-0000fT-ML for qemu-devel@nongnu.org; Mon, 02 Apr 2007 06:42:30 -0400 Received: from imap.tools.intra (imap.tools.intra [172.20.0.17]) by kurt.TooLs.DE (Postfix) with ESMTP id 25941C643 for ; Mon, 2 Apr 2007 12:42:26 +0200 (MEST) Received: from tiger2.tools.intra (tiger2.tools.intra [172.20.0.11]) by imap.tools.intra (8.13.6+Sun/8.13.6) with SMTP id l32AgOi3024912 for ; Mon, 2 Apr 2007 12:42:24 +0200 (CEST) Message-Id: <200704021042.l32AgOi3024912@imap.tools.intra> Date: Mon, 2 Apr 2007 12:42:23 +0200 (CEST) From: Juergen Keil MIME-Version: 1.0 Content-Type: MULTIPART/mixed; BOUNDARY=Dule_of_Doves_375_000 Subject: [Qemu-devel] [PATCH] qcow2: release refcount table clusters of the old table, after growing the refcount table Reply-To: Juergen Keil , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Dule_of_Doves_375_000 Content-Type: TEXT/plain; charset=us-ascii Content-MD5: eW/2obD70TTKGemQ1zIl0A== Another patch for qcow2: when the refcount table is grown, clusters for the new refcount table are allocated, but the clusters for the old (now unused) refcount table are not released. This isn't a big problem, it just wastes a few clusters. But it results in error messages when block-qcow2.c is compiled with DEBUG_ALLOC / DEBUG_ALLOC2 error checking, and a qcow2 image has ever grown the refcount table: /* compare ref counts */ for(i = 0; i < nb_clusters; i++) { refcount1 = get_refcount(bs, i); refcount2 = refcount_table[i]; if (refcount1 != refcount2) printf("ERROR cluster %d refcount=%d reference=%d\n", i, refcount1, refcount2); } % qemu-img info sol11-b60.img ERROR cluster 9 refcount=1 reference=0 <<<<<<<<<<<<<<<<<<<<<<<<<<< image: sol11-b60.img file format: qcow2 virtual size: 8.0G (8589934592 bytes) disk size: 2.6G cluster_size: 4096 --Dule_of_Doves_375_000 Content-Type: TEXT/plain; name=qcow2-patch; charset=us-ascii Content-Description: qcow2-patch Content-MD5: ymNZLGCXcXH2XcC5R7vNWw== Index: block-qcow2.c =================================================================== RCS file: /cvsroot/qemu/qemu/block-qcow2.c,v retrieving revision 1.5 diff -u -B -r1.5 block-qcow2.c --- block-qcow2.c 1 Apr 2007 19:01:40 -0000 1.5 +++ block-qcow2.c 2 Apr 2007 10:17:54 -0000 @@ -1886,6 +1894,8 @@ int64_t table_offset; uint64_t data64; uint32_t data32; + int old_table_size; + int64_t old_table_offset; if (min_size <= s->refcount_table_size) return 0; @@ -1931,11 +1941,14 @@ &data32, sizeof(data32)) != sizeof(data32)) goto fail; qemu_free(s->refcount_table); + old_table_offset = s->refcount_table_offset; + old_table_size = s->refcount_table_size; s->refcount_table = new_table; s->refcount_table_size = new_table_size; s->refcount_table_offset = table_offset; update_refcount(bs, table_offset, new_table_size2, 1); + free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t)); return 0; fail: free_clusters(bs, table_offset, new_table_size2); --Dule_of_Doves_375_000--