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 least > 512 bytes. > > Signed-off-by: Kevin Wolf <kw...@redhat.com> > --- > block/io.c | 41 +++++++++++++++++------------------------ > 1 file changed, 17 insertions(+), 24 deletions(-) > > 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(BlockDriverState *bs, > { > int ret; > > - int64_t sector_num = offset >> BDRV_SECTOR_BITS; > - unsigned int nb_sectors = bytes >> BDRV_SECTOR_BITS; > - > - assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); > - assert((bytes & (BDRV_SECTOR_SIZE - 1)) == 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)) == 0); assert((bytes & (align - 1)) == 0); and maybe add 'assert(is_power_of_2(align)); for good measure. > > - max_nb_sectors = ROUND_UP(MAX(0, total_sectors - sector_num), > - align >> BDRV_SECTOR_BITS); > - if (nb_sectors < max_nb_sectors) { > + max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align); > + if (bytes < max_bytes) { Another one of my posted patches switches this to <= to avoid a harmless 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 <ebl...@redhat.com> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature