From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCSm5-0007IG-I3 for qemu-devel@nongnu.org; Mon, 13 Jun 2016 10:23:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCSm0-0003WH-8I for qemu-devel@nongnu.org; Mon, 13 Jun 2016 10:23:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36328) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCSm0-0003WC-08 for qemu-devel@nongnu.org; Mon, 13 Jun 2016 10:23:28 -0400 References: <1464686130-12265-1-git-send-email-den@openvz.org> <1464686130-12265-2-git-send-email-den@openvz.org> From: Eric Blake Message-ID: <575EC1DC.5020501@redhat.com> Date: Mon, 13 Jun 2016 08:23:24 -0600 MIME-Version: 1.0 In-Reply-To: <1464686130-12265-2-git-send-email-den@openvz.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VA4aTdhkGbG1fa4aO8LChOT447FRQPqBe" Subject: Re: [Qemu-devel] [PATCH 01/11] block: switch blk_write_compressed() to byte-based interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" , qemu-devel@nongnu.org Cc: Pavel Butsykin , Jeff Cody , Markus Armbruster , John Snow , Stefan Hajnoczi , Kevin Wolf This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --VA4aTdhkGbG1fa4aO8LChOT447FRQPqBe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/31/2016 03:15 AM, Denis V. Lunev wrote: > From: Pavel Butsykin >=20 > This is a preparatory patch, which continues the general trend of the t= ransition > to the byte-based interfaces. >=20 > Signed-off-by: Pavel Butsykin > Signed-off-by: Denis V. Lunev > CC: Jeff Cody > CC: Markus Armbruster > CC: Eric Blake > CC: John Snow > CC: Stefan Hajnoczi > CC: Kevin Wolf > --- > block/block-backend.c | 8 ++++---- > block/io.c | 9 +++++---- > include/block/block.h | 4 ++-- > include/sysemu/block-backend.h | 4 ++-- > qemu-img.c | 6 ++++-- > qemu-io-cmds.c | 2 +- > 6 files changed, 18 insertions(+), 15 deletions(-) >=20 > diff --git a/block/block-backend.c b/block/block-backend.c > index 34500e6..3c1fc50 100644 > --- a/block/block-backend.c > +++ b/block/block-backend.c > @@ -1477,15 +1477,15 @@ int coroutine_fn blk_co_pwrite_zeroes(BlockBack= end *blk, int64_t offset, > flags | BDRV_REQ_ZERO_WRITE); > } > =20 > -int blk_write_compressed(BlockBackend *blk, int64_t sector_num, > - const uint8_t *buf, int nb_sectors) > +int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const voi= d *buf, > + int count) Why are you switching the type of buf? It's not necessarily wrong, but the commit message should call it out as intentional. > -int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num, > - const uint8_t *buf, int nb_sectors) > +int bdrv_pwrite_compressed(BlockDriverState *bs, int64_t offset, > + const void *buf, int count) > { > BlockDriver *drv =3D bs->drv; > int ret; > @@ -1791,14 +1791,15 @@ int bdrv_write_compressed(BlockDriverState *bs,= int64_t sector_num, > if (!drv->bdrv_write_compressed) { > return -ENOTSUP; > } > - ret =3D bdrv_check_request(bs, sector_num, nb_sectors); > + ret =3D bdrv_check_byte_request(bs, offset, count); > if (ret < 0) { > return ret; > } > =20 > assert(QLIST_EMPTY(&bs->dirty_bitmaps)); > =20 > - return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors)= ; > + return drv->bdrv_write_compressed(bs, offset >> BDRV_SECTOR_BITS, = buf, > + count >> BDRV_SECTOR_BITS); If you are going to shift right, you need to first assert that offset and count are aligned (and thus that our call to a sector interface isn't going to operate on the wrong data). See for example commit 166fe9= 60. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --VA4aTdhkGbG1fa4aO8LChOT447FRQPqBe 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/ iQEcBAEBCAAGBQJXXsHdAAoJEKeha0olJ0NqtZsH/irZMsBQQbvuA0fBqxQo2LT4 mrHLA7l7WdJr3kbDWQaqAzIfYmCHEIPbGSdtY78eBRKxocHC5ta/l+AkIHiMTz93 3cdD8Ko8f3dBgcq+wzuK7ck4oHjZwtSHWcR4EcT0W2Klr3XoY/STpWnIShOgGigj +GetQfgAjAxC2MwpNWeqiJXIXvq5XfB/g6jIejL/3JLLtdw8TT/UayOAM9x9cC7N FXgj2VR7KsIP5gyBfL6JybK/IU3n5rK0qKnmi1GPzYCEO1dmQYmIF8TgvGY5D+Mw Uf85UREFiORs2x6WN1nosno+Z9fQCUw+mmZFoXPGvq+FbCstUadgrfrbRY0xozk= =kP/x -----END PGP SIGNATURE----- --VA4aTdhkGbG1fa4aO8LChOT447FRQPqBe--