From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2LNa-00059c-3I for qemu-devel@nongnu.org; Mon, 16 May 2016 12:28:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2LNU-0002Pa-Uy for qemu-devel@nongnu.org; Mon, 16 May 2016 12:28:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2LNU-0002PN-ML for qemu-devel@nongnu.org; Mon, 16 May 2016 12:28:20 -0400 References: <1463227273-27523-1-git-send-email-den@openvz.org> <1463227273-27523-4-git-send-email-den@openvz.org> From: Eric Blake Message-ID: <5739F522.1080505@redhat.com> Date: Mon, 16 May 2016 10:28:18 -0600 MIME-Version: 1.0 In-Reply-To: <1463227273-27523-4-git-send-email-den@openvz.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4lqE6wbubudrlN1Qbn1pi6fB26DPO5CvJ" Subject: Re: [Qemu-devel] [PATCH 3/6] qcow2: simplify logic in qcow2_co_write_zeroes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" , qemu-devel@nongnu.org Cc: Kevin Wolf This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --4lqE6wbubudrlN1Qbn1pi6fB26DPO5CvJ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/14/2016 06:01 AM, Denis V. Lunev wrote: > Unaligned request could occupy only one cluster. This is true since the= s/request could/requests will/ > previous commit. Simplify the code taking this considiration into s/considiration/consideration/ > account. >=20 > There are no other changes so far. >=20 > Signed-off-by: Denis V. Lunev > CC: Kevin Wolf > --- > block/qcow2.c | 23 +++++------------------ > 1 file changed, 5 insertions(+), 18 deletions(-) >=20 > diff --git a/block/qcow2.c b/block/qcow2.c > index 62febfc..9a54bbd 100644 > --- a/block/qcow2.c > +++ b/block/qcow2.c > @@ -2436,33 +2436,20 @@ static coroutine_fn int qcow2_co_write_zeroes(B= lockDriverState *bs, > int tail =3D (sector_num + nb_sectors) % s->cluster_sectors; > =20 > if (head !=3D 0 || tail !=3D 0) { > - int64_t cl_end =3D -1; > + int64_t cl_start =3D sector_num - head; > =20 > - sector_num -=3D head; > - nb_sectors +=3D head; > + assert(cl_start + s->cluster_sectors >=3D sector_num + nb_sect= ors); In other words, the caller is now buggy if it ever passes us an unaligned request that crosses cluster boundaries (the only requests that can cross boundaries will be aligned). With the grammar fix in the commit message, Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --4lqE6wbubudrlN1Qbn1pi6fB26DPO5CvJ 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/ iQEcBAEBCAAGBQJXOfUiAAoJEKeha0olJ0NqfAIH/1AWfQfDCh8tJ308zhLFDhVL Betu0h+z102IQTat9D5O9JZ4koxwF94EAL/UyTb9lA0yAX2IdqRrnNq5g4IZuqq3 xCF3djW+60T2T1zRp0wTZdCl9DeBCB7PyJY7VcKngoca/wnx967VK1YZG67VYtsl qSuSvW5dBYkGCWRc69j5yX+mPhSO/2Mj/Y1Tr3C+7yG7kE/7N4W6Xe2o9GxylzRl EwlJFSvzq6AcnAk4N66OV5l0uLx6v3rWV42R3uvDaQhkpAVHadtJEtXVdg5DQcC9 7y4zgOvwOzrHYmEZYP7nIPV7ClpYOjIYp1dDfQgfFlXhStVddCzOBMjBXW9jdsk= =kI2K -----END PGP SIGNATURE----- --4lqE6wbubudrlN1Qbn1pi6fB26DPO5CvJ--