From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA28U-000770-ME for qemu-devel@nongnu.org; Mon, 06 Jun 2016 17:32:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bA28S-0001kC-Gr for qemu-devel@nongnu.org; Mon, 06 Jun 2016 17:32:37 -0400 References: <1465225155-18661-1-git-send-email-kwolf@redhat.com> <1465225155-18661-3-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <5755EBED.2070400@redhat.com> Date: Mon, 6 Jun 2016 15:32:29 -0600 MIME-Version: 1.0 In-Reply-To: <1465225155-18661-3-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PfCr61fSL0r2lBumBWJw0x8ijTXGpLtVA" Subject: Re: [Qemu-devel] [PATCH v2 2/5] qcow2: Implement .bdrv_co_preadv() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: mreitz@redhat.com, jsnow@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PfCr61fSL0r2lBumBWJw0x8ijTXGpLtVA Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/06/2016 08:59 AM, Kevin Wolf wrote: > Reading from qcow2 images is now byte granularity. >=20 > Most of the affected code in qcow2 actually gets simpler with this > change. The only exception is encryption, which is fixed on 512 bytes > blocks; in order to keep this working, bs->request_alignment is set for= > encrypted images. >=20 > Signed-off-by: Kevin Wolf > --- > block/qcow2-cluster.c | 27 ++++++------- > block/qcow2.c | 108 +++++++++++++++++++++++++++---------------= -------- > block/qcow2.h | 2 +- > 3 files changed, 72 insertions(+), 65 deletions(-) >=20 > - * on exit, *num is the number of contiguous sectors we can read. > + * On exit, *bytes is the number of bytes staring at offset that have = the same s/staring/starting/ (although "staring" does make for a rather interesting thought :) > @@ -1389,26 +1402,24 @@ static coroutine_fn int qcow2_co_readv(BlockDri= verState *bs, int64_t sector_num, > =20 > qemu_co_mutex_lock(&s->lock); > =20 > - while (remaining_sectors !=3D 0) { > + while (bytes !=3D 0) { > =20 > /* prepare next request */ > - cur_nr_sectors =3D remaining_sectors; > + cur_bytes =3D MIN(bytes, INT_MAX); > if (s->cipher) { > - cur_nr_sectors =3D MIN(cur_nr_sectors, > - QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors); > + cur_bytes =3D MIN(cur_bytes, > + QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size)= ; > } Can this ever result in cur_bytes that is not aligned, even though encryption requires aligned reads? Do you need to round anything to a sector boundary in this case? > qemu_co_mutex_unlock(&s->lock); > - ret =3D bdrv_co_readv(bs->file->bs, > - (cluster_offset >> 9) + index_in_clust= er, > - cur_nr_sectors, &hd_qiov); > + ret =3D bdrv_co_preadv(bs->file->bs, > + cluster_offset + offset_in_cluster, > + cur_bytes, &hd_qiov, 0); > qemu_co_mutex_lock(&s->lock); > if (ret < 0) { > goto fail; > } > if (bs->encrypted) { > assert(s->cipher); > + assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); > + assert((cur_bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0);= Hmm, you do check that later on. So, other than the typo (easy to fix on commit), Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --PfCr61fSL0r2lBumBWJw0x8ijTXGpLtVA 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/ iQEcBAEBCAAGBQJXVevtAAoJEKeha0olJ0NqOEcH/0txHWtb1v3950RoYf8uoptF nkLjCNNoPTM45A8cC+Q8vi7YcP1C9+s9Ki41A7Na++pOgNepgbNnvIMRgMnY7kWP 7lG5d8OxXzPTPfV02OViqFmqSOELA0PUS6U2SLTil3HUi05fjpMOqH81FBQIl4Kb Y5mFK80d9frZwXV+Gn/3GY/hNhpb7xIuqsJenJWs5hCph/CakLNfYk16WgxMkLUc JLNo4qeSj0TH1B0JRsKaPQsSXgD1/NXTaKGVMW2g2IFb1HBzGneCOybpFqfffS/w gWFSEtS5aKpJpsWyl+qXHcj3qvtMMAD0WVMkNhUWusJsGjIBx6uhcTipaqH2H3Y= =zm56 -----END PGP SIGNATURE----- --PfCr61fSL0r2lBumBWJw0x8ijTXGpLtVA--