* [PATCH 1/1] scsi: storvsc: Limit max_sectors for virtual Fibre Channel devices
@ 2023-07-20 21:05 Michael Kelley
2023-07-23 20:42 ` Martin K. Petersen
0 siblings, 1 reply; 2+ messages in thread
From: Michael Kelley @ 2023-07-20 21:05 UTC (permalink / raw)
To: kys, martin.petersen, longli, wei.liu, decui, jejb, linux-hyperv,
linux-kernel, linux-scsi
Cc: mikelley, stable
The Hyper-V host is queried to get the max transfer size that it
supports, and this value is used to set max_sectors for the synthetic
SCSI controller. However, this max transfer size may be too large
for virtual Fibre Channel devices, which are limited to 512 Kbytes.
If a larger transfer size is used with a vFC device, Hyper-V always
returns an error, and storvsc logs a message like this where the SRB
status and SCSI status are both zero:
hv_storvsc <GUID>: tag#197 cmd 0x8a status: scsi 0x0 srb 0x0 hv 0xc0000001
Add logic to limit the max transfer size to 512 Kbytes for vFC devices.
Fixes: 1d3e0980782f ("scsi: storvsc: Correct reporting of Hyper-V I/O size limits")
Cc: stable@vger.kernel.org
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
---
drivers/scsi/storvsc_drv.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 7f12d93..f282321 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -366,6 +366,7 @@ enum storvsc_request_type {
#define STORVSC_FC_MAX_LUNS_PER_TARGET 255
#define STORVSC_FC_MAX_TARGETS 128
#define STORVSC_FC_MAX_CHANNELS 8
+#define STORVSC_FC_MAX_XFER_SIZE ((u32)(512 * 1024))
#define STORVSC_IDE_MAX_LUNS_PER_TARGET 64
#define STORVSC_IDE_MAX_TARGETS 1
@@ -2006,6 +2007,9 @@ static int storvsc_probe(struct hv_device *device,
* protecting it from any weird value.
*/
max_xfer_bytes = round_down(stor_device->max_transfer_bytes, HV_HYP_PAGE_SIZE);
+ if (is_fc)
+ max_xfer_bytes = min(max_xfer_bytes, STORVSC_FC_MAX_XFER_SIZE);
+
/* max_hw_sectors_kb */
host->max_sectors = max_xfer_bytes >> 9;
/*
--
1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] scsi: storvsc: Limit max_sectors for virtual Fibre Channel devices
2023-07-20 21:05 [PATCH 1/1] scsi: storvsc: Limit max_sectors for virtual Fibre Channel devices Michael Kelley
@ 2023-07-23 20:42 ` Martin K. Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2023-07-23 20:42 UTC (permalink / raw)
To: kys, longli, wei.liu, decui, jejb, linux-hyperv, linux-kernel,
linux-scsi, Michael Kelley
Cc: Martin K . Petersen, stable
On Thu, 20 Jul 2023 14:05:02 -0700, Michael Kelley wrote:
> The Hyper-V host is queried to get the max transfer size that it
> supports, and this value is used to set max_sectors for the synthetic
> SCSI controller. However, this max transfer size may be too large
> for virtual Fibre Channel devices, which are limited to 512 Kbytes.
> If a larger transfer size is used with a vFC device, Hyper-V always
> returns an error, and storvsc logs a message like this where the SRB
> status and SCSI status are both zero:
>
> [...]
Applied to 6.5/scsi-fixes, thanks!
[1/1] scsi: storvsc: Limit max_sectors for virtual Fibre Channel devices
https://git.kernel.org/mkp/scsi/c/010c1e1c5741
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-23 20:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-20 21:05 [PATCH 1/1] scsi: storvsc: Limit max_sectors for virtual Fibre Channel devices Michael Kelley
2023-07-23 20:42 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®