Message ID | 1465395011-26088-7-git-send-email-kwolf@redhat.com |
---|---|
State | New |
Headers | show |
On 06/08/2016 08:10 AM, Kevin Wolf wrote: > If block drivers say that they can do an alignment < 512 bytes, let's > just suppose they mean it. raw-posix used to be an offender with respect > to this, but it can actually deal with byte-aligned requests now. > > The default is still 512 bytes for any drivers that only implement > sector-based interfaces, but it is 1 now for drivers that implement > .bdrv_co_preadv. > > Signed-off-by: Kevin Wolf <kwolf@redhat.com> > --- > block.c | 2 +- > block/io.c | 8 +++----- > 2 files changed, 4 insertions(+), 6 deletions(-) > Reviewed-by: Eric Blake <eblake@redhat.com>
On Wed, Jun 08, 2016 at 04:10:11PM +0200, Kevin Wolf wrote: > diff --git a/block.c b/block.c > index f54bc25..3d850a2 100644 > --- a/block.c > +++ b/block.c > @@ -937,7 +937,7 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, > goto fail_opts; > } > > - bs->request_alignment = 512; > + bs->request_alignment = drv->bdrv_co_preadv ? 1 : 512; What happens in the raw-posix.c AIO case? There we should still use 512. Stefan
Am 14.06.2016 um 14:09 hat Stefan Hajnoczi geschrieben: > On Wed, Jun 08, 2016 at 04:10:11PM +0200, Kevin Wolf wrote: > > diff --git a/block.c b/block.c > > index f54bc25..3d850a2 100644 > > --- a/block.c > > +++ b/block.c > > @@ -937,7 +937,7 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, > > goto fail_opts; > > } > > > > - bs->request_alignment = 512; > > + bs->request_alignment = drv->bdrv_co_preadv ? 1 : 512; > > What happens in the raw-posix.c AIO case? There we should still use > 512. I'm only changing the default value here. raw-posix already overrides bs->request_alignment as needed, see raw_probe_alignment(). Kevin
diff --git a/block.c b/block.c index f54bc25..3d850a2 100644 --- a/block.c +++ b/block.c @@ -937,7 +937,7 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, goto fail_opts; } - bs->request_alignment = 512; + bs->request_alignment = drv->bdrv_co_preadv ? 1 : 512; bs->zero_beyond_eof = true; bs->read_only = !(bs->open_flags & BDRV_O_RDWR); diff --git a/block/io.c b/block/io.c index 4af9c59..b3d6228 100644 --- a/block/io.c +++ b/block/io.c @@ -1044,8 +1044,7 @@ int coroutine_fn bdrv_co_preadv(BlockDriverState *bs, BlockDriver *drv = bs->drv; BdrvTrackedRequest req; - /* TODO Lift BDRV_SECTOR_SIZE restriction in BlockDriver interface */ - uint64_t align = MAX(BDRV_SECTOR_SIZE, bs->request_alignment); + uint64_t align = bs->request_alignment; uint8_t *head_buf = NULL; uint8_t *tail_buf = NULL; QEMUIOVector local_qiov; @@ -1296,7 +1295,7 @@ static int coroutine_fn bdrv_co_do_zero_pwritev(BlockDriverState *bs, uint8_t *buf = NULL; QEMUIOVector local_qiov; struct iovec iov; - uint64_t align = MAX(BDRV_SECTOR_SIZE, bs->request_alignment); + uint64_t align = bs->request_alignment; unsigned int head_padding_bytes, tail_padding_bytes; int ret = 0; @@ -1383,8 +1382,7 @@ int coroutine_fn bdrv_co_pwritev(BlockDriverState *bs, BdrvRequestFlags flags) { BdrvTrackedRequest req; - /* TODO Lift BDRV_SECTOR_SIZE restriction in BlockDriver interface */ - uint64_t align = MAX(BDRV_SECTOR_SIZE, bs->request_alignment); + uint64_t align = bs->request_alignment; uint8_t *head_buf = NULL; uint8_t *tail_buf = NULL; QEMUIOVector local_qiov;
If block drivers say that they can do an alignment < 512 bytes, let's just suppose they mean it. raw-posix used to be an offender with respect to this, but it can actually deal with byte-aligned requests now. The default is still 512 bytes for any drivers that only implement sector-based interfaces, but it is 1 now for drivers that implement .bdrv_co_preadv. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- block.c | 2 +- block/io.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-)