[SCSI] ibmvfc: Fix hang on module removal

If certain ELS events are received during module removal, after the kthread
is stopped, the rmmod can hang. This fixes the ibmvfc driver so that ELS
events during rmmod are ignored by stopping all device activity prior to
killing the kthread and also changes reinitialization to not attempt a reinit
if the adapter has been taken offline.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

authored by

Brian King and committed by
James Bottomley
2d0da2a4 b3c10489

+7 -4
+7 -4
drivers/scsi/ibmvscsi/ibmvfc.c
··· 521 521 static void ibmvfc_reinit_host(struct ibmvfc_host *vhost) 522 522 { 523 523 if (vhost->action == IBMVFC_HOST_ACTION_NONE) { 524 - scsi_block_requests(vhost->host); 525 - ibmvfc_set_host_state(vhost, IBMVFC_INITIALIZING); 526 - ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_QUERY); 524 + if (!ibmvfc_set_host_state(vhost, IBMVFC_INITIALIZING)) { 525 + scsi_block_requests(vhost->host); 526 + ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_QUERY); 527 + } 527 528 } else 528 529 vhost->reinit = 1; 529 530 ··· 3812 3811 3813 3812 ENTER; 3814 3813 ibmvfc_remove_trace_file(&vhost->host->shost_dev.kobj, &ibmvfc_trace_attr); 3814 + ibmvfc_link_down(vhost, IBMVFC_HOST_OFFLINE); 3815 + ibmvfc_wait_while_resetting(vhost); 3816 + ibmvfc_release_crq_queue(vhost); 3815 3817 kthread_stop(vhost->work_thread); 3816 3818 fc_remove_host(vhost->host); 3817 3819 scsi_remove_host(vhost->host); 3818 - ibmvfc_release_crq_queue(vhost); 3819 3820 3820 3821 spin_lock_irqsave(vhost->host->host_lock, flags); 3821 3822 ibmvfc_purge_requests(vhost, DID_ERROR);