Skip to content

Commit 010c1e1

Browse files
kelleymhmartinkpetersen
authored andcommitted
scsi: storvsc: Limit max_sectors for virtual Fibre Channel devices
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: 1d3e098 ("scsi: storvsc: Correct reporting of Hyper-V I/O size limits") Cc: stable@vger.kernel.org Signed-off-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/1689887102-32806-1-git-send-email-mikelley@microsoft.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 80b6051 commit 010c1e1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/scsi/storvsc_drv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ static void storvsc_on_channel_callback(void *context);
366366
#define STORVSC_FC_MAX_LUNS_PER_TARGET 255
367367
#define STORVSC_FC_MAX_TARGETS 128
368368
#define STORVSC_FC_MAX_CHANNELS 8
369+
#define STORVSC_FC_MAX_XFER_SIZE ((u32)(512 * 1024))
369370

370371
#define STORVSC_IDE_MAX_LUNS_PER_TARGET 64
371372
#define STORVSC_IDE_MAX_TARGETS 1
@@ -2006,6 +2007,9 @@ static int storvsc_probe(struct hv_device *device,
20062007
* protecting it from any weird value.
20072008
*/
20082009
max_xfer_bytes = round_down(stor_device->max_transfer_bytes, HV_HYP_PAGE_SIZE);
2010+
if (is_fc)
2011+
max_xfer_bytes = min(max_xfer_bytes, STORVSC_FC_MAX_XFER_SIZE);
2012+
20092013
/* max_hw_sectors_kb */
20102014
host->max_sectors = max_xfer_bytes >> 9;
20112015
/*

0 commit comments

Comments
 (0)