From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKTp1-0002qR-Ev for qemu-devel@nongnu.org; Fri, 13 Sep 2013 09:54:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKTow-0005Rc-Km for qemu-devel@nongnu.org; Fri, 13 Sep 2013 09:54:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34298) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKTow-0005RV-C9 for qemu-devel@nongnu.org; Fri, 13 Sep 2013 09:54:02 -0400 Message-ID: <523318F2.1020008@redhat.com> Date: Fri, 13 Sep 2013 07:53:54 -0600 From: Eric Blake MIME-Version: 1.0 References: <1379067909-22984-1-git-send-email-pl@kamp.de> <1379067909-22984-13-git-send-email-pl@kamp.de> In-Reply-To: <1379067909-22984-13-git-send-email-pl@kamp.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vV6VpGi2ac5kCgoKcs5febVcVqqU454nu" Subject: Re: [Qemu-devel] [PATCH 12/12] block/get_block_status: fix BDRV_BLOCK_ZERO for unallocated blocks 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) --vV6VpGi2ac5kCgoKcs5febVcVqqU454nu Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/13/2013 04:25 AM, Peter Lieven wrote: > this patch does 2 things: > a) only do additional call outs if BDRV_BLOCK_ZERO is not already set. > b) use bdi.discard_zeroes to return the zero state of an unallocated bl= ock. > the callout to bdrv_has_zero_init() is only valid right after bdrv_c= reate. >=20 > Signed-off-by: Peter Lieven > --- > block.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/block.c b/block.c > index 282943b..6698c10 100644 > --- a/block.c > +++ b/block.c > @@ -3153,8 +3153,10 @@ static int64_t coroutine_fn bdrv_co_get_block_st= atus(BlockDriverState *bs, > return ret; > } > =20 > - if (!(ret & BDRV_BLOCK_DATA)) { > - if (bdrv_has_zero_init(bs)) { > + if (!(ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO)) { Why not avoid the &&: if ((ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) =3D=3D 0) { Then again, any decent compiler will probably already do that optimization on your behalf. > + BlockDriverInfo bdi; > + if (bdrv_get_info(bs, &bdi) =3D=3D 0 && > + bdi.discard_zeroes) { > ret |=3D BDRV_BLOCK_ZERO; > } else if (bs->backing_hd) { > BlockDriverState *bs2 =3D bs->backing_hd; >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --vV6VpGi2ac5kCgoKcs5febVcVqqU454nu 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/ iQEcBAEBCAAGBQJSMxjyAAoJEKeha0olJ0Nq3t8H/ApN5MAUDykwyGEtToMWhvhj UiYx5VxKJ7G/btq3AY6+BMvqhyagqQxx1RCziiI9AuS9Ds9RQ+2earIPLNzIFWC4 LtLcepZ3Pc3y/WoQLqtXPWniuTlmNrIEChw3+7UJWFBx3F7jCimye5ekWiDKkMB5 36oWl9zoZ0Ds0VxQmzEIW2fiehCp0Y6Q5Kl1l6X9TUf5W478e1SHgLfitDWZT2ec 4cWPdLPDQkt3Fp1mrA/BG5KsK4WBuBPJBSfVylrwgZTrSbzkTq3jvV0lPkDof2xd GH4G/AcSWlhx7eGZoixomdLlFIkCgorANrTE3QQ2l22Cd18S/YOrlV6BaDGO5zI= =g3P6 -----END PGP SIGNATURE----- --vV6VpGi2ac5kCgoKcs5febVcVqqU454nu--