The NBD protocol would like to advertise the optimal I/O size to the client; but it would be a layering violation to peek into blk_bs(blk)->bl, when we only have a BB.
I just copied the existing blk_get_max_transfer_length() in reading a value from the top BDS; I have no idea if bdrv_refresh_limits() properly picks a size valid over the entire BDS chain as part of its recursion, but if not, it would be audit of existing code in addition to the new accessor function added here. Signed-off-by: Eric Blake <ebl...@redhat.com> --- include/sysemu/block-backend.h | 1 + block/block-backend.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index bf04086..76b3647 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -145,6 +145,7 @@ void blk_lock_medium(BlockBackend *blk, bool locked); void blk_eject(BlockBackend *blk, bool eject_flag); int blk_get_flags(BlockBackend *blk); int blk_get_max_transfer_length(BlockBackend *blk); +int blk_get_opt_transfer_length(BlockBackend *blk); int blk_get_max_iov(BlockBackend *blk); void blk_set_guest_block_size(BlockBackend *blk, int align); void *blk_try_blockalign(BlockBackend *blk, size_t size); diff --git a/block/block-backend.c b/block/block-backend.c index 1c3b495..e76e61d 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1272,6 +1272,17 @@ int blk_get_max_transfer_length(BlockBackend *blk) } } +int blk_get_opt_transfer_length(BlockBackend *blk) +{ + BlockDriverState *bs = blk_bs(blk); + + if (bs) { + return bs->bl.opt_transfer_length; + } else { + return 0; + } +} + int blk_get_max_iov(BlockBackend *blk) { return blk->root->bs->bl.max_iov; -- 2.5.5