From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xo4C9-0006SG-Jb for qemu-devel@nongnu.org; Tue, 11 Nov 2014 00:40:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xo4C4-0003jy-Ly for qemu-devel@nongnu.org; Tue, 11 Nov 2014 00:40:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xo4C4-0003jr-EE for qemu-devel@nongnu.org; Tue, 11 Nov 2014 00:40:44 -0500 Message-ID: <5461A152.5070106@redhat.com> Date: Mon, 10 Nov 2014 22:40:34 -0700 From: Eric Blake MIME-Version: 1.0 References: <1415627159-15941-1-git-send-email-mreitz@redhat.com> <1415627159-15941-11-git-send-email-mreitz@redhat.com> In-Reply-To: <1415627159-15941-11-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jwURCAS5FKQNQvL0R58EUcX4GAFge6lPG" Subject: Re: [Qemu-devel] [PATCH 10/21] qcow2: refcount_order parameter for qcow2_create2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Lieven , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jwURCAS5FKQNQvL0R58EUcX4GAFge6lPG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/10/2014 06:45 AM, Max Reitz wrote: > Add a refcount_order parameter to qcow2_create2(), use that value for > the image header and for calculating the size required for > preallocation. >=20 > For now, always pass 4. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2.c | 41 ++++++++++++++++++++++++++++++----------- > 1 file changed, 30 insertions(+), 11 deletions(-) >=20 > @@ -1811,6 +1811,13 @@ static int qcow2_create2(const char *filename, i= nt64_t total_size, > int64_t meta_size =3D 0; > uint64_t nreftablee, nrefblocke, nl1e, nl2e; > int64_t aligned_total_size =3D align_offset(total_size, cluste= r_size); > + int refblock_bits, refblock_size; > + /* refcount entry size in bytes */ > + double rces =3D (1 << refcount_order) / 8.; Would float be any simpler than double? > + > + /* see qcow2_open() */ > + refblock_bits =3D cluster_bits - (refcount_order - 3); > + refblock_size =3D 1 << refblock_bits; > =20 > /* header: 1 cluster */ > meta_size +=3D cluster_size; > @@ -1835,20 +1842,20 @@ static int qcow2_create2(const char *filename, = int64_t total_size, > * c =3D cluster size > * y1 =3D number of refcount blocks entries > * y2 =3D meta size including everything > + * rces =3D refcount entry size in bytes > * then, > * y1 =3D (y2 + a)/c > - * y2 =3D y1 * sizeof(u16) + y1 * sizeof(u16) * sizeof(u64) = / c + m > + * y2 =3D y1 * rces + y1 * rces * sizeof(u64) / c + m Hmm. This changes from integral to floating point. Are we going to suffer from any rounding problems? I guess you want double to ensure maximum precision; but whereas earlier patches were limited with refcount_order of 6 to 2^63, this now limits us around 2^53 if we are still trying to be accurate. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jwURCAS5FKQNQvL0R58EUcX4GAFge6lPG 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 iQEcBAEBCAAGBQJUYaFSAAoJEKeha0olJ0Nql6kH/RBb8R4k5F5VpyH+vnqtllhb J7yODFfaJfYZCclGNJuaWaBB/kPhuHfRwzrFl98fS75zmQREmLp61vx2mO7zh+ow 9VQ1Xhf3BwmDu7cSfE3phy35KpsQRdB2kFKhFOTG7oqlos3N09GkyO9u6fBJ+J4Q WKarvMwnmYIqdyjNYtgU7JwPNOCaUgk1dWIWhJDifgyy216oGWAA0inh1HIU9F1G CWHjfweO0tac/ofh2CSncBxacoCWpFriwFmarX08GcHixfomG2yqjjMuIM3uLtah Xz+OvcrybvrcOcajT+ejn2NJceT2p5ACzrrB/K8y8xWull7UbW4Dn1m3M95AUCY= =Qedp -----END PGP SIGNATURE----- --jwURCAS5FKQNQvL0R58EUcX4GAFge6lPG--