aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2011-09-23 13:48:18 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-10-30 05:20:28 -0400
commit3308511c93e6ad0d3c58984ecd6e5e57f96b12c8 (patch)
treef141323e13347655a21bcd6cecbba6499d44ce05 /drivers/scsi
parent21208ae5a21fd5f337e987cde11374eaf2fe70b4 (diff)
[SCSI] Make scsi_free_queue() kill pending SCSI commands
Make sure that SCSI device removal via scsi_remove_host() does finish all pending SCSI commands. Currently that's not the case and hence removal of a SCSI host during I/O can cause a deadlock. See also "blkdev_issue_discard() hangs forever if underlying storage device is removed" (http://bugzilla.kernel.org/show_bug.cgi?id=40472). See also http://lkml.org/lkml/2011/8/27/6. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Cc: <stable@kernel.org> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/hosts.c9
-rw-r--r--drivers/scsi/scsi_lib.c9
2 files changed, 15 insertions, 3 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 4f7a5829ea4c..351dc0b86fab 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -286,6 +286,7 @@ static void scsi_host_dev_release(struct device *dev)
286{ 286{
287 struct Scsi_Host *shost = dev_to_shost(dev); 287 struct Scsi_Host *shost = dev_to_shost(dev);
288 struct device *parent = dev->parent; 288 struct device *parent = dev->parent;
289 struct request_queue *q;
289 290
290 scsi_proc_hostdir_rm(shost->hostt); 291 scsi_proc_hostdir_rm(shost->hostt);
291 292
@@ -293,9 +294,11 @@ static void scsi_host_dev_release(struct device *dev)
293 kthread_stop(shost->ehandler); 294 kthread_stop(shost->ehandler);
294 if (shost->work_q) 295 if (shost->work_q)
295 destroy_workqueue(shost->work_q); 296 destroy_workqueue(shost->work_q);
296 if (shost->uspace_req_q) { 297 q = shost->uspace_req_q;
297 kfree(shost->uspace_req_q->queuedata); 298 if (q) {
298 scsi_free_queue(shost->uspace_req_q); 299 kfree(q->queuedata);
300 q->queuedata = NULL;
301 scsi_free_queue(q);
299 } 302 }
300 303
301 scsi_destroy_command_freelist(shost); 304 scsi_destroy_command_freelist(shost);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index fc3f168decb4..b4d43ae76132 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1698,6 +1698,15 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
1698 1698
1699void scsi_free_queue(struct request_queue *q) 1699void scsi_free_queue(struct request_queue *q)
1700{ 1700{
1701 unsigned long flags;
1702
1703 WARN_ON(q->queuedata);
1704
1705 /* cause scsi_request_fn() to kill all non-finished requests */
1706 spin_lock_irqsave(q->queue_lock, flags);
1707 q->request_fn(q);
1708 spin_unlock_irqrestore(q->queue_lock, flags);
1709
1701 blk_cleanup_queue(q); 1710 blk_cleanup_queue(q);
1702} 1711}
1703 1712