Received: from eggs.gnu.org ([2001:4830:134:3::10]:41598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHWpz-0000zP-S4 for qemu-devel@nongnu.org; Mon, 27 Jun 2016 09:44:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHWpx-0000dP-Kv for qemu-devel@nongnu.org; Mon, 27 Jun 2016 09:44:30 -0400 References: <1466500894-9710-1-git-send-email-kwolf@redhat.com> <1466500894-9710-13-git-send-email-kwolf@redhat.com> From: Max Reitz Message-ID: Date: Mon, 27 Jun 2016 15:44:21 +0200 MIME-Version: 1.0 In-Reply-To: <1466500894-9710-13-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="E7uu7QFBNEgUPLP0U4FoKBMF2IsqLTKTK" Subject: Re: [Qemu-devel] [PATCH 12/17] block: Convert bdrv_write() to BdrvChild List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: stefanha@redhat.com, famz@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --E7uu7QFBNEgUPLP0U4FoKBMF2IsqLTKTK From: Max Reitz To: Kevin Wolf , qemu-block@nongnu.org Cc: stefanha@redhat.com, famz@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org Message-ID: Subject: Re: [PATCH 12/17] block: Convert bdrv_write() to BdrvChild References: <1466500894-9710-1-git-send-email-kwolf@redhat.com> <1466500894-9710-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1466500894-9710-13-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 21.06.2016 11:21, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/io.c | 5 +++-- > block/qcow.c | 10 +++++++++- > block/qcow2-cluster.c | 2 +- > block/qcow2-refcount.c | 2 +- > block/qcow2.c | 10 +++++++++- > block/vdi.c | 4 ++-- > block/vvfat.c | 5 ++--- > include/block/block.h | 2 +- > 8 files changed, 28 insertions(+), 12 deletions(-) Because I think this is better than saying "I won't give an R-b because of (1), (2)..." at the bottom: Review key: [o] -- completely optional suggestion [r] -- request, optional, but I'll wait with an R-b until I get feedback [x] -- requires a fix [...] > diff --git a/block/qcow.c b/block/qcow.c > index e09827b..c80df78 100644 > --- a/block/qcow.c > +++ b/block/qcow.c > @@ -969,7 +969,15 @@ static int qcow_write_compressed(BlockDriverState = *bs, int64_t sector_num, > =20 > if (ret !=3D Z_STREAM_END || out_len >=3D s->cluster_size) { > /* could not compress: write normal cluster */ > - ret =3D bdrv_write(bs, sector_num, buf, s->cluster_sectors); > + QEMUIOVector qiov; > + struct iovec iov =3D { > + .iov_base =3D (uint8_t*) buf, [o] ERROR: "(foo*)" should be "(foo *)" !!11!1elf > + .iov_len =3D nb_sectors * BDRV_SECTOR_SIZE, > + }; > + qemu_iovec_init_external(&qiov, &iov, 1); > + > + ret =3D bs->drv->bdrv_co_writev(bs, sector_num, s->cluster_sec= tors, > + &qiov); [r] I'd use nb_sectors instead of s->cluster_sectors (or use s->cluster_sectors above), I think it should be the same variable in both places. [o] Also, but this is a much weaker proposal, I'd have preferred a direct call to qcow_co_writev(). But maybe that's just me. > if (ret < 0) { > goto fail; > } [...] > diff --git a/block/qcow2.c b/block/qcow2.c > index 4718f82..bc78af3 100644 > --- a/block/qcow2.c > +++ b/block/qcow2.c > @@ -2597,7 +2597,15 @@ static int qcow2_write_compressed(BlockDriverSta= te *bs, int64_t sector_num, > =20 > if (ret !=3D Z_STREAM_END || out_len >=3D s->cluster_size) { > /* could not compress: write normal cluster */ > - ret =3D bdrv_write(bs, sector_num, buf, s->cluster_sectors); > + QEMUIOVector qiov; > + struct iovec iov =3D { > + .iov_base =3D (uint8_t*) buf, [o] ERROR: "(foo*)" should be "(foo *)" > + .iov_len =3D nb_sectors * BDRV_SECTOR_SIZE, > + }; > + qemu_iovec_init_external(&qiov, &iov, 1); > + > + ret =3D bs->drv->bdrv_co_writev(bs, sector_num, s->cluster_sec= tors, > + &qiov); [x] I don't think qcow2 has a bdrv_co_writev(). ($ dd if=3D/dev/urandom of=3Dfoo.raw bs=3D64k count=3D1 $ ./qemu-img convert -c -O qcow2 foo.raw foo.qcow2 [1] 11808 segmentation fault (core dumped)) [r] Same as in qcow.c, I'd rather use nb_sectors instead of s->cluster_sectors. [o] Same as in qcow.c, I'd call qcow2_co_pwritev() directly. Doing so would have prevented [x]. Max > if (ret < 0) { > goto fail; > } --E7uu7QFBNEgUPLP0U4FoKBMF2IsqLTKTK 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 iQEvBAEBCAAZBQJXcS21EhxtcmVpdHpAcmVkaGF0LmNvbQAKCRA7sUIC6DisrRNH B/0VoGMlMH6lIe7oOol1BrwNreB9zFMWDwJkTnsCPhHE1kpoNlibsCIvMlJYoRsW axHLlbWbC51gfwFTo8Hq3kZpY1FnmO0g18+5kF421nsXVgwi9HQtBnHlZCi00OUT wsVR/c8TbqnLjDB8ucN28lPpVZhFKeOxkQ+JX3gS/zdUevxQzEw4jP9pTsOajo/r Hjly7K0XxFvHql/VnefksIht5NmDmIOJL+B4dySt+490aMuA3YtgJMWgp1RFUFkh WHSIY+fEtOZj9BmWnm+Ul0YhR6pWDTuPD7n/HTwEz3be1iuPohUvUi6yexYhchm7 xzrM2gueXjeVP3g6MLv7drq9 =K6uZ -----END PGP SIGNATURE----- --E7uu7QFBNEgUPLP0U4FoKBMF2IsqLTKTK--