From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAekH-0007xa-TY for qemu-devel@nongnu.org; Wed, 08 Jun 2016 10:46:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAekG-0000Za-Re for qemu-devel@nongnu.org; Wed, 08 Jun 2016 10:46:13 -0400 References: <1465395011-26088-1-git-send-email-kwolf@redhat.com> <1465395011-26088-4-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <57582FA8.8050704@redhat.com> Date: Wed, 8 Jun 2016 08:46:00 -0600 MIME-Version: 1.0 In-Reply-To: <1465395011-26088-4-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eavm7JvUDnFsfSN3eDnCoEnxWoUxm4JPg" Subject: Re: [Qemu-devel] [PATCH 3/6] block: Prepare bdrv_aligned_pwritev() for byte-aligned requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: pbonzini@redhat.com, mreitz@redhat.com, stefanha@redhat.com, famz@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --eavm7JvUDnFsfSN3eDnCoEnxWoUxm4JPg Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/08/2016 08:10 AM, Kevin Wolf wrote: > Signed-off-by: Kevin Wolf > --- > block/io.c | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) >=20 > diff --git a/block/io.c b/block/io.c > index 2fd88cb..4af9c59 100644 > --- a/block/io.c > +++ b/block/io.c > @@ -1241,11 +1241,9 @@ static int coroutine_fn bdrv_aligned_pwritev(Blo= ckDriverState *bs, > bool waited; > int ret; > =20 > - int64_t sector_num =3D offset >> BDRV_SECTOR_BITS; > - unsigned int nb_sectors =3D bytes >> BDRV_SECTOR_BITS; > + int64_t start_sector =3D offset >> BDRV_SECTOR_BITS; > + int64_t end_sector =3D DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SI= ZE); > =20 > - assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); > - assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); I wonder if we should add an 'unsigned int align' parameter to this function, to mirror bdrv_aligned_preadv() - that way, we can assert that any divisions we do based on 'align' are indeed aligned. If we do that, then just as in the previous patch, I think we would want to keep 'assert((offset & (align - 1)) =3D=3D 0)'. But at the moment, I don't se= e any divisions based on align, so I think you are okay. > if (ret >=3D 0) { > - bs->total_sectors =3D MAX(bs->total_sectors, sector_num + nb_s= ectors); > + bs->total_sectors =3D MAX(bs->total_sectors, end_sector); Someday, we may want bs->total_bytes instead of total_sectors, but unrelated to this patch. Looks clean: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --eavm7JvUDnFsfSN3eDnCoEnxWoUxm4JPg 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/ iQEcBAEBCAAGBQJXWC+oAAoJEKeha0olJ0NqlSQIAKOaxtBhj/owAkoqG+Grdwng IiIyxXrF0VWtszsoymOEdy3wPO/KfaRgBR8EYBlb3JNhKwF8bxy9URashQEb5xxm M/bAUp2+mXED+9ouHkR7JTBu3A8pWEBuUeT/erRt547NQUNXQxfDxq6KKHI5QVwZ 4aI9iPvAP4PCOTsX8QHC6OYdEWeXXKq8HshVtNpLORNt7UsWwUBlb0wf7Mj6DpyO UBxIWdg45As4NiBZDWdxAqCpDoCcWgCrdjRLRG6q93jSw/Rocx8H7ADkoK7NT5hY J+bExAfonHjEIfu+RgAJJXO9x2wRWOATZQlofMNdUf9vJt9oxJzOFIMAV3Q9UaY= =bWhA -----END PGP SIGNATURE----- --eavm7JvUDnFsfSN3eDnCoEnxWoUxm4JPg--