[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/28] block-backend: align max_transfer to request alignment
From: |
Paolo Bonzini |
Subject: |
[PULL 16/28] block-backend: align max_transfer to request alignment |
Date: |
Fri, 25 Jun 2021 16:18:10 +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
- [PULL 06/28] configure, meson: convert crypto detection to meson, (continued)
- [PULL 06/28] configure, meson: convert crypto detection to meson, Paolo Bonzini, 2021/06/25
- [PULL 09/28] configure, meson: convert libusb detection to meson, Paolo Bonzini, 2021/06/25
- [PULL 05/28] tests: remove QCRYPTO_HAVE_TLS_TEST_SUPPORT, Paolo Bonzini, 2021/06/25
- [PULL 08/28] configure, meson: convert pam detection to meson, Paolo Bonzini, 2021/06/25
- [PULL 10/28] configure, meson: convert libcacard detection to meson, Paolo Bonzini, 2021/06/25
- [PULL 11/28] configure, meson: convert libusbredir detection to meson, Paolo Bonzini, 2021/06/25
- [PULL 07/28] configure, meson: convert libtasn1 detection to meson, Paolo Bonzini, 2021/06/25
- [PULL 12/28] KVM: Fix dirty ring mmap incorrect size due to renaming accident, Paolo Bonzini, 2021/06/25
- [PULL 13/28] file-posix: fix max_iov for /dev/sg devices, Paolo Bonzini, 2021/06/25
- [PULL 14/28] scsi-generic: pass max_segments via max_iov field in BlockLimits, Paolo Bonzini, 2021/06/25
- [PULL 16/28] block-backend: align max_transfer to request alignment,
Paolo Bonzini <=
- [PULL 15/28] osdep: provide ROUND_DOWN macro, Paolo Bonzini, 2021/06/25
- [PULL 17/28] block: add max_hw_transfer to BlockLimits, Paolo Bonzini, 2021/06/25
- [PULL 18/28] file-posix: try BLKSECTGET on block devices too, do not round to power of 2, Paolo Bonzini, 2021/06/25
- [PULL 19/28] block: feature detection for host block support, Paolo Bonzini, 2021/06/25
- [PULL 21/28] block: try BSD disk size ioctls one after another, Paolo Bonzini, 2021/06/25
- [PULL 20/28] block: check for sys/disk.h, Paolo Bonzini, 2021/06/25
- [PULL 22/28] block: detect DKIOCGETBLOCKCOUNT/SIZE before use, Paolo Bonzini, 2021/06/25
- [PULL 23/28] file-posix: handle EINTR during ioctl, Paolo Bonzini, 2021/06/25
- [PULL 25/28] machine: move common smp_parse code to caller, Paolo Bonzini, 2021/06/25