From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMkVn-0001oL-4g for qemu-devel@nongnu.org; Thu, 19 Sep 2013 16:07:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMkVi-0008Hk-1V for qemu-devel@nongnu.org; Thu, 19 Sep 2013 16:07:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMkVh-0008Hg-PZ for qemu-devel@nongnu.org; Thu, 19 Sep 2013 16:07:33 -0400 Message-ID: <523B597C.4060304@redhat.com> Date: Thu, 19 Sep 2013 14:07:24 -0600 From: Eric Blake MIME-Version: 1.0 References: <1379425736-11326-1-git-send-email-pl@kamp.de> <1379425736-11326-8-git-send-email-pl@kamp.de> In-Reply-To: <1379425736-11326-8-git-send-email-pl@kamp.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="S6pd3EPMBNXukupDODWQgnD2b3JHAOlnO" Subject: Re: [Qemu-devel] [PATCHv2 07/20] block: honour alignment and limit in bdrv_co_do_write_zeroes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: kwolf@redhat.com, ronniesahlberg@gmail.com, stefanha@redhat.com, qemu-devel@nongnu.org, anthony@codemonkey.ws, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --S6pd3EPMBNXukupDODWQgnD2b3JHAOlnO Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/17/2013 07:48 AM, Peter Lieven wrote: > Signed-off-by: Peter Lieven > --- > block.c | 57 +++++++++++++++++++++++++++++++++++++++++--------------= -- > 1 file changed, 41 insertions(+), 16 deletions(-) >=20 > diff --git a/block.c b/block.c > index 177720e..74ec342 100644 > --- a/block.c > +++ b/block.c > @@ -2660,28 +2660,53 @@ static int coroutine_fn bdrv_co_do_write_zeroes= (BlockDriverState *bs, > BlockDriver *drv =3D bs->drv; > QEMUIOVector qiov; > struct iovec iov; > - int ret; > + int ret =3D 0; > =20 > - /* TODO Emulate only part of misaligned requests instead of lettin= g block > - * drivers return -ENOTSUP and emulate everything */ > + /* if no limit is specified in the BlockDriverState use a default > + * of 32768 512-byte sectors (16 MiB) per request. > + */ > + int max_write_zeroes =3D bs->max_write_zeroes ? bs->max_write_zero= es : 32768; Worth having a named constant instead of a magic number? > + while (nb_sectors > 0 && !ret) { > + > + if (ret =3D=3D -ENOTSUP) { > + /* Fall back to bounce buffer if write zeroes is unsupport= ed */ > + iov.iov_len =3D nb_sectors * BDRV_SECTOR_SIZE; > + iov.iov_base =3D qemu_blockalign(bs, iov.iov_len); > + memset(iov.iov_base, 0, iov.iov_len); This allocates, clears, and frees iov.iov_len bytes of 0 every iteration through the loop. Can you hoist that so you only allocate the bounce buffer once, and then clean it up after the loop completes? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --S6pd3EPMBNXukupDODWQgnD2b3JHAOlnO 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.4.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSO1l8AAoJEKeha0olJ0Nq0PYH/AmDd7ILnL0q9wVWhxahKlMy B9OLd3aHGsFMgvpY/CDTzuNvD+53tvbtZRukSMZbhtLVa4fI/L3toca2oORdfrFT wCB/kL6Bb5fIjAHz6kXjSha7dqVojTBWMSEa/iqnLczy8O5S2O8Ft8orx1ZwhL6m tDK6ac2YcYnQ5fIjb3qKL6ImgHr0YfjYM+NGDCCWhRMkTK7dT4FNhu3Sa4KBadeM vNieMiAKskZVZanZARQduBp7I8keOQsZjEgkmfwmCB9oT+oTPHybk4wy/xT1JCBw 3BP0DNQpvjvE8uaXLxCdO+9GaLpIi1n+Ko8+qKWfuDJrOGt6JcYE36jCSENdJf8= =4GcA -----END PGP SIGNATURE----- --S6pd3EPMBNXukupDODWQgnD2b3JHAOlnO--