提交 9696df21 编写于 作者: M Max Reitz 提交者: Kevin Wolf

qcow2: Reuse refcount table in calculate_refcounts()

We will later call calculate_refcounts multiple times, so reuse the
refcount table if possible.
Signed-off-by: NMax Reitz <mreitz@redhat.com>
Reviewed-by: NBenoît Canet <benoit.canet@nodalink.com>
Reviewed-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 641bb63c
...@@ -1661,10 +1661,12 @@ static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res, ...@@ -1661,10 +1661,12 @@ static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
QCowSnapshot *sn; QCowSnapshot *sn;
int ret; int ret;
*refcount_table = g_try_new0(uint16_t, *nb_clusters); if (!*refcount_table) {
if (*nb_clusters && *refcount_table == NULL) { *refcount_table = g_try_new0(uint16_t, *nb_clusters);
res->check_errors++; if (*nb_clusters && *refcount_table == NULL) {
return -ENOMEM; res->check_errors++;
return -ENOMEM;
}
} }
/* header */ /* header */
...@@ -1780,7 +1782,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, ...@@ -1780,7 +1782,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
{ {
BDRVQcowState *s = bs->opaque; BDRVQcowState *s = bs->opaque;
int64_t size, highest_cluster, nb_clusters; int64_t size, highest_cluster, nb_clusters;
uint16_t *refcount_table; uint16_t *refcount_table = NULL;
int ret; int ret;
size = bdrv_getlength(bs->file); size = bdrv_getlength(bs->file);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册