From: Lin Ma Date: Mon, 13 Sep 2021 09:07:37 +0000 (+0800) Subject: block-backend: align max_transfer to request alignment X-Git-Tag: upstream/4.2.1~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4b94c1bbc3703407c110ab2eef2600d83e8647e4;p=tools%2Fqemu-arm-static.git block-backend: align max_transfer to request alignment Git-commit: b99f7fa08a3df8b8a6a907642e5851cdcf43fa9f References: bsc#1190425 Block device requests must be aligned to bs->bl.request_alignment. It makes sense for drivers to align bs->bl.max_transfer the same way; however when there is no specified limit, blk_get_max_transfer just returns INT_MAX. Since the contract of the function does not specify that INT_MAX means "no maximum", just align the outcome of the function (whether INT_MAX or bs->bl.max_transfer) before returning it. Signed-off-by: Paolo Bonzini Signed-off-by: Lin Ma --- diff --git a/block/block-backend.c b/block/block-backend.c index 8b8f2a80a..5344126d1 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1829,12 +1829,12 @@ uint32_t blk_get_request_alignment(BlockBackend *blk) uint32_t blk_get_max_transfer(BlockBackend *blk) { BlockDriverState *bs = blk_bs(blk); - uint32_t max = 0; + uint32_t max = INT_MAX; if (bs) { - max = bs->bl.max_transfer; + max = MIN_NON_ZERO(max, bs->bl.max_transfer); } - return MIN_NON_ZERO(max, INT_MAX); + return ROUND_DOWN(max, blk_get_request_alignment(blk)); } int blk_get_max_iov(BlockBackend *blk)