[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/11] block-backend: align max_transfer to request alignment
From: |
Paolo Bonzini |
Subject: |
[PATCH 04/11] block-backend: align max_transfer to request alignment |
Date: |
Thu, 24 Jun 2021 20:04:16 +0200 |
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>
---
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 15f1ea4288..6e37582740 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1957,12 +1957,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.31.1
- [PATCH v5 00/11] block: file-posix queue, Paolo Bonzini, 2021/06/24
- [PATCH 01/11] file-posix: fix max_iov for /dev/sg devices, Paolo Bonzini, 2021/06/24
- [PATCH 03/11] osdep: provide ROUND_DOWN macro, Paolo Bonzini, 2021/06/24
- [PATCH 04/11] block-backend: align max_transfer to request alignment,
Paolo Bonzini <=
- [PATCH 02/11] scsi-generic: pass max_segments via max_iov field in BlockLimits, Paolo Bonzini, 2021/06/24
- [PATCH 05/11] block: add max_hw_transfer to BlockLimits, Paolo Bonzini, 2021/06/24
- [PATCH 10/11] block: detect DKIOCGETBLOCKCOUNT/SIZE before use, Paolo Bonzini, 2021/06/24
- [PATCH 09/11] block: try BSD disk size ioctls one after another, Paolo Bonzini, 2021/06/24
- [PATCH 11/11] file-posix: handle EINTR during ioctl, Paolo Bonzini, 2021/06/24