Commit c879f2b7 authored by Mike Anderson's avatar Mike Anderson Committed by James Bottomley

[PATCH] scsi_set_device_offline lock fix

Patrick pointed out that I could get into a ABBA issue with holding
list_lock while calling scsi_eh_scmd_add which takes host_lock.
A call to scsi_prep_fn already holds the queue_lock and then makes a
call to scsi_get_command which takes list_lock.

-andmike
--
Michael Anderson
andmike@us.ibm.com

=====
name:		00_scsi_set_device_offline.diff
version:	2003-02-26.15:18:19-0800
against:	scsi-misc-2.5

 scsi.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

=====
parent a1b784ec
......@@ -1308,7 +1308,8 @@ void scsi_device_put(struct scsi_device *sdev)
void scsi_set_device_offline(struct scsi_device *sdev)
{
struct scsi_cmnd *scmd;
int cmds_active = 0;
LIST_HEAD(active_list);
struct list_head *lh, *lh_sf;
unsigned long flags;
sdev->online = FALSE;
......@@ -1324,15 +1325,17 @@ void scsi_set_device_offline(struct scsi_device *sdev)
if (!scsi_delete_timer(scmd)) {
continue;
}
++cmds_active;
scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD);
list_add_tail(&scmd->eh_entry, &active_list);
}
}
spin_unlock_irqrestore(&sdev->list_lock, flags);
if (!cmds_active) {
if (!list_empty(&active_list)) {
list_for_each_safe(lh, lh_sf, &active_list) {
scmd = list_entry(lh, struct scsi_cmnd, eh_entry);
scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD);
}
} else {
/* FIXME: Send online state change hotplug event */
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment