From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhPDw-00060h-3u for qemu-devel@nongnu.org; Thu, 23 Oct 2014 16:43:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XhPDn-0002NI-8Y for qemu-devel@nongnu.org; Thu, 23 Oct 2014 16:43:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1983) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhPDn-0002Mp-12 for qemu-devel@nongnu.org; Thu, 23 Oct 2014 16:42:59 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9NKgwSD015629 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 23 Oct 2014 16:42:58 -0400 From: Kevin Wolf Date: Thu, 23 Oct 2014 22:42:18 +0200 Message-Id: <1414096959-14682-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1414096959-14682-1-git-send-email-kwolf@redhat.com> References: <1414096959-14682-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 11/32] qcow2: Pull check_refblocks() up List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com From: Max Reitz Pull check_refblocks() before calculate_refcounts() so we can drop its static declaration. Signed-off-by: Max Reitz Reviewed-by: Beno=C3=AEt Canet Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- 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; } =20 -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 *re= s, - BdrvCheckMode fix, uint16_t **refcount_ta= ble, - 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_FRAG_= 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_cluster= s, - 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, B= drvCheckResult *res, } =20 /* + * Calculates an in-memory refcount table. + */ +static int calculate_refcounts(BlockDriverState *bs, BdrvCheckResult *re= s, + BdrvCheckMode fix, uint16_t **refcount_ta= ble, + 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_FRAG_= 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_cluster= s, + 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 aga= inst the * refcount as reported by the refcount structures on-disk. */ --=20 1.8.3.1