Add support to not allow additions to a host when it is being removed. Signed-off-by: Mike Anderson <andmike@xxxxxxxxxx> --- linux-2.6.12-rc6-mm1-andmike/drivers/scsi/hosts.c | 2 + linux-2.6.12-rc6-mm1-andmike/drivers/scsi/scsi_scan.c | 21 ++++++++++++------ linux-2.6.12-rc6-mm1-andmike/include/scsi/scsi_host.h | 9 +++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff -puN drivers/scsi/hosts.c~host_scan drivers/scsi/hosts.c --- linux-2.6.12-rc6-mm1/drivers/scsi/hosts.c~host_scan 2005-06-16 10:47:17.000000000 -0700 +++ linux-2.6.12-rc6-mm1-andmike/drivers/scsi/hosts.c 2005-06-16 10:47:17.000000000 -0700 @@ -133,7 +133,9 @@ EXPORT_SYMBOL(scsi_host_set_state); **/ void scsi_remove_host(struct Scsi_Host *shost) { + down(&shost->scan_mutex); scsi_host_set_state(shost, SHOST_CANCEL); + up(&shost->scan_mutex); scsi_forget_host(shost); scsi_proc_host_rm(shost); diff -puN include/scsi/scsi_host.h~host_scan include/scsi/scsi_host.h --- linux-2.6.12-rc6-mm1/include/scsi/scsi_host.h~host_scan 2005-06-16 10:47:17.000000000 -0700 +++ linux-2.6.12-rc6-mm1-andmike/include/scsi/scsi_host.h 2005-06-16 10:47:17.000000000 -0700 @@ -656,6 +656,15 @@ static inline struct device *scsi_get_de return shost->shost_gendev.parent; } +/** + * scsi_host_scan_allowed - Is scanning of this host allowed + * @shost: Pointer to Scsi_Host. + **/ +static inline int scsi_host_scan_allowed(struct Scsi_Host *shost) +{ + return shost->shost_state == SHOST_RUNNING; +} + extern void scsi_unblock_requests(struct Scsi_Host *); extern void scsi_block_requests(struct Scsi_Host *); diff -puN drivers/scsi/scsi_scan.c~host_scan drivers/scsi/scsi_scan.c --- linux-2.6.12-rc6-mm1/drivers/scsi/scsi_scan.c~host_scan 2005-06-16 10:47:17.000000000 -0700 +++ linux-2.6.12-rc6-mm1-andmike/drivers/scsi/scsi_scan.c 2005-06-16 10:47:17.000000000 -0700 @@ -1218,9 +1218,12 @@ struct scsi_device *__scsi_add_device(st get_device(&starget->dev); down(&shost->scan_mutex); - res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata); - if (res != SCSI_SCAN_LUN_PRESENT) - sdev = ERR_PTR(-ENODEV); + if (scsi_host_scan_allowed(shost)) { + res = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, + hostdata); + if (res != SCSI_SCAN_LUN_PRESENT) + sdev = ERR_PTR(-ENODEV); + } up(&shost->scan_mutex); scsi_target_reap(starget); put_device(&starget->dev); @@ -1370,11 +1373,15 @@ int scsi_scan_host_selected(struct Scsi_ return -EINVAL; down(&shost->scan_mutex); - if (channel == SCAN_WILD_CARD) - for (channel = 0; channel <= shost->max_channel; channel++) + if (scsi_host_scan_allowed(shost)) { + if (channel == SCAN_WILD_CARD) + for (channel = 0; channel <= shost->max_channel; + channel++) + scsi_scan_channel(shost, channel, id, lun, + rescan); + else scsi_scan_channel(shost, channel, id, lun, rescan); - else - scsi_scan_channel(shost, channel, id, lun, rescan); + } up(&shost->scan_mutex); return 0; _ - : send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html