|
|
a83cc2 |
From 05038edf628c6bca7cef061b7b1fac2b0b2163af Mon Sep 17 00:00:00 2001
|
|
|
a83cc2 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
a83cc2 |
Date: Fri, 16 Jul 2021 16:51:30 -0400
|
|
|
a83cc2 |
Subject: [PATCH 14/43] scsi-generic: pass max_segments via max_iov field in
|
|
|
a83cc2 |
BlockLimits
|
|
|
a83cc2 |
|
|
|
a83cc2 |
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
RH-Bugzilla: 1957194
|
|
|
a83cc2 |
|
|
|
a83cc2 |
I/O to a disk via read/write is not limited by the number of segments allowed
|
|
|
a83cc2 |
by the host adapter; the kernel can split requests if needed, and the limit
|
|
|
a83cc2 |
imposed by the host adapter can be very low (256k or so) to avoid that SG_IO
|
|
|
a83cc2 |
returns EINVAL if memory is heavily fragmented.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Since this value is only interesting for SG_IO-based I/O, do not include
|
|
|
a83cc2 |
it in the max_transfer and only take it into account when patching the
|
|
|
a83cc2 |
block limits VPD page in the scsi-generic device.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
a83cc2 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
a83cc2 |
(cherry picked from commit 01ef8185b809af9d287e1a03a3f9d8ea8231118a)
|
|
|
a83cc2 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
---
|
|
|
a83cc2 |
block/file-posix.c | 3 +--
|
|
|
a83cc2 |
hw/scsi/scsi-generic.c | 6 ++++--
|
|
|
a83cc2 |
2 files changed, 5 insertions(+), 4 deletions(-)
|
|
|
a83cc2 |
|
|
|
a83cc2 |
diff --git a/block/file-posix.c b/block/file-posix.c
|
|
|
a83cc2 |
index 74d4903dc1..1a6c799e19 100644
|
|
|
a83cc2 |
--- a/block/file-posix.c
|
|
|
a83cc2 |
+++ b/block/file-posix.c
|
|
|
a83cc2 |
@@ -1263,8 +1263,7 @@ static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
|
|
|
a83cc2 |
|
|
|
a83cc2 |
ret = sg_get_max_segments(s->fd);
|
|
|
a83cc2 |
if (ret > 0) {
|
|
|
a83cc2 |
- bs->bl.max_transfer = MIN(bs->bl.max_transfer,
|
|
|
a83cc2 |
- ret * qemu_real_host_page_size);
|
|
|
a83cc2 |
+ bs->bl.max_iov = ret;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
|
|
|
a83cc2 |
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
|
|
|
a83cc2 |
index 98c30c5d5c..82e1e2ee79 100644
|
|
|
a83cc2 |
--- a/hw/scsi/scsi-generic.c
|
|
|
a83cc2 |
+++ b/hw/scsi/scsi-generic.c
|
|
|
a83cc2 |
@@ -179,10 +179,12 @@ static void scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s)
|
|
|
a83cc2 |
(r->req.cmd.buf[1] & 0x01)) {
|
|
|
a83cc2 |
page = r->req.cmd.buf[2];
|
|
|
a83cc2 |
if (page == 0xb0) {
|
|
|
a83cc2 |
- uint32_t max_transfer =
|
|
|
a83cc2 |
- blk_get_max_transfer(s->conf.blk) / s->blocksize;
|
|
|
a83cc2 |
+ uint32_t max_transfer = blk_get_max_transfer(s->conf.blk);
|
|
|
a83cc2 |
+ uint32_t max_iov = blk_get_max_iov(s->conf.blk);
|
|
|
a83cc2 |
|
|
|
a83cc2 |
assert(max_transfer);
|
|
|
a83cc2 |
+ max_transfer = MIN_NON_ZERO(max_transfer, max_iov * qemu_real_host_page_size)
|
|
|
a83cc2 |
+ / s->blocksize;
|
|
|
a83cc2 |
stl_be_p(&r->buf[8], max_transfer);
|
|
|
a83cc2 |
/* Also take care of the opt xfer len. */
|
|
|
a83cc2 |
stl_be_p(&r->buf[12],
|
|
|
a83cc2 |
--
|
|
|
a83cc2 |
2.27.0
|
|
|
a83cc2 |
|