Re: [PATCH scsi-misc-2.6 08/08] scsi: fix hot unplug sequence

From: Tejun Heo
Date: Tue Mar 22 2005 - 21:29:07 EST


08_scsi_hot_unplug_fix.patch

When hot-unplugging using scsi_remove_host() function (as usb
does), scsi_forget_host() used to be called before
scsi_host_cancel(). So, the device gets removed first without
request cleanup and scsi_host_cancel() never gets to call
scsi_device_cancel() on the removed devices. This results in
premature completion of hot-unplugging process with active
requests left in queue, eventually leading to hang/offlined
device or oops when the active command times out.

This patch makes scsi_remove_host() call scsi_host_cancel()
first such that the host is first transited into cancel state
and all requests of all devices are killed, and then, the
devices are removed. This patch fixes the oops in eh after
hot-unplugging bug.

Signed-off-by: Tejun Heo <htejun@xxxxxxxxx>

hosts.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)

Index: scsi-export/drivers/scsi/hosts.c
===================================================================
--- scsi-export.orig/drivers/scsi/hosts.c 2005-03-23 09:39:36.000000000 +0900
+++ scsi-export/drivers/scsi/hosts.c 2005-03-23 09:40:11.000000000 +0900
@@ -74,8 +74,8 @@ void scsi_host_cancel(struct Scsi_Host *
**/
void scsi_remove_host(struct Scsi_Host *shost)
{
- scsi_forget_host(shost);
scsi_host_cancel(shost, 0);
+ scsi_forget_host(shost);
scsi_proc_host_rm(shost);

set_bit(SHOST_DEL, &shost->shost_state);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/