From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8v1I-0006oD-HJ for qemu-devel@nongnu.org; Fri, 03 Jun 2016 15:44:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8v1G-0005BQ-Fl for qemu-devel@nongnu.org; Fri, 03 Jun 2016 15:44:35 -0400 References: <1464974478-23598-1-git-send-email-kwolf@redhat.com> <1464974478-23598-5-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <5751DE1B.6080403@redhat.com> Date: Fri, 3 Jun 2016 13:44:27 -0600 MIME-Version: 1.0 In-Reply-To: <1464974478-23598-5-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="OHRwVD0BMXPc8KSPTPXegQAeFLQWJruPQ" Subject: Re: [Qemu-devel] [PATCH 4/5] qcow2: Use bytes instead of sectors for QCowL2Meta List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: jsnow@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --OHRwVD0BMXPc8KSPTPXegQAeFLQWJruPQ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/03/2016 11:21 AM, Kevin Wolf wrote: > In preparation for implementing .bdrv_co_pwritev in qcow2. >=20 > Signed-off-by: Kevin Wolf > --- > block/qcow2-cluster.c | 32 ++++++++++++-------------------- > block/qcow2.h | 13 +++---------- > 2 files changed, 15 insertions(+), 30 deletions(-) >=20 > @@ -1192,25 +1191,20 @@ static int handle_alloc(BlockDriverState *bs, u= int64_t guest_offset, > /* > * Save info needed for meta data update. > * > - * requested_sectors: Number of sectors from the start of the firs= t > + * requested_sectors: Number of bytes from the start of the first This comment seems like an incomplete conversion. Is it sectors or bytes?= > - int requested_sectors =3D > - (*bytes + offset_into_cluster(s, guest_offset)) > - >> BDRV_SECTOR_BITS; > - int avail_sectors =3D nb_clusters > - << (s->cluster_bits - BDRV_SECTOR_BITS); > - int alloc_n_start =3D offset_into_cluster(s, guest_offset) > - >> BDRV_SECTOR_BITS; > - int nb_sectors =3D MIN(requested_sectors, avail_sectors); > + int requested_bytes =3D *bytes + offset_into_cluster(s, guest_offs= et); > + int avail_bytes =3D nb_clusters << s->cluster_bits; Can this ever overflow? Otherwise looks correct. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --OHRwVD0BMXPc8KSPTPXegQAeFLQWJruPQ 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/ iQEcBAEBCAAGBQJXUd4bAAoJEKeha0olJ0Nqp0MIAJhpzEFhJkDhDfl6fDm1MA/f W42+h+PHqYNjBVKmbuH04nQNwzYT4O14QeMPwxBzHeQ3ukvHqNdaYfg8PfQrvRNH vZup6U+i5zj3QnQFGTxfxB8r/rSEZdaqIpc/V2tztN2W5OXbNm5sWFL7Le7SAA2O CzjlHXK3ssAK9GHCOMjvBYkIiVlZzWNIw5rzTlSV66Raett1o4WoHWVrNIsG2Q4J /SkuhaPE7b5lvno12vphC/2sTTi438Rp4kj0CwvoAiosnOaVkuXqL+jQ8YV/IHnl bSfnA30m/ukMVEgJarB/XMrrHV7Zv3clNmwKQTpU6/BO1YSTozA+BoLKOc6ZfB8= =w7Iw -----END PGP SIGNATURE----- --OHRwVD0BMXPc8KSPTPXegQAeFLQWJruPQ--