48 lines
1.6 KiB
Diff
48 lines
1.6 KiB
Diff
|
From 643c979c2bfa0fc3c45ec8ec5f05a77e0b075356 Mon Sep 17 00:00:00 2001
|
||
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
||
|
Date: Fri, 16 Jul 2021 16:51:32 -0400
|
||
|
Subject: [PATCH 16/43] block-backend: align max_transfer to request alignment
|
||
|
|
||
|
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
|
||
|
RH-Bugzilla: 1957194
|
||
|
|
||
|
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 <pbonzini@redhat.com>
|
||
|
(cherry picked from commit b99f7fa08a3df8b8a6a907642e5851cdcf43fa9f)
|
||
|
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
||
|
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
||
|
---
|
||
|
block/block-backend.c | 6 +++---
|
||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/block/block-backend.c b/block/block-backend.c
|
||
|
index 05d8e5fb5d..136cc602c5 100644
|
||
|
--- a/block/block-backend.c
|
||
|
+++ b/block/block-backend.c
|
||
|
@@ -1943,12 +1943,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)
|
||
|
--
|
||
|
2.27.0
|
||
|
|