Received: from eggs.gnu.org ([2001:4830:134:3::10]:40823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJlfm-0007vH-Gn for qemu-devel@nongnu.org; Fri, 06 Feb 2015 11:22:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJlfj-0002Sz-4e for qemu-devel@nongnu.org; Fri, 06 Feb 2015 11:22:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJlfi-0002Sr-S0 for qemu-devel@nongnu.org; Fri, 06 Feb 2015 11:22:23 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t16GMMeT025642 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 6 Feb 2015 11:22:22 -0500 Date: Fri, 6 Feb 2015 17:22:20 +0100 From: Kevin Wolf Message-ID: <20150206162220.GH13081@noname.redhat.com> References: <1423233556-19394-1-git-send-email-mreitz@redhat.com> <54D4DD45.5010809@redhat.com> <54D4DE43.7050207@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="huq684BweRXVnRxX" Content-Disposition: inline In-Reply-To: <54D4DE43.7050207@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3] qcow2: Rewrite qcow2_alloc_bytes() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 06.02.2015 um 16:31 hat Eric Blake geschrieben: > On 02/06/2015 08:27 AM, Eric Blake wrote: >=20 > >> =20 > >> - /* The cluster refcount was incremented, either by qcow2_alloc_cl= usters() > >> - * or explicitly by qcow2_update_cluster_refcount(). Refcount bl= ocks must > >> - * be flushed before the caller's L2 table updates. > >> - */ > >> + assert(offset); > >> + ret =3D update_refcount(bs, offset, size, 1, QCOW2_DISCARD_NEVER); > >=20 > > Case 1: This incremented the new cluster. Good > > Case 2: This incremented the old cluster. Good > > Case 3: This incremented the new cluster. Good > > Case 4: This incremented the old cluster. But the new cluster remains at > > refcount 0. BAD. >=20 > Wait. Maybe I'm confused. You are requesting an update_refcount() > across size bytes, and given the offset, that means that the code will > round up to cover BOTH clusters in one call. Does update_refcount() > properly increment from [ 1, 0 ] to [ 2, 1 ] when given a 2-cluster > size (when offset, size is rounded up to cluster boundaries)? If so, > then there is no bug after all. Yes, this is what it should be doing. Letting one update_refcount() call (more or less) atomically increment both refcounts was the whole point of my suggestion anyway because that is what enables the simplification. Kevin --huq684BweRXVnRxX Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJU1Oo8AAoJEH8JsnLIjy/WVGMP/3VcEmvngGBERkGK2fEU/VFC zBmdyDaw+yKXxgaSkhHrqoK+mu6TxtE8MTuyfdBcIN14C97F2qHag3StVHcxbUSF s5SE2X6GeRxcFZo6m8X22hnvmzqFFBoKYcX5nd0uNBhAH+xp24DWQW3XQKBX+jdL tlhlhQdroadlY+TOr0xg3UkeuMatsI3a17uKkMTo20h4NgZjIGJUsJHVWbkEASKM 4AvGzh70eUgmWhvCzNAbuSBe9kjhj88CeVegNdFgfekopo5wXOaEQQR95PvYFZEG Q1QopOswM1xWl15hfAQWsu+3HwwP72LZ8oAtJl0pTCvgVTaATNEi8Yb9AAZ7KUMZ JoNEvktI7S9NPMi1pZ/ZT2Kyad9xANSKYp9DsMrqkVPXFuQG6+7rAbz2G9TcUvqB S5wYjWkrefBSB8VseS7dY8LgZ/YsJOuVgWfLPc03ewfuDkyh4IVsF8AB5KWyQI6L 1HJ+MLTliKxlhXCUqePWiKBGjIFtosVrECvj44Z74Xat94zNHrk5L/89PAGqv9rB D1SJMJYug/pnGhBBupjbu3IqhZKbeWigxZDAUAAHRl4mqYkiWgOkBI5ioKJfomIW 7sO9Vo4D/AwKmZ7CQi/r5jHamtf8vDYpnPsgljbDMWW+6Ff9hQ9CEA0CYJyuyOAm im3lyoHcMxe2tsfvr8wd =Ue32 -----END PGP SIGNATURE----- --huq684BweRXVnRxX--