linux/include/scsi
Joe Eykholt 4b2164d4d2 [SCSI] libfc: Fix remote port restart problem
This patch somewhat combines two fixes to remote port handing in libfc.

The first problem was that rport work could be queued on a deleted
and freed rport.  This is handled by not resetting rdata->event
ton NONE if the rdata is about to be deleted.

However, that fix led to the second problem, described by
Bhanu Gollapudi, as follows:
> Here is the sequence of events. T1 is first LOGO receive thread, T2 is
> fc_rport_work() scheduled by T1 and T3 is second LOGO receive thread and
> T4 is fc_rport_work scheduled by T3.
>
> 1. (T1)Received 1st LOGO in state Ready
> 2. (T1)Delete port & enter to RESTART state.
> 3. (T1)schdule event_work, since event is RPORT_EV_NONE.
> 4. (T1)set event = RPORT_EV_LOGO
> 5. (T1)Enter RESTART state as disc_id is set.
> 6. (T2)remember to PLOGI, and set event = RPORT_EV_NONE
> 6. (T3)Received 2nd LOGO
> 7. (T3)Delete Port & enter to RESTART state.
> 8. (T3)schedule event_work, since event is RPORT_EV_NONE.
> 9. (T3)Enter RESTART state as disc_id is set.
> 9. (T3)set event = RPORT_EV_LOGO
> 10.(T2)work restart, enter PLOGI state and issues PLOGI
> 11.(T4)Since state is not RESTART anymore, restart is not set, and the
> event is not reset to RPORT_EV_NONE. (current event is RPORT_EV_LOGO).
> 12. Now, PLOGI succeeds and fc_rport_enter_ready() will not schedule
> event_work, and hence the rport will never be created, eventually losing
> the target after dev_loss_tmo.

So, the problem here is that we were tracking the desire for
the rport be restarted by state RESTART, which was otherwise
equivalent to DELETE.  A contributing factor is that we dropped
the lock between steps 6 and 10 in thread T2, which allows the
state to change, and we didn't completely re-evaluate then.

This is hopefully corrected by the following minor redesign:

Simplify the rport restart logic by making the decision to
restart after deleting the transport rport.  That decision
is based on a new STARTED flag that indicates fc_rport_login()
has been called and fc_rport_logoff() has not been called
since then.  This replaces the need for the RESTART state.

Only restart if the rdata is still in DELETED state
and only if it still has the STARTED flag set.

Also now, since we clear the event code much later in the
work thread, allow for the possibility that the rport may
have become READY again via incoming PLOGI, and if so,
queue another event to handle that.

In the problem scenario, the second LOGO received will
cause the LOGO event to occur again.

