[SCSI] qla2xxx: Correct synchronization of software/firmware fcport states.

Greg Wettstein (greg@enjellic.com) noted:

http://article.gmane.org/gmane.linux.scsi/43409

on a reboot of a previously recognized SCST target, the initiator
driver would be unable to re-recognize the device as a target.
It turns out that prior to the SCST software reloading and
returning it's "target-capable" abilities in the PRLI payload,
the HBA would be re-initialized as an initiator-only type port.
Since initiators typically classify themselves as an FCP-2
capable device, both software and firmware do not perform an
explicit logout during port-loss. Unfortunately, as can be seen
by the failure case, when the port (now target-capable) returns,
firmware performs an ADISC without a follow-on PRLI, leaving
stale 'initiator-only' data in the firmware's port database.

Correct the discrepancy by performing the explicit logout during
the transport's request to terminate-rport-io, thus synchronizing
port states and ensuring a follow-on PRLI is performed.

Reported-by: Greg Wettstein <greg@enjellic.com>
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

authored by Andrew Vasquez and committed by James Bottomley 6390d1f3 fe42625c

+11
+11
drivers/scsi/qla2xxx/qla_attr.c
··· 993 { 994 fc_port_t *fcport = *(fc_port_t **)rport->dd_data; 995 996 qla2x00_abort_fcport_cmds(fcport); 997 scsi_target_unblock(&rport->dev); 998 }
··· 993 { 994 fc_port_t *fcport = *(fc_port_t **)rport->dd_data; 995 996 + /* 997 + * At this point all fcport's software-states are cleared. Perform any 998 + * final cleanup of firmware resources (PCBs and XCBs). 999 + */ 1000 + if (fcport->loop_id != FC_NO_LOOP_ID) { 1001 + fcport->ha->isp_ops->fabric_logout(fcport->ha, fcport->loop_id, 1002 + fcport->d_id.b.domain, fcport->d_id.b.area, 1003 + fcport->d_id.b.al_pa); 1004 + fcport->loop_id = FC_NO_LOOP_ID; 1005 + } 1006 + 1007 qla2x00_abort_fcport_cmds(fcport); 1008 scsi_target_unblock(&rport->dev); 1009 }