From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5dfJ-0001ul-Gw for qemu-devel@nongnu.org; Wed, 25 May 2016 14:36:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5dfF-0003Ea-8w for qemu-devel@nongnu.org; Wed, 25 May 2016 14:36:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5dfF-0003EQ-0i for qemu-devel@nongnu.org; Wed, 25 May 2016 14:36:17 -0400 References: <1463476543-3087-1-git-send-email-den@openvz.org> <1463476543-3087-2-git-send-email-den@openvz.org> <20160517163431.GG9802@noname.redhat.com> From: Eric Blake Message-ID: <5745F09E.8050505@redhat.com> Date: Wed, 25 May 2016 12:36:14 -0600 MIME-Version: 1.0 In-Reply-To: <20160517163431.GG9802@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="RL6OMw5W7EXo94X2XA2LN236Wf6930TCO" Subject: Re: [Qemu-devel] [PATCH 1/5] block: split write_zeroes always List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , "Denis V. Lunev" Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --RL6OMw5W7EXo94X2XA2LN236Wf6930TCO Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/17/2016 10:34 AM, Kevin Wolf wrote: > Am 17.05.2016 um 11:15 hat Denis V. Lunev geschrieben: >> We should split requests even if they are less than write_zeroes_align= ment. >> For example we can have the following request: >> offset 62k >> size 4k >> write_zeroes_alignment 64k >> The original code sent 1 request covering 2 qcow2 clusters, and result= ed >> in both clusters being allocated. But by splitting the request, we can= >> cater to the case where one of the two clusters can be zeroed as a >> whole, for only 1 cluster allocated after the operation. >> >> Signed-off-by: Denis V. Lunev >> CC: Eric Blake >> CC: Kevin Wolf >> --- >> block/io.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/block/io.c b/block/io.c >> index cd6d71a..6a24ea8 100644 >> --- a/block/io.c >> +++ b/block/io.c >> @@ -1172,13 +1172,13 @@ static int coroutine_fn bdrv_co_do_write_zeroe= s(BlockDriverState *bs, >> /* Align request. Block drivers can expect the "bulk" of the= request >> * to be aligned. >> */ >> - if (bs->bl.write_zeroes_alignment >> - && num > bs->bl.write_zeroes_alignment) { >> + if (bs->bl.write_zeroes_alignment) { >> if (sector_num % bs->bl.write_zeroes_alignment !=3D 0) { >> /* Make a small request up to the first aligned secto= r. */ >> num =3D bs->bl.write_zeroes_alignment; >> num -=3D sector_num % bs->bl.write_zeroes_alignment; >=20 > Turns out this doesn't work. If this is a small request that zeros > something in the middle of a single cluster (i.e. we have untouched dat= a > both before and after the request in the same cluster), then num can no= w > become greater than nb_sectors, so that we end up zeroing too much. I'm planning on folding in a working version of this patch in my byte-based write_zeroes conversion series. As part of the patch, I'm also hoisting the division out of the loop (no guarantees that the compiler can spot that bs->bl.write_zeroes_alignment will be a power of two, to optimize it to a shift). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --RL6OMw5W7EXo94X2XA2LN236Wf6930TCO 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/ iQEcBAEBCAAGBQJXRfCfAAoJEKeha0olJ0NqUsgH/jFHaBIkCwetyHQOVxbO4VL4 K97iBoGYJMFpbgazM4WYBJDweq444pDlnOJ68CgEX1cqH6iWQLu3L65JyzKdnisB hSifCFgMsOo5fOo4WN11zhFY3CcfF1HZralCas9aNatx03d3Ic8iMOSq4aL5QG0e yeUby/BCpKTmGlaTk8dSLSt1Rs5SD57RqwjE6SjbrIoHPIiLojOrTxPh9NtmaoWs FdO+M2+e0qsSdNIqBgVHV9rPIVwHhcOPiMyaNyGqZjZbC7QPC15V9DtRiX5B22Y6 fbGUqs49NTy8EL0l+LX2uMQbEuE9B90/7xz+6BxFcvbCDAfR4n4+cN9aNIrW0po= =iCKJ -----END PGP SIGNATURE----- --RL6OMw5W7EXo94X2XA2LN236Wf6930TCO--