diff options
author | Bart Van Assche <bvanassche@acm.org> | 2011-09-23 13:48:18 -0400 |
---|---|---|
committer | Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com> | 2011-11-21 12:55:13 -0500 |
commit | 712f248a5b7438bf003644a1cc0dfeed4bbbc8fd (patch) | |
tree | d6d0cb1b624dfdbc79b9b7f62f565bc0ff5af063 | |
parent | 320b9ba8fcddaae2a209d779b7adf990d8e6e2fd (diff) |
Make scsi_free_queue() kill pending SCSI commands
BugLink: http://bugs.launchpad.net/bugs/890952
commit 3308511c93e6ad0d3c58984ecd6e5e57f96b12c8 upstream.
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>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
-rw-r--r-- | drivers/scsi/hosts.c | 9 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 9 |
2 files changed, 15 insertions, 3 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 4f7a5829ea4..351dc0b86fa 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 28d9c9d6b4b..f97acffdddc 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1697,6 +1697,15 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) | |||
1697 | 1697 | ||
1698 | void scsi_free_queue(struct request_queue *q) | 1698 | void scsi_free_queue(struct request_queue *q) |
1699 | { | 1699 | { |
1700 | unsigned long flags; | ||
1701 | |||
1702 | WARN_ON(q->queuedata); | ||
1703 | |||
1704 | /* cause scsi_request_fn() to kill all non-finished requests */ | ||
1705 | spin_lock_irqsave(q->queue_lock, flags); | ||
1706 | q->request_fn(q); | ||
1707 | spin_unlock_irqrestore(q->queue_lock, flags); | ||
1708 | |||
1700 | blk_cleanup_queue(q); | 1709 | blk_cleanup_queue(q); |
1701 | } | 1710 | } |
1702 | 1711 | ||