From 24ce9a20260713e86377cfa78fb8699335759f4f Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 23 Jun 2016 16:37:12 -0600 Subject: block: Give nonzero result to blk_get_max_transfer_length() Making all callers special-case 0 as unlimited is awkward, and we DO have a hard maximum of BDRV_REQUEST_MAX_SECTORS given our current block layer API limits. In the case of scsi, this means that we now always advertise a limit to the guest, even in cases where the underlying layers previously use 0 for no inherent limit beyond the block layer. Signed-off-by: Eric Blake Reviewed-by: Kevin Wolf Reviewed-by: Fam Zheng Signed-off-by: Kevin Wolf --- block/block-backend.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'block/block-backend.c') diff --git a/block/block-backend.c b/block/block-backend.c index 34500e6080..1fb070b4e4 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1303,15 +1303,16 @@ int blk_get_flags(BlockBackend *blk) } } +/* Returns the maximum transfer length, in sectors; guaranteed nonzero */ int blk_get_max_transfer_length(BlockBackend *blk) { BlockDriverState *bs = blk_bs(blk); + int max = 0; if (bs) { - return bs->bl.max_transfer_length; - } else { - return 0; + max = bs->bl.max_transfer_length; } + return MIN_NON_ZERO(max, BDRV_REQUEST_MAX_SECTORS); } int blk_get_max_iov(BlockBackend *blk) -- cgit v1.2.3