FC_Transport: Check portstates before invoking target scan
PATCH 1/1 FC_Transport: Check portstates before invoking target scan
Hi James (& James, too :-),
scsi_transport_fc.c:fc_user_scan() should check the portstates prior to calling scsi_scan_target(). Otherwise we might get a nice oops as the rport might already been disconnected from the host by the time we're calling scsi_scan_target(). Thus the traversal from the rport to the scsi_host in scsi_scan_target() will fail, resulting in a nice Oops. Plus it's quite pointless to scan a target if the portstates already told us that we can't communicate with it.
Please apply.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Markus Rex, HRB 16746 (AG Nürnberg)
scsi_transport_fc: Check portstates before invoking target scan
When a target scan is initiated from sysfs, we should check the portstate prior to invoke scsi_scan_target().
Otherwise scsi_scan_target() might oops as the rport might already been removed from the scsi host and the traversal from the rport to the scsi_host in scsi_scan_target() will fail.
Also the portstate already told us that communication with the target has failed, so it's quite pointless to try.
drivers/scsi/scsi_transport_fc.c +6 -0
@@ -1943,6 +1943,12 @@ static int fc_user_scan(struct Scsi_Hostif (rport->scsi_target_id ==-1 )continue ; +if ((rport->port_state ==FC_PORTSTATE_NOTPRESENT ) || + (rport->port_state ==FC_PORTSTATE_UNKNOWN ) || + (rport->port_state ==FC_PORTSTATE_DELETED ) || + (rport->port_state ==FC_PORTSTATE_BLOCKED )) +continue ; +if ((channel ==SCAN_WILD_CARD || channel == rport->channel) && (id ==SCAN_WILD_CARD || id == rport->scsi_target_id)) { scsi_scan_target(&rport->dev, rport->channel,
Sounds reasonable... Only change I'd make is rather than comparing all the different states, simply compare (rport->port_state != FC_PORTSTATE_ONLINE)
-- james s
Quoted 48 lines · Hannes Reinecke
Hi James (& James, too :-),
scsi_transport_fc.c:fc_user_scan() should check the portstates prior to calling
scsi_scan_target(). Otherwise we might get a nice oops as the rport might already been disconnected from the host by the time we're callingscsi_scan_target(). Thus the traversal from the rport to thescsi_hostinscsi_scan_target()will fail, resulting in a nice Oops. Plus it's quite pointless to scan a target if the portstates already told us that we can't communicate with it.Please apply.
Cheers,
Hannes
------------------------------------------------------------------------
scsi_transport_fc: Check portstates before invoking target scanWhen a target scan is initiated from sysfs, we should check the portstate prior to invoke
scsi_scan_target().
Otherwisescsi_scan_target()might oops as the rport might already been removed from the scsi host and the traversal from the rport to thescsi_hostinscsi_scan_target()will fail.
Also the portstate already told us that communication with the target has failed, so it's quite pointless to try.Signed-off-by Hannes Reinecke <[email protected]>drivers/scsi/scsi_transport_fc.c +6
-0@@ -1943,6 +1943,12 @@ static int fc_user_scan(struct Scsi_Hostif (rport->scsi_target_id ==-1 )continue ; +if ((rport->port_state ==FC_PORTSTATE_NOTPRESENT ) || + (rport->port_state ==FC_PORTSTATE_UNKNOWN ) || + (rport->port_state ==FC_PORTSTATE_DELETED ) || + (rport->port_state ==FC_PORTSTATE_BLOCKED )) +continue ; +if ((channel ==SCAN_WILD_CARD || channel == rport->channel) && (id ==SCAN_WILD_CARD || id == rport->scsi_target_id)) { scsi_scan_target(&rport->dev, rport->channel,
Hi James,
Quoted 3 lines · James Smart
Sounds reasonable... Only change I'd make is rather than comparing all the different states, simply compare (
rport->port_state!=FC_PORTSTATE_ONLINE)
As per normal you are oh-so correct.
Updated patch attached.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: Markus Rex, HRB 16746 (AG N�rnberg)
scsi_transport_fc: Check portstates before invoking target scan
When a target scan is initiated from sysfs, we should check the portstate prior to invoke scsi_scan_target().
Otherwise scsi_scan_target() might oops as the rport might already been removed from the scsi host and the traversal from the rport to the scsi_host in scsi_scan_target() will fail.
Also the portstate already told us that communication with the target has failed, so it's quite pointless to try.
drivers/scsi/scsi_transport_fc.c +3 -0
@@ -1943,6 +1943,9 @@ static int fc_user_scan(struct Scsi_Hostif (rport->scsi_target_id ==-1 )continue ; +if (rport->port_state !=FC_PORTSTATE_ONLINE ) +continue ; +if ((channel ==SCAN_WILD_CARD || channel == rport->channel) && (id ==SCAN_WILD_CARD || id == rport->scsi_target_id)) { scsi_scan_target(&rport->dev, rport->channel,