* [Qemu-devel] [PATCH] qcow2: release refcount table clusters of the old table, after growing the refcount table
@ 2007-04-02 10:42 Juergen Keil
0 siblings, 0 replies; only message in thread
From: Juergen Keil @ 2007-04-02 10:42 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: TEXT/plain, Size: 937 bytes --]
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
[-- Attachment #2: qcow2-patch --]
[-- Type: TEXT/plain, Size: 1081 bytes --]
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-04-02 10:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-02 10:42 [Qemu-devel] [PATCH] qcow2: release refcount table clusters of the old table, after growing the refcount table Juergen Keil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).