[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 03/10] qcow2: Pull check_refblocks() up
From: |
Benoît Canet |
Subject: |
Re: [Qemu-devel] [PATCH v3 03/10] qcow2: Pull check_refblocks() up |
Date: |
Fri, 22 Aug 2014 18:04:19 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Fri, Aug 22, 2014 at 06:31:37PM +0200, Max Reitz wrote:
> Pull check_refblocks() before calculate_refcounts() so we can drop its
> static declaration.
>
> Signed-off-by: Max Reitz <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 5f0920b..2b728ef 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -1496,59 +1496,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.
> @@ -1626,6 +1573,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.
> */
> --
> 2.0.4
>
Reviewed-by: Benoît Canet <address@hidden>
- [Qemu-devel] [PATCH v3 00/10] qcow2: Fix image repairing, Max Reitz, 2014/08/22
- [Qemu-devel] [PATCH v3 01/10] qcow2: Fix leaks in dirty images, Max Reitz, 2014/08/22
- [Qemu-devel] [PATCH v3 02/10] qcow2: Split qcow2_check_refcounts(), Max Reitz, 2014/08/22
- [Qemu-devel] [PATCH v3 03/10] qcow2: Pull check_refblocks() up, Max Reitz, 2014/08/22
- Re: [Qemu-devel] [PATCH v3 03/10] qcow2: Pull check_refblocks() up,
Benoît Canet <=
- [Qemu-devel] [PATCH v3 04/10] qcow2: Reuse refcount table in calculate_refcounts(), Max Reitz, 2014/08/22
- [Qemu-devel] [PATCH v3 05/10] qcow2: Fix refcount blocks beyond image end, Max Reitz, 2014/08/22
- [Qemu-devel] [PATCH v3 06/10] qcow2: Do not perform potentially damaging repairs, Max Reitz, 2014/08/22
- [Qemu-devel] [PATCH v3 07/10] qcow2: Rebuild refcount structure during check, Max Reitz, 2014/08/22