From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKtCL-0005zL-Dg for qemu-devel@nongnu.org; Fri, 22 Aug 2014 14:04:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKtCG-0006Xt-7z for qemu-devel@nongnu.org; Fri, 22 Aug 2014 14:04:25 -0400 Received: from dew.nodalink.com ([95.130.14.197]:39926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKtCF-0006Xo-VP for qemu-devel@nongnu.org; Fri, 22 Aug 2014 14:04:20 -0400 Date: Fri, 22 Aug 2014 18:04:19 +0000 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140822180419.GD9526@nodalink.com> References: <1408725104-17176-1-git-send-email-mreitz@redhat.com> <1408725104-17176-4-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1408725104-17176-4-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 03/10] qcow2: Pull check_refblocks() up List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi , =?iso-8859-1?Q?Beno=EEt?= Canet 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. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-refcount.c | 102 ++++++++++++++++++++++++-----------------= -------- > 1 file changed, 49 insertions(+), 53 deletions(-) >=20 > 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; > } > =20 > -static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, > - BdrvCheckMode fix, uint16_t **refcount_tabl= e, > - 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 =3D bs->opaque; > - int64_t i; > - QCowSnapshot *sn; > - int ret; > - > - *refcount_table =3D g_try_new0(uint16_t, *nb_clusters); > - if (*nb_clusters && *refcount_table =3D=3D NULL) { > - res->check_errors++; > - return -ENOMEM; > - } > - > - /* header */ > - inc_refcounts(bs, res, *refcount_table, *nb_clusters, > - 0, s->cluster_size); > - > - /* current L1 table */ > - ret =3D check_refcounts_l1(bs, res, *refcount_table, *nb_clusters, > - s->l1_table_offset, s->l1_size, CHECK_FRA= G_INFO); > - if (ret < 0) { > - return ret; > - } > - > - /* snapshots */ > - for (i =3D 0; i < s->nb_snapshots; i++) { > - sn =3D s->snapshots + i; > - ret =3D check_refcounts_l1(bs, res, *refcount_table, *nb_clust= ers, > - 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, > } > =20 > /* > + * 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 =3D bs->opaque; > + int64_t i; > + QCowSnapshot *sn; > + int ret; > + > + *refcount_table =3D g_try_new0(uint16_t, *nb_clusters); > + if (*nb_clusters && *refcount_table =3D=3D NULL) { > + res->check_errors++; > + return -ENOMEM; > + } > + > + /* header */ > + inc_refcounts(bs, res, *refcount_table, *nb_clusters, > + 0, s->cluster_size); > + > + /* current L1 table */ > + ret =3D check_refcounts_l1(bs, res, *refcount_table, *nb_clusters, > + s->l1_table_offset, s->l1_size, CHECK_FRA= G_INFO); > + if (ret < 0) { > + return ret; > + } > + > + /* snapshots */ > + for (i =3D 0; i < s->nb_snapshots; i++) { > + sn =3D s->snapshots + i; > + ret =3D check_refcounts_l1(bs, res, *refcount_table, *nb_clust= ers, > + 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 a= gainst the > * refcount as reported by the refcount structures on-disk. > */ > --=20 > 2.0.4 >=20 Reviewed-by: Beno=EEt Canet