From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAeY4-0004Ld-2V for qemu-devel@nongnu.org; Wed, 08 Jun 2016 10:33:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAeY1-0004bJ-UD for qemu-devel@nongnu.org; Wed, 08 Jun 2016 10:33:35 -0400 References: <1465395011-26088-1-git-send-email-kwolf@redhat.com> <1465395011-26088-3-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <57582CAC.2080105@redhat.com> Date: Wed, 8 Jun 2016 08:33:16 -0600 MIME-Version: 1.0 In-Reply-To: <1465395011-26088-3-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gx96lCIv2et9o5Cdario77fa5DewmgJe1" Subject: Re: [Qemu-devel] [PATCH 2/6] block: Prepare bdrv_aligned_preadv() 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) --gx96lCIv2et9o5Cdario77fa5DewmgJe1 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/08/2016 08:10 AM, Kevin Wolf wrote: > This patch makes bdrv_aligned_preadv() ready to accept byte-aligned > requests. Note that this doesn't mean that such requests are actually > made. The caller still ensures that all requests are aligned to at leas= t > 512 bytes. >=20 > Signed-off-by: Kevin Wolf > --- > block/io.c | 41 +++++++++++++++++------------------------ > 1 file changed, 17 insertions(+), 24 deletions(-) >=20 > diff --git a/block/io.c b/block/io.c > index 3b34f20..2fd88cb 100644 > --- a/block/io.c > +++ b/block/io.c > @@ -959,11 +959,6 @@ static int coroutine_fn bdrv_aligned_preadv(BlockD= riverState *bs, > { > int ret; > =20 > - int64_t sector_num =3D offset >> BDRV_SECTOR_BITS; > - unsigned int nb_sectors =3D bytes >> BDRV_SECTOR_BITS; > - > - assert((offset & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); > - assert((bytes & (BDRV_SECTOR_SIZE - 1)) =3D=3D 0); My recent patch proposal conflicts here; I can drop (or rebase) mine, but I think you want to keep the asserts, after modifying them to: assert((offset & (align - 1)) =3D=3D 0); assert((bytes & (align - 1)) =3D=3D 0); and maybe add 'assert(is_power_of_2(align)); for good measure. > =20 > - max_nb_sectors =3D ROUND_UP(MAX(0, total_sectors - sector_num)= , > - align >> BDRV_SECTOR_BITS); > - if (nb_sectors < max_nb_sectors) { > + max_bytes =3D ROUND_UP(MAX(0, total_bytes - offset), align); > + if (bytes < max_bytes) { Another one of my posted patches switches this to <=3D to avoid a harmles= s off-by-one, also something I can rebase. Whether you add the assertions, or leave it for me to (re-)add them in my rebase, Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --gx96lCIv2et9o5Cdario77fa5DewmgJe1 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/ iQEcBAEBCAAGBQJXWCysAAoJEKeha0olJ0Nq0Q8H/0m9ZeqY5nU8n5WsY9xzxHc0 1KWWHyYiMGDJ8DJ3h6k5yBwLJVo3Q/T7ZQ4jb3eRta4nNut46shUZWWeuyNqJshk H2/GgO+B/tQv0kYnd8e/8xgjQvmNZ49QVUmKa4FgqrN10PfViTeOGLRW+NgPeQ/p mihJKzohRAyCbExTGw2/a4gARfcYRxb56L5XfvDbWoWoy7jZ/165WRKvysCVfTLD PWVDGpDWJGtPTK0YtWpZtfGTCT9GiXFIm503n+xrti6fMnd4AAjmF34hDqNtwLAv gN7cLW6XHKugpeZSZuXqWuQv+CwhO5wBbqh35NsK5MSNY2QB9joyFzkey9FZlCE= =GWGw -----END PGP SIGNATURE----- --gx96lCIv2et9o5Cdario77fa5DewmgJe1--