Reported-by: Bhanu Gollapudi <bprakash@broadcom.com>
Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
2010-07-27 12:01:52 -05:00
..
fc [SCSI] libfc: Handle unsolicited PRLO request 2010-07-27 12:01:46 -05:00
Kbuild [SCSI] Unexport scsi/scsi.h from headers_install 2010-05-02 11:45:12 -04:00
fc_encode.h [SCSI] libfc: Move the port_id into lport 2010-05-16 22:22:34 -04:00
fc_frame.h [SCSI] fcoe, libfc: use single frame allocation API 2009-12-04 12:01:09 -06:00
iscsi_if.h [SCSI] libiscsi: add warm target reset tmf support 2009-12-04 12:01:36 -06:00
iscsi_proto.h [SCSI] libiscsi: Check TMF state before sending PDU 2009-12-04 12:01:36 -06:00
libfc.h [SCSI] libfc: Fix remote port restart problem 2010-07-27 12:01:52 -05:00
libfcoe.h [SCSI] fcoe, fnic, libfc: increased CDB size to 16 bytes for fcoe. 2010-04-11 14:02:39 -05:00
libiscsi.h [SCSI] libiscsi: Make iscsi_eh_target_reset start with session reset 2010-03-03 17:39:04 +05:30
libiscsi_tcp.h kfifo: move struct kfifo in place 2009-12-22 14:17:55 -08:00
libsas.h include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
libsrp.h libsrp: fix compile failure 2009-12-30 12:23:27 -08:00
osd_attributes.h [SCSI] libosd: OSD2r05: Attribute definitions 2009-06-10 08:54:07 -05:00
osd_initiator.h [SCSI] libosd: Fix blk_put_request locking again 2009-12-10 08:54:17 -06:00
osd_protocol.h [SCSI] osd_protocol.h: Add missing #include 2009-12-04 12:01:48 -06:00
osd_sec.h [SCSI] libosd: OSDv1 Headers 2009-03-12 12:58:06 -05:00
osd_sense.h [SCSI] libosd: osd_sense: OSD_CFO_PERMISSIONS 2009-12-04 12:01:44 -06:00
osd_types.h [SCSI] libosd: OSDv1 Headers 2009-03-12 12:58:06 -05:00
sas.h [SCSI] libsas: Convert sas_proto users to sas_protocol 2008-01-11 18:22:41 -06:00
sas_ata.h [SCSI] libsas: fix missing inlines in header file 2008-04-07 12:19:10 -05:00
scsi.h [SCSI] Add missing scsi command definitions 2010-04-30 12:46:17 -05:00
scsi_bsg_fc.h [SCSI] fc-transport: Use packed modifier for fc_bsg_request structure. 2010-01-17 12:36:33 -06:00
scsi_cmnd.h [SCSI] Deprecate SCSI_PROT_*_CONVERT operations 2009-10-02 09:46:25 -05:00
scsi_dbg.h [SCSI] Fix device not ready printk 2007-10-12 14:51:56 -04:00
scsi_device.h [SCSI] eliminate potential kmalloc failure in scsi_get_vpd_page() 2010-01-18 10:48:05 -06:00
scsi_devinfo.h Merge ../scsi-rc-fixes-2.6 2006-04-14 15:47:45 -05:00
scsi_dh.h [SCSI] scsi_dh: Change the scsidh_activate interface to be asynchronous 2009-12-04 12:00:46 -06:00
scsi_driver.h sd, sr: fix Driver 'sd' needs updating message 2009-06-21 12:01:27 -05:00
scsi_eh.h [SCSI] scsi_eh_prep_cmnd should save scmd->underflow 2008-07-26 15:14:56 -04:00
scsi_host.h SCSI: implement sd_unlock_native_capacity() 2010-06-02 13:50:04 -04:00
scsi_ioctl.h [PATCH] don't mess with file in scsi_nonblockable_ioctl() 2008-10-21 07:47:28 -04:00
scsi_netlink.h [SCSI] scsi_netlink: Add transport and LLD recieve and event support 2008-10-03 11:46:13 -05:00
scsi_netlink_fc.h [SCSI] SCSI & FC transport: extend event vendor id's to 64bits 2006-09-02 15:35:15 -05:00
scsi_scan.h PM/Hibernate: Wait for SCSI devices scan to complete during resume 2009-04-13 11:37:07 -07:00
scsi_tcq.h scsi: make sure that scsi_init_shared_tag_map() doesn't overwrite existing map 2008-10-27 19:25:30 +01:00
scsi_tgt.h [SCSI] tgt: add I_T nexus support 2007-10-12 14:37:50 -04:00
scsi_tgt_if.h [SCSI] tgt: add I_T nexus support 2007-10-12 14:37:50 -04:00
scsi_transport.h block: unify request timeout handling 2008-10-09 08:56:13 +02:00
scsi_transport_fc.h [SCSI] Allow FC LLD to fast-fail scsi eh by introducing new eh return 2010-04-11 09:49:33 -05:00
scsi_transport_iscsi.h [SCSI] iscsi class: Add new NETLINK_ISCSI messages for cnic/bnx2i driver. 2009-06-09 10:22:35 -05:00
scsi_transport_sas.h [SCSI] scsi_transport_sas: add support for transport layer retries (TLR) 2010-02-08 17:15:19 -06:00
scsi_transport_spi.h [SCSI] aic79xx: make driver respect nvram for IU and QAS settings 2009-06-15 10:09:35 -05:00
scsi_transport_srp.h [SCSI] tgt: move tsk_mgmt_response callback to transport class 2007-10-12 14:38:01 -04:00
scsicam.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sg.h sysctl extern cleanup: sg 2010-03-12 15:53:10 -08:00
srp.h [SCSI] srp.h: Add I/O Class values 2006-06-17 20:37:38 -07:00