@@ -309,18 +309,22 @@ enum storvsc_request_type {
309
309
*/
310
310
311
311
static int storvsc_ringbuffer_size = (256 * PAGE_SIZE );
312
+ static u32 max_outstanding_req_per_channel ;
313
+
314
+ static int storvsc_vcpus_per_sub_channel = 4 ;
312
315
313
316
module_param (storvsc_ringbuffer_size , int , S_IRUGO );
314
317
MODULE_PARM_DESC (storvsc_ringbuffer_size , "Ring buffer size (bytes)" );
315
318
319
+ module_param (storvsc_vcpus_per_sub_channel , int , S_IRUGO );
320
+ MODULE_PARM_DESC (vcpus_per_sub_channel , "Ratio of VCPUs to subchannels" );
316
321
/*
317
322
* Timeout in seconds for all devices managed by this driver.
318
323
*/
319
324
static int storvsc_timeout = 180 ;
320
325
321
326
static int msft_blist_flags = BLIST_TRY_VPD_PAGES ;
322
327
323
- #define STORVSC_MAX_IO_REQUESTS 200
324
328
325
329
static void storvsc_on_channel_callback (void * context );
326
330
@@ -1376,7 +1380,6 @@ static int storvsc_do_io(struct hv_device *device,
1376
1380
1377
1381
static int storvsc_device_configure (struct scsi_device * sdevice )
1378
1382
{
1379
- scsi_change_queue_depth (sdevice , STORVSC_MAX_IO_REQUESTS );
1380
1383
1381
1384
blk_queue_max_segment_size (sdevice -> request_queue , PAGE_SIZE );
1382
1385
@@ -1646,7 +1649,6 @@ static struct scsi_host_template scsi_driver = {
1646
1649
.eh_timed_out = storvsc_eh_timed_out ,
1647
1650
.slave_configure = storvsc_device_configure ,
1648
1651
.cmd_per_lun = 255 ,
1649
- .can_queue = STORVSC_MAX_IO_REQUESTS * STORVSC_MAX_TARGETS ,
1650
1652
.this_id = -1 ,
1651
1653
/* no use setting to 0 since ll_blk_rw reset it to 1 */
1652
1654
/* currently 32 */
@@ -1686,6 +1688,7 @@ static int storvsc_probe(struct hv_device *device,
1686
1688
const struct hv_vmbus_device_id * dev_id )
1687
1689
{
1688
1690
int ret ;
1691
+ int num_cpus = num_online_cpus ();
1689
1692
struct Scsi_Host * host ;
1690
1693
struct hv_host_device * host_dev ;
1691
1694
bool dev_is_ide = ((dev_id -> driver_data == IDE_GUID ) ? true : false);
@@ -1694,6 +1697,7 @@ static int storvsc_probe(struct hv_device *device,
1694
1697
int max_luns_per_target ;
1695
1698
int max_targets ;
1696
1699
int max_channels ;
1700
+ int max_sub_channels = 0 ;
1697
1701
1698
1702
/*
1699
1703
* Based on the windows host we are running on,
@@ -1719,12 +1723,18 @@ static int storvsc_probe(struct hv_device *device,
1719
1723
max_luns_per_target = STORVSC_MAX_LUNS_PER_TARGET ;
1720
1724
max_targets = STORVSC_MAX_TARGETS ;
1721
1725
max_channels = STORVSC_MAX_CHANNELS ;
1726
+ /*
1727
+ * On Windows8 and above, we support sub-channels for storage.
1728
+ * The number of sub-channels offerred is based on the number of
1729
+ * VCPUs in the guest.
1730
+ */
1731
+ max_sub_channels = (num_cpus / storvsc_vcpus_per_sub_channel );
1722
1732
break ;
1723
1733
}
1724
1734
1725
- if ( dev_id -> driver_data == SFC_GUID )
1726
- scsi_driver . can_queue = ( STORVSC_MAX_IO_REQUESTS *
1727
- STORVSC_FC_MAX_TARGETS );
1735
+ scsi_driver . can_queue = ( max_outstanding_req_per_channel *
1736
+ ( max_sub_channels + 1 ));
1737
+
1728
1738
host = scsi_host_alloc (& scsi_driver ,
1729
1739
sizeof (struct hv_host_device ));
1730
1740
if (!host )
@@ -1837,7 +1847,6 @@ static struct hv_driver storvsc_drv = {
1837
1847
1838
1848
static int __init storvsc_drv_init (void )
1839
1849
{
1840
- u32 max_outstanding_req_per_channel ;
1841
1850
1842
1851
/*
1843
1852
* Divide the ring buffer data size (which is 1 page less
@@ -1852,10 +1861,6 @@ static int __init storvsc_drv_init(void)
1852
1861
vmscsi_size_delta ,
1853
1862
sizeof (u64 )));
1854
1863
1855
- if (max_outstanding_req_per_channel <
1856
- STORVSC_MAX_IO_REQUESTS )
1857
- return - EINVAL ;
1858
-
1859
1864
return vmbus_driver_register (& storvsc_drv );
1860
1865
}
1861
1866
0 commit comments