All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] FC_Transport: Check portstates before invoking target scan
@ 2007-06-14  7:27 Hannes Reinecke
  2007-06-14 11:57 ` James Smart
  0 siblings, 1 reply; 3+ messages in thread
From: Hannes Reinecke @ 2007-06-14  7:27 UTC (permalink / raw)
  To: James Bottomley; +Cc: James Smart, SCSI Mailing List

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

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
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)

[-- Attachment #2: fc_transport_check-portstates-before-scanning --]
[-- Type: text/plain, Size: 1238 bytes --]

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.

Signed-off-by: Hannes Reinecke <hare@suse.de>

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 4953f0d..bd73615 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -1943,6 +1943,12 @@ static int fc_user_scan(struct Scsi_Host
 		if (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,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] FC_Transport: Check portstates before invoking target scan
  2007-06-14  7:27 [PATCH] FC_Transport: Check portstates before invoking target scan Hannes Reinecke
@ 2007-06-14 11:57 ` James Smart
  2007-06-14 13:16   ` Hannes Reinecke
  0 siblings, 1 reply; 3+ messages in thread
From: James Smart @ 2007-06-14 11:57 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: James Bottomley, SCSI Mailing List

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

Hannes Reinecke wrote:
> 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
> 
> 
> ------------------------------------------------------------------------
> 
> 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.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> 
> diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
> index 4953f0d..bd73615 100644
> --- a/drivers/scsi/scsi_transport_fc.c
> +++ b/drivers/scsi/scsi_transport_fc.c
> @@ -1943,6 +1943,12 @@ static int fc_user_scan(struct Scsi_Host
>  		if (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,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] FC_Transport: Check portstates before invoking target scan
  2007-06-14 11:57 ` James Smart
@ 2007-06-14 13:16   ` Hannes Reinecke
  0 siblings, 0 replies; 3+ messages in thread
From: Hannes Reinecke @ 2007-06-14 13:16 UTC (permalink / raw)
  To: James Smart; +Cc: James Bottomley, SCSI Mailing List

[-- Attachment #1: Type: text/plain, Size: 499 bytes --]

Hi James,

On Thu, Jun 14, 2007 at 07:57:05AM -0400, James Smart wrote:
> 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
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Markus Rex, HRB 16746 (AG N�rnberg)

[-- Attachment #2: fc_transport_check-portstates-before-scanning --]
[-- Type: text/plain, Size: 1069 bytes --]

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.

Signed-off-by: Hannes Reinecke <hare@suse.de>

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 4953f0d..e882570 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -1943,6 +1943,9 @@ static int fc_user_scan(struct Scsi_Host
 		if (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,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-06-14 13:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-14  7:27 [PATCH] FC_Transport: Check portstates before invoking target scan Hannes Reinecke
2007-06-14 11:57 ` James Smart
2007-06-14 13:16   ` Hannes Reinecke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.