[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v8 11/17] qcow2: Reuse refcount table in calculate_r
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v8 11/17] qcow2: Reuse refcount table in calculate_refcounts() |
Date: |
Wed, 22 Oct 2014 14:09:37 +0200 |
We will later call calculate_refcounts multiple times, so reuse the
refcount table if possible.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: BenoƮt Canet <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
---
block/qcow2-refcount.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index d653124..c92e1fc 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -1661,10 +1661,12 @@ static int calculate_refcounts(BlockDriverState *bs,
BdrvCheckResult *res,
QCowSnapshot *sn;
int ret;
- *refcount_table = g_try_new0(uint16_t, *nb_clusters);
- if (*nb_clusters && *refcount_table == NULL) {
- res->check_errors++;
- return -ENOMEM;
+ if (!*refcount_table) {
+ *refcount_table = g_try_new0(uint16_t, *nb_clusters);
+ if (*nb_clusters && *refcount_table == NULL) {
+ res->check_errors++;
+ return -ENOMEM;
+ }
}
/* header */
@@ -1780,7 +1782,7 @@ int qcow2_check_refcounts(BlockDriverState *bs,
BdrvCheckResult *res,
{
BDRVQcowState *s = bs->opaque;
int64_t size, highest_cluster, nb_clusters;
- uint16_t *refcount_table;
+ uint16_t *refcount_table = NULL;
int ret;
size = bdrv_getlength(bs->file);
--
1.9.3
- [Qemu-devel] [PATCH v8 04/17] qcow2: Split qcow2_check_refcounts(), (continued)
- [Qemu-devel] [PATCH v8 04/17] qcow2: Split qcow2_check_refcounts(), Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 01/17] block: Add qemu_{, try_}blockalign0(), Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 06/17] qcow2: Pull check_refblocks() up, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 03/17] qcow2: Fix leaks in dirty images, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 05/17] qcow2: Use sizeof(**refcount_table), Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 07/17] qcow2: Use int64_t for in-memory reftable size, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 08/17] qcow2: Split fail code in L1 and L2 checks, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 09/17] qcow2: Let inc_refcounts() return -errno, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 11/17] qcow2: Reuse refcount table in calculate_refcounts(),
Max Reitz <=
- [Qemu-devel] [PATCH v8 10/17] qcow2: Let inc_refcounts() resize the reftable, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 12/17] qcow2: Fix refcount blocks beyond image end, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 14/17] qcow2: Rebuild refcount structure during check, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 13/17] qcow2: Do not perform potentially damaging repairs, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 15/17] qcow2: Clean up after refcount rebuild, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 17/17] iotests: Add test for potentially damaging repairs, Max Reitz, 2014/10/22
- [Qemu-devel] [PATCH v8 16/17] iotests: Fix test outputs, Max Reitz, 2014/10/22
- Re: [Qemu-devel] [PATCH v8 00/17] qcow2: Fix image repairing, Kevin Wolf, 2014/10/22