Skip to content

Commit f458aad

Browse files
kattisrinivasanJames Bottomley
authored and
James Bottomley
committed
scsi: storvsc: Size the queue depth based on the ringbuffer size
Size the queue depth based on the ringbuffer size. Also accommodate for the fact that we could have multiple channels (ringbuffers) per adaptor. Signed-off-by: K. Y. Srinivasan <[email protected]> Reviewed-by: Long Li <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent b9ec3a5 commit f458aad

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Diff for: drivers/scsi/storvsc_drv.c

+16-11
Original file line numberDiff line numberDiff line change
@@ -309,18 +309,22 @@ enum storvsc_request_type {
309309
*/
310310

311311
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;
312315

313316
module_param(storvsc_ringbuffer_size, int, S_IRUGO);
314317
MODULE_PARM_DESC(storvsc_ringbuffer_size, "Ring buffer size (bytes)");
315318

319+
module_param(storvsc_vcpus_per_sub_channel, int, S_IRUGO);
320+
MODULE_PARM_DESC(vcpus_per_sub_channel, "Ratio of VCPUs to subchannels");
316321
/*
317322
* Timeout in seconds for all devices managed by this driver.
318323
*/
319324
static int storvsc_timeout = 180;
320325

321326
static int msft_blist_flags = BLIST_TRY_VPD_PAGES;
322327

323-
#define STORVSC_MAX_IO_REQUESTS 200
324328

325329
static void storvsc_on_channel_callback(void *context);
326330

@@ -1376,7 +1380,6 @@ static int storvsc_do_io(struct hv_device *device,
13761380

13771381
static int storvsc_device_configure(struct scsi_device *sdevice)
13781382
{
1379-
scsi_change_queue_depth(sdevice, STORVSC_MAX_IO_REQUESTS);
13801383

13811384
blk_queue_max_segment_size(sdevice->request_queue, PAGE_SIZE);
13821385

@@ -1646,7 +1649,6 @@ static struct scsi_host_template scsi_driver = {
16461649
.eh_timed_out = storvsc_eh_timed_out,
16471650
.slave_configure = storvsc_device_configure,
16481651
.cmd_per_lun = 255,
1649-
.can_queue = STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS,
16501652
.this_id = -1,
16511653
/* no use setting to 0 since ll_blk_rw reset it to 1 */
16521654
/* currently 32 */
@@ -1686,6 +1688,7 @@ static int storvsc_probe(struct hv_device *device,
16861688
const struct hv_vmbus_device_id *dev_id)
16871689
{
16881690
int ret;
1691+
int num_cpus = num_online_cpus();
16891692
struct Scsi_Host *host;
16901693
struct hv_host_device *host_dev;
16911694
bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false);
@@ -1694,6 +1697,7 @@ static int storvsc_probe(struct hv_device *device,
16941697
int max_luns_per_target;
16951698
int max_targets;
16961699
int max_channels;
1700+
int max_sub_channels = 0;
16971701

16981702
/*
16991703
* Based on the windows host we are running on,
@@ -1719,12 +1723,18 @@ static int storvsc_probe(struct hv_device *device,
17191723
max_luns_per_target = STORVSC_MAX_LUNS_PER_TARGET;
17201724
max_targets = STORVSC_MAX_TARGETS;
17211725
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);
17221732
break;
17231733
}
17241734

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+
17281738
host = scsi_host_alloc(&scsi_driver,
17291739
sizeof(struct hv_host_device));
17301740
if (!host)
@@ -1837,7 +1847,6 @@ static struct hv_driver storvsc_drv = {
18371847

18381848
static int __init storvsc_drv_init(void)
18391849
{
1840-
u32 max_outstanding_req_per_channel;
18411850

18421851
/*
18431852
* Divide the ring buffer data size (which is 1 page less
@@ -1852,10 +1861,6 @@ static int __init storvsc_drv_init(void)
18521861
vmscsi_size_delta,
18531862
sizeof(u64)));
18541863

1855-
if (max_outstanding_req_per_channel <
1856-
STORVSC_MAX_IO_REQUESTS)
1857-
return -EINVAL;
1858-
18591864
return vmbus_driver_register(&storvsc_drv);
18601865
}
18611866

0 commit comments

Comments
 (0)