From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSsRt-0002ne-IE for qemu-devel@nongnu.org; Mon, 08 Feb 2016 15:30:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSsRs-000578-ET for qemu-devel@nongnu.org; Mon, 08 Feb 2016 15:30:17 -0500 References: <1453311539-1193-1-git-send-email-berrange@redhat.com> <1453311539-1193-14-git-send-email-berrange@redhat.com> From: Eric Blake Message-ID: <56B8FAD2.2090404@redhat.com> Date: Mon, 8 Feb 2016 13:30:10 -0700 MIME-Version: 1.0 In-Reply-To: <1453311539-1193-14-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="8NtCU9fnqfoORXkMpBQ7Demfjj35nBPaM" Subject: Re: [Qemu-devel] [PATCH v2 13/17] qcow: make encrypt_sectors encrypt in place List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8NtCU9fnqfoORXkMpBQ7Demfjj35nBPaM Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01/20/2016 10:38 AM, Daniel P. Berrange wrote: > Instead of requiring separate input/output buffers for > encrypting data, change encrypt_sectors() to assume > use of a single buffer, encrypting in place. One current > caller all uses the same buffer for input/output already > and the other two callers are easily converted todo so. s/todo/to do/ >=20 > Signed-off-by: Daniel P. Berrange > --- > block/qcow.c | 31 ++++++++++--------------------- > 1 file changed, 10 insertions(+), 21 deletions(-) >=20 > @@ -453,13 +447,12 @@ static uint64_t get_cluster_offset(BlockDriverSta= te *bs, > uint64_t start_sect; > assert(s->cipher); > start_sect =3D (offset & ~(s->cluster_size - 1)) >= > 9; > - memset(s->cluster_data + 512, 0x00, 512); > + memset(s->cluster_data, 0x00, 512); > for(i =3D 0; i < s->cluster_sectors; i++) { As long as you're touching near here, is it worth adding a space before '= ('? > @@ -672,7 +665,6 @@ static coroutine_fn int qcow_co_writev(BlockDriverS= tate *bs, int64_t sector_num, > BDRVQcowState *s =3D bs->opaque; > int index_in_cluster; > uint64_t cluster_offset; > - const uint8_t *src_buf; > int ret =3D 0, n; > uint8_t *cluster_data =3D NULL; > struct iovec hd_iov; > @@ -715,18 +707,15 @@ static coroutine_fn int qcow_co_writev(BlockDrive= rState *bs, int64_t sector_num, > if (!cluster_data) { > cluster_data =3D g_malloc0(s->cluster_size); > } > - if (encrypt_sectors(s, sector_num, cluster_data, buf, > + if (encrypt_sectors(s, sector_num, buf, > n, true, &err) < 0) { > error_free(err); > ret =3D -EIO; > break; > } > - src_buf =3D cluster_data; cluster_data is now unused; you've got a wasted g_malloc0() here and g_free() later on. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --8NtCU9fnqfoORXkMpBQ7Demfjj35nBPaM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWuPrSAAoJEKeha0olJ0NqKloH/jDamMYP9sO7V8wP2R54n6Ro aAMXwoNLQW+F+ZuI9+T4vZNCxCn1BQeo14MQaPfBx8XBapltFGF8a5HcwkrhXTVQ N3AyEnS+kx/YfLtEsbpFOrvknzH0McWJCXXWnUerYlQ1maDah2Ujt72P6kaRdaKF LCCQs4rph9HFA+pHoFcl4Q5pZkBxd490ipeW7FC+vAYWbsCwA0eIYXXUnLrGbmez 7CM8T6+ppYUnmVKet1ARLGdA46VAWptrPFP+JXVavKgecZa6BxTvuEaH23oFp/EZ MfMOJhYwaAgU1Aomiff7lhyoQo0poZzY1B58i5KdUEn1vALnrN3bK/+fkjPrekQ= =KdgS -----END PGP SIGNATURE----- --8NtCU9fnqfoORXkMpBQ7Demfjj35nBPaM--