[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/32] qcow2: Pull check_refblocks() up
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 11/32] qcow2: Pull check_refblocks() up |
Date: |
Thu, 23 Oct 2014 22:42:18 +0200 |
From: Max Reitz <address@hidden>
Pull check_refblocks() before calculate_refcounts() so we can drop its
static declaration.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: BenoƮt Canet <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-refcount.c | 102 ++++++++++++++++++++++++-------------------------
1 file changed, 49 insertions(+), 53 deletions(-)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index e8b9df9..24f297f 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -1535,59 +1535,6 @@ done:
return new_offset;
}
-static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res,
- BdrvCheckMode fix, uint16_t **refcount_table,
- int64_t *nb_clusters);
-
-/*
- * Calculates an in-memory refcount table.
- */
-static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
- BdrvCheckMode fix, uint16_t **refcount_table,
- int64_t *nb_clusters)
-{
- BDRVQcowState *s = bs->opaque;
- int64_t i;
- QCowSnapshot *sn;
- int ret;
-
- *refcount_table = g_try_new0(uint16_t, *nb_clusters);
- if (*nb_clusters && *refcount_table == NULL) {
- res->check_errors++;
- return -ENOMEM;
- }
-
- /* header */
- inc_refcounts(bs, res, *refcount_table, *nb_clusters,
- 0, s->cluster_size);
-
- /* current L1 table */
- ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters,
- s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO);
- if (ret < 0) {
- return ret;
- }
-
- /* snapshots */
- for (i = 0; i < s->nb_snapshots; i++) {
- sn = s->snapshots + i;
- ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters,
- sn->l1_table_offset, sn->l1_size, 0);
- if (ret < 0) {
- return ret;
- }
- }
- inc_refcounts(bs, res, *refcount_table, *nb_clusters,
- s->snapshots_offset, s->snapshots_size);
-
- /* refcount data */
- inc_refcounts(bs, res, *refcount_table, *nb_clusters,
- s->refcount_table_offset,
- s->refcount_table_size * sizeof(uint64_t));
-
- return check_refblocks(bs, res, fix, refcount_table, nb_clusters);
-}
-
/*
* Checks consistency of refblocks and accounts for each refblock in
* *refcount_table.
@@ -1665,6 +1612,55 @@ static int check_refblocks(BlockDriverState *bs,
BdrvCheckResult *res,
}
/*
+ * Calculates an in-memory refcount table.
+ */
+static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
+ BdrvCheckMode fix, uint16_t **refcount_table,
+ int64_t *nb_clusters)
+{
+ BDRVQcowState *s = bs->opaque;
+ int64_t i;
+ QCowSnapshot *sn;
+ int ret;
+
+ *refcount_table = g_try_new0(uint16_t, *nb_clusters);
+ if (*nb_clusters && *refcount_table == NULL) {
+ res->check_errors++;
+ return -ENOMEM;
+ }
+
+ /* header */
+ inc_refcounts(bs, res, *refcount_table, *nb_clusters,
+ 0, s->cluster_size);
+
+ /* current L1 table */
+ ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters,
+ s->l1_table_offset, s->l1_size, CHECK_FRAG_INFO);
+ if (ret < 0) {
+ return ret;
+ }
+
+ /* snapshots */
+ for (i = 0; i < s->nb_snapshots; i++) {
+ sn = s->snapshots + i;
+ ret = check_refcounts_l1(bs, res, *refcount_table, *nb_clusters,
+ sn->l1_table_offset, sn->l1_size, 0);
+ if (ret < 0) {
+ return ret;
+ }
+ }
+ inc_refcounts(bs, res, *refcount_table, *nb_clusters,
+ s->snapshots_offset, s->snapshots_size);
+
+ /* refcount data */
+ inc_refcounts(bs, res, *refcount_table, *nb_clusters,
+ s->refcount_table_offset,
+ s->refcount_table_size * sizeof(uint64_t));
+
+ return check_refblocks(bs, res, fix, refcount_table, nb_clusters);
+}
+
+/*
* Compares the actual reference count for each cluster in the image against
the
* refcount as reported by the refcount structures on-disk.
*/
--
1.8.3.1
- [Qemu-devel] [PULL 03/32] MAINTAINERS: add the image fuzzer to the block layer, (continued)
- [Qemu-devel] [PULL 03/32] MAINTAINERS: add the image fuzzer to the block layer, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 01/32] MAINTAINERS: add aio to block layer, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 05/32] block: qemu-iotests change _supported_proto to file once more., Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 02/32] MAINTAINERS: qemu-iotests belongs to the block layer, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 06/32] block: Add qemu_{,try_}blockalign0(), Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 04/32] block/vdi: Use {DIV_,}ROUND_UP, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 08/32] qcow2: Fix leaks in dirty images, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 07/32] qcow2: Calculate refcount block entry count, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 09/32] qcow2: Split qcow2_check_refcounts(), Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 10/32] qcow2: Use sizeof(**refcount_table), Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 11/32] qcow2: Pull check_refblocks() up,
Kevin Wolf <=
- [Qemu-devel] [PULL 13/32] qcow2: Split fail code in L1 and L2 checks, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 12/32] qcow2: Use int64_t for in-memory reftable size, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 14/32] qcow2: Let inc_refcounts() return -errno, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 16/32] qcow2: Reuse refcount table in calculate_refcounts(), Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 15/32] qcow2: Let inc_refcounts() resize the reftable, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 17/32] qcow2: Fix refcount blocks beyond image end, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 18/32] qcow2: Do not perform potentially damaging repairs, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 20/32] qcow2: Clean up after refcount rebuild, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 19/32] qcow2: Rebuild refcount structure during check, Kevin Wolf, 2014/10/23
- [Qemu-devel] [PULL 21/32] iotests: Fix test outputs, Kevin Wolf, 2014/10/23