From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwCHG-0001V3-ML for qemu-devel@nongnu.org; Wed, 03 Dec 2014 10:55:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwCHB-0001Qx-Hu for qemu-devel@nongnu.org; Wed, 03 Dec 2014 10:55:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55689) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwCHB-0001Qn-7X for qemu-devel@nongnu.org; Wed, 03 Dec 2014 10:55:37 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sB3FtZqN022139 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 3 Dec 2014 10:55:36 -0500 Message-ID: <547F3276.40106@redhat.com> Date: Wed, 03 Dec 2014 08:55:34 -0700 From: Eric Blake MIME-Version: 1.0 References: <1417613866-25890-1-git-send-email-mreitz@redhat.com> <1417613866-25890-6-git-send-email-mreitz@redhat.com> In-Reply-To: <1417613866-25890-6-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wDcBr1JAdTKospd0rlOLMwHdhFxIi75nh" Subject: Re: [Qemu-devel] [PATCH v4 05/26] qcow2: Use unsigned addend for update_refcount() 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) --wDcBr1JAdTKospd0rlOLMwHdhFxIi75nh Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/03/2014 06:37 AM, Max Reitz wrote: > update_refcount() and qcow2_update_cluster_refcount() currently take a > signed addend. At least one caller passes a value directly derived from= > an absolute refcount that should be reached ("l2_refcount - 1" in > expand_zero_clusters_in_l1()). Therefore, the addend should be unsigned= > because unsigned overflow is well-defined in contrast to signed > overflow. This will be especially important for 64 bit refcounts. >=20 > Because update_refcount() then no longer knows whether the refcount > should be increased or decreased (which is important for setting the > refblock-L2-table cache dependency and for overflow/underflow checks), > it now requires an additional flag which specified exactly that. The > same applies to qcow2_update_cluster_refcount(). >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-cluster.c | 2 +- > block/qcow2-refcount.c | 63 ++++++++++++++++++++++++++++++++----------= -------- > block/qcow2.h | 3 ++- > 3 files changed, 44 insertions(+), 24 deletions(-) >=20 > @@ -1677,7 +1695,8 @@ static void compare_refcounts(BlockDriverState *b= s, BdrvCheckResult *res, > =20 > if (num_fixed) { > ret =3D update_refcount(bs, i << s->cluster_bits, 1, > - (int)refcount2 - (int)refcount1,= > + refcount2 - refcount1, > + refcount1 > refcount2, > QCOW2_DISCARD_ALWAYS); Nice - my comment on 4/26 is indeed addressed here (so I was correct in guessing that the series touched that area again, and no need to respin).= Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --wDcBr1JAdTKospd0rlOLMwHdhFxIi75nh 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 iQEcBAEBCAAGBQJUfzJ2AAoJEKeha0olJ0NqlyUH/3wnnU1fEigg7d7srcfb71wn 27Sos3ZFehYmmQjkY9+hGbQr1u+HCF3IaeeowJXjwIkBhyH+5zOGHENie1g0CU7R cw2HjFk0fp6ztCT21EiQmmIE1GEG8eQ/CkLsa5xlOZT61kJ9ytN+UJikzPE2+Lo6 5I7G0PKF6P26E8iuhwO5ZzTjip8O+ev22VMOBbI/B3phn8Uy2WGCTF+sVNYgM62e dfg8iG9s/2zmBOLj4ieyqQYujEkRzW5GVrVKGSQo9aiz3GU+yDKN2hhOsjUOy/fe L8gp/VBXF+dw3SQ6xuukcloiSZ688EzfejB/KAH1zM0sJSi8XWcFA5sOEWeNf+4= =MJXF -----END PGP SIGNATURE----- --wDcBr1JAdTKospd0rlOLMwHdhFxIi75nh--