|
|
a83cc2 |
From 643c979c2bfa0fc3c45ec8ec5f05a77e0b075356 Mon Sep 17 00:00:00 2001
|
|
|
a83cc2 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
a83cc2 |
Date: Fri, 16 Jul 2021 16:51:32 -0400
|
|
|
a83cc2 |
Subject: [PATCH 16/43] block-backend: align max_transfer to request alignment
|
|
|
a83cc2 |
|
|
|
a83cc2 |
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
RH-Bugzilla: 1957194
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Block device requests must be aligned to bs->bl.request_alignment.
|
|
|
a83cc2 |
It makes sense for drivers to align bs->bl.max_transfer the same
|
|
|
a83cc2 |
way; however when there is no specified limit, blk_get_max_transfer
|
|
|
a83cc2 |
just returns INT_MAX. Since the contract of the function does not
|
|
|
a83cc2 |
specify that INT_MAX means "no maximum", just align the outcome
|
|
|
a83cc2 |
of the function (whether INT_MAX or bs->bl.max_transfer) before
|
|
|
a83cc2 |
returning it.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
a83cc2 |
(cherry picked from commit b99f7fa08a3df8b8a6a907642e5851cdcf43fa9f)
|
|
|
a83cc2 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
---
|
|
|
a83cc2 |
block/block-backend.c | 6 +++---
|
|
|
a83cc2 |
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
a83cc2 |
|
|
|
a83cc2 |
diff --git a/block/block-backend.c b/block/block-backend.c
|
|
|
a83cc2 |
index 05d8e5fb5d..136cc602c5 100644
|
|
|
a83cc2 |
--- a/block/block-backend.c
|
|
|
a83cc2 |
+++ b/block/block-backend.c
|
|
|
a83cc2 |
@@ -1943,12 +1943,12 @@ uint32_t blk_get_request_alignment(BlockBackend *blk)
|
|
|
a83cc2 |
uint32_t blk_get_max_transfer(BlockBackend *blk)
|
|
|
a83cc2 |
{
|
|
|
a83cc2 |
BlockDriverState *bs = blk_bs(blk);
|
|
|
a83cc2 |
- uint32_t max = 0;
|
|
|
a83cc2 |
+ uint32_t max = INT_MAX;
|
|
|
a83cc2 |
|
|
|
a83cc2 |
if (bs) {
|
|
|
a83cc2 |
- max = bs->bl.max_transfer;
|
|
|
a83cc2 |
+ max = MIN_NON_ZERO(max, bs->bl.max_transfer);
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
- return MIN_NON_ZERO(max, INT_MAX);
|
|
|
a83cc2 |
+ return ROUND_DOWN(max, blk_get_request_alignment(blk));
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
int blk_get_max_iov(BlockBackend *blk)
|
|
|
a83cc2 |
--
|
|
|
a83cc2 |
2.27.0
|
|
|
a83cc2 |
|