Skip to content

Commit 436ad94

Browse files
caaverymartinkpetersen
authored andcommitted
scsi: storvsc: Allow only one remove lun work item to be issued per lun
When running multipath on a VM if all available paths go down the driver can schedule large amounts of storvsc_remove_lun work items to the same lun. In response to the failing paths typically storvsc responds by taking host->scan_mutex and issuing a TUR per lun. If there has been heavy IO to the failed device all the failed IOs are returned from the host. A remove lun work item is issued per failed IO. If the outstanding TURs have not been completed in a timely manner the scan_mutex is never released or released too late. Consequently the many remove lun work items are not completed as scsi_remove_device also tries to take host->scan_mutex. This results in dragging the VM down and sometimes completely. This patch only allows one remove lun to be issued to a particular lun while it is an instantiated member of the scsi stack. Signed-off-by: Cathy Avery <cavery@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Long Li <longli@microsoft.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent ca6958b commit 436ad94

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

drivers/scsi/storvsc_drv.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ struct hv_host_device {
486486
unsigned int port;
487487
unsigned char path;
488488
unsigned char target;
489+
struct workqueue_struct *handle_error_wq;
489490
};
490491

491492
struct storvsc_scan_work {
@@ -922,6 +923,7 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb,
922923
{
923924
struct storvsc_scan_work *wrk;
924925
void (*process_err_fn)(struct work_struct *work);
926+
struct hv_host_device *host_dev = shost_priv(host);
925927
bool do_work = false;
926928

927929
switch (SRB_STATUS(vm_srb->srb_status)) {
@@ -988,7 +990,7 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb,
988990
wrk->lun = vm_srb->lun;
989991
wrk->tgt_id = vm_srb->target_id;
990992
INIT_WORK(&wrk->work, process_err_fn);
991-
schedule_work(&wrk->work);
993+
queue_work(host_dev->handle_error_wq, &wrk->work);
992994
}
993995

994996

@@ -1803,10 +1805,19 @@ static int storvsc_probe(struct hv_device *device,
18031805
if (stor_device->num_sc != 0)
18041806
host->nr_hw_queues = stor_device->num_sc + 1;
18051807

1808+
/*
1809+
* Set the error handler work queue.
1810+
*/
1811+
host_dev->handle_error_wq =
1812+
alloc_ordered_workqueue("storvsc_error_wq_%d",
1813+
WQ_MEM_RECLAIM,
1814+
host->host_no);
1815+
if (!host_dev->handle_error_wq)
1816+
goto err_out2;
18061817
/* Register the HBA and start the scsi bus scan */
18071818
ret = scsi_add_host(host, &device->device);
18081819
if (ret != 0)
1809-
goto err_out2;
1820+
goto err_out3;
18101821

18111822
if (!dev_is_ide) {
18121823
scsi_scan_host(host);
@@ -1815,7 +1826,7 @@ static int storvsc_probe(struct hv_device *device,
18151826
device->dev_instance.b[4]);
18161827
ret = scsi_add_device(host, 0, target, 0);
18171828
if (ret)
1818-
goto err_out3;
1829+
goto err_out4;
18191830
}
18201831
#if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
18211832
if (host->transportt == fc_transport_template) {
@@ -1827,14 +1838,17 @@ static int storvsc_probe(struct hv_device *device,
18271838
fc_host_port_name(host) = stor_device->port_name;
18281839
stor_device->rport = fc_remote_port_add(host, 0, &ids);
18291840
if (!stor_device->rport)
1830-
goto err_out3;
1841+
goto err_out4;
18311842
}
18321843
#endif
18331844
return 0;
18341845

1835-
err_out3:
1846+
err_out4:
18361847
scsi_remove_host(host);
18371848

1849+
err_out3:
1850+
destroy_workqueue(host_dev->handle_error_wq);
1851+
18381852
err_out2:
18391853
/*
18401854
* Once we have connected with the host, we would need to
@@ -1858,13 +1872,15 @@ static int storvsc_remove(struct hv_device *dev)
18581872
{
18591873
struct storvsc_device *stor_device = hv_get_drvdata(dev);
18601874
struct Scsi_Host *host = stor_device->host;
1875+
struct hv_host_device *host_dev = shost_priv(host);
18611876

18621877
#if IS_ENABLED(CONFIG_SCSI_FC_ATTRS)
18631878
if (host->transportt == fc_transport_template) {
18641879
fc_remote_port_delete(stor_device->rport);
18651880
fc_remove_host(host);
18661881
}
18671882
#endif
1883+
destroy_workqueue(host_dev->handle_error_wq);
18681884
scsi_remove_host(host);
18691885
storvsc_dev_remove(dev);
18701886
scsi_host_put(host);

0 commit comments

Comments
 (0)