From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrZyd-0004eY-DY for qemu-devel@nongnu.org; Thu, 20 Nov 2014 17:13:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrZyY-00060F-FI for qemu-devel@nongnu.org; Thu, 20 Nov 2014 17:13:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44190) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrZyY-000606-82 for qemu-devel@nongnu.org; Thu, 20 Nov 2014 17:13:18 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAKMDHqs002251 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 20 Nov 2014 17:13:17 -0500 Message-ID: <546E677C.7090907@redhat.com> Date: Thu, 20 Nov 2014 15:13:16 -0700 From: Eric Blake MIME-Version: 1.0 References: <1416503198-17031-1-git-send-email-mreitz@redhat.com> <1416503198-17031-8-git-send-email-mreitz@redhat.com> In-Reply-To: <1416503198-17031-8-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ccWJ3KOuOQ93XPpd7f25EBhmVAAnhBfvd" Subject: Re: [Qemu-devel] [PATCH v3 07/22] qcow2: Helper function for refcount modification List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ccWJ3KOuOQ93XPpd7f25EBhmVAAnhBfvd Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/20/2014 10:06 AM, Max Reitz wrote: > Since refcounts do not always have to be a uint16_t, all refcount block= s > and arrays in memory should not have a specific type (thus they become > pointers to void) and for accessing them, two helper functions are used= > (a getter and a setter). Those functions are called indirectly through > function pointers in the BDRVQcowState so they may later be exchanged > for different refcount orders. >=20 > With the check and repair functions using this function, the refcount > array they are creating will be in big endian byte order; additionally,= > using realloc_refcount_array() makes the size of this refcount array > always cluster-aligned. Both combined allow rebuild_refcount_structure(= ) > to drop the bounce buffer which was used to convert parts of the > refcount array to big endian byte order and store them on disk. Instead= , > those parts can now be written directly. Thanks, that helps. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-refcount.c | 131 ++++++++++++++++++++++++++++++-----------= -------- > block/qcow2.h | 8 +++ > 2 files changed, 89 insertions(+), 50 deletions(-) >=20 > @@ -2101,7 +2132,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, B= drvCheckResult *res, > /* Because the old reftable has been exchanged for a new one t= he > * references have to be recalculated */ > rebuild =3D false; > - memset(refcount_table, 0, nb_clusters * sizeof(uint16_t)); > + memset(refcount_table, 0, refcount_array_byte_size(s, nb_clust= ers)); Yep, that makes more sense than what you had in v2. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ccWJ3KOuOQ93XPpd7f25EBhmVAAnhBfvd Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUbmd8AAoJEKeha0olJ0NqJ+MH/0fvg+jMghZXPCrliV50g55/ qzksgbcYXwB8KfwIcAjvq5OL7L+WxwWQjsIsUdgl7CR4fyx6UeRBuD45NJlQ1tGA kBaIhNdS2/6T/8pp8W99NJcmFB+zLaTiD8LHUtek9pPxruGc5CjyKY4A7YC8xega mShtduLWvo2vCIjN0hiHhrMn3Jusw5DnWryqlassfwoqMCycwzH5+ivy8V47EclK 8iBH303aubNztD8MgTnQZ/OLCXdesWAKP7jv0vvj+0yrsUr417M7B7RWypFd75ta X+Lltb6aISzQCQdgud9bnp2cHMx653dUO2PFDT9aeeg4hf1UB115et7dAHcCoYM= =hweE -----END PGP SIGNATURE----- --ccWJ3KOuOQ93XPpd7f25EBhmVAAnhBfvd--