Commit 23be50f1afbb8c3db746ecd7735f74eacc89db24

Authored by ths
1 parent cce1075c

Qcow2: Release refcount table clusters after growing the refcount table,

by Juergen Keil.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2586 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 5 additions and 0 deletions
block-qcow2.c
@@ -1886,6 +1886,8 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size) @@ -1886,6 +1886,8 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size)
1886 int64_t table_offset; 1886 int64_t table_offset;
1887 uint64_t data64; 1887 uint64_t data64;
1888 uint32_t data32; 1888 uint32_t data32;
  1889 + int old_table_size;
  1890 + int64_t old_table_offset;
1889 1891
1890 if (min_size <= s->refcount_table_size) 1892 if (min_size <= s->refcount_table_size)
1891 return 0; 1893 return 0;
@@ -1931,11 +1933,14 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size) @@ -1931,11 +1933,14 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size)
1931 &data32, sizeof(data32)) != sizeof(data32)) 1933 &data32, sizeof(data32)) != sizeof(data32))
1932 goto fail; 1934 goto fail;
1933 qemu_free(s->refcount_table); 1935 qemu_free(s->refcount_table);
  1936 + old_table_offset = s->refcount_table_offset;
  1937 + old_table_size = s->refcount_table_size;
1934 s->refcount_table = new_table; 1938 s->refcount_table = new_table;
1935 s->refcount_table_size = new_table_size; 1939 s->refcount_table_size = new_table_size;
1936 s->refcount_table_offset = table_offset; 1940 s->refcount_table_offset = table_offset;
1937 1941
1938 update_refcount(bs, table_offset, new_table_size2, 1); 1942 update_refcount(bs, table_offset, new_table_size2, 1);
  1943 + free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
1939 return 0; 1944 return 0;
1940 fail: 1945 fail:
1941 free_clusters(bs, table_offset, new_table_size2); 1946 free_clusters(bs, table_offset, new_table_size2);