Received: from eggs.gnu.org ([2001:4830:134:3::10]:51091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ypatw-0002Yw-0L for qemu-devel@nongnu.org; Tue, 05 May 2015 07:20:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ypats-0002L9-I3 for qemu-devel@nongnu.org; Tue, 05 May 2015 07:20:35 -0400 Date: Tue, 5 May 2015 13:20:19 +0200 From: Kevin Wolf Message-ID: <20150505112019.GB3866@noname.redhat.com> References: <9b9c36f8c567da1f9561828380e8aa42c08b7efd.1430388393.git.berto@igalia.com> <20150501142321.GB2386@stefanha-thinkpad.redhat.com> <20150504105813.GD3676@noname.str.redhat.com> <20150505102858.GC3149@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="82I3+IH0IqGh5yIs" Content-Disposition: inline In-Reply-To: <20150505102858.GC3149@stefanha-thinkpad.redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/6] qcow2: use one single memory block for the L2/refcount cache tables List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-block@nongnu.org, Alberto Garcia , qemu-devel@nongnu.org, Stefan Hajnoczi --82I3+IH0IqGh5yIs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 05.05.2015 um 12:28 hat Stefan Hajnoczi geschrieben: > On Mon, May 04, 2015 at 12:58:13PM +0200, Kevin Wolf wrote: > > Am 01.05.2015 um 16:23 hat Stefan Hajnoczi geschrieben: > > > On Thu, Apr 30, 2015 at 01:11:40PM +0300, Alberto Garcia wrote: > > > > Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_table= s) > > > > { > > > > BDRVQcowState *s =3D bs->opaque; > > > > Qcow2Cache *c; > > > > - int i; > > > > =20 > > > > c =3D g_new0(Qcow2Cache, 1); > > > > c->size =3D num_tables; > > > > + c->table_size =3D s->cluster_size; > > >=20 > > > This assumes c->table_size meets bs' memory alignment requirements. = The > > > following would be safer: > > >=20 > > > c->table_size =3D QEMU_ALIGN_UP(c->table_size, bdrv_opt_mem_align(bs-= >file)); > >=20 > > You can't just access more than one cluster. You might be caching data > > and later write it back when it's stale. >=20 > I don't mean I/O alignment, just memory alignment (i.e. the start > address of the data buffer in memory). The start address is already taken care of by qemu_blockalign(). With rounding c->table_size, you'd align the length, and that would be wrong. Though looking at the code again I see now that c->table_size isn't consistently used. The I/O requests still use s->cluster_size. We should either use it everywhere or not introduce it at all. Kevin --82I3+IH0IqGh5yIs Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJVSKdyAAoJEH8JsnLIjy/WczkP/ReZDPHDAiRbFcs/sg/V5cR6 6GrSTcuzj1HTRMTQdo9Z8ePCJZsmH9bDN83oFlfLlNkgnFqJ4hmq5M+sxfkxBh4Z FJ07cXIRTgNRaiFLT6lKNv9xsjUJQ2MXr4/P8vCdJZZAjFzb9IWd+aj9JOprzlhi 7Swom6yhVZX23Tl73FByL8eZH6x/1Nrdj2kVU6TPQ6CK08ckZqPQPjeBg6IQqdcz fTB+cu7SvkjW9rYJFWsBFsaJKwPz1LG6wk4xjW2sdANFOn2u7sWrshvUVFj6QJ6O oA54GwUqgA+MHI9OeIo0yDSfVuzKRKQ54Tn4ylMT4AwlZpzcOCNKEGWIxt4Ia69F h/hM8qTjoi3x5ui5FJzjcLn1ISnmYMQOrEFUsFIb0Gt80MN2wBiIwJEvr/FfHgkA tsTOgL6QyRbfiEA4YDFUEqgT2qLxN5Epi/u/gNP07hwcK43+siDFpyBGmWQaZjhD QtTTOoB2/ghFAHTMs4+b1vsUMnChMjU7z0hCfv2/c60CNpJW3Pr0nBNsEBetoSfs Of9RFhCNQ3vN3UWanF3moonB0RvdXWzaxFGTHXFmLqF8ACaO1Ym1GpuQ/Exr0sRV uPFGbz4QIuzBx9ME17G1N9Nd1beycqZJE5R1aBy4P5pUTimGwy5BgNbh5kMjGEal c8fPEzS9F3nQMXdTd08H =viWf -----END PGP SIGNATURE----- --82I3+IH0IqGh5yIs--