public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi_transport_fc: Also check for NOTPRESENT in fc_remote_port_add()
@ 2017-09-25 11:47 Hannes Reinecke
  2017-09-25 12:01 ` Johannes Thumshirn
  2017-09-26  1:35 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Hannes Reinecke @ 2017-09-25 11:47 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

During failover there is a small race window between fc_remote_port_add()
and fc_timeout_deleted_rport(); the latter drops the lock after setting
the port to NOTPRESENT, so if fc_remote_port_add() is called right at
that time it will fail to detect the existing rport and happily adding
a new structure, causing rports to get registered twice.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/scsi_transport_fc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 3c6bc00..9d2d559 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -2739,7 +2739,8 @@ struct fc_rport *
 
 	list_for_each_entry(rport, &fc_host->rports, peers) {
 
-		if ((rport->port_state == FC_PORTSTATE_BLOCKED) &&
+		if ((rport->port_state == FC_PORTSTATE_BLOCKED ||
+		     rport->port_state == FC_PORTSTATE_NOTPRESENT) &&
 			(rport->channel == channel)) {
 
 			switch (fc_host->tgtid_bind_type) {
-- 
1.8.5.6

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

* Re: [PATCH] scsi_transport_fc: Also check for NOTPRESENT in fc_remote_port_add()
  2017-09-25 11:47 [PATCH] scsi_transport_fc: Also check for NOTPRESENT in fc_remote_port_add() Hannes Reinecke
@ 2017-09-25 12:01 ` Johannes Thumshirn
  2017-09-26  1:35 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2017-09-25 12:01 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, Hannes Reinecke

Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

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

* Re: [PATCH] scsi_transport_fc: Also check for NOTPRESENT in fc_remote_port_add()
  2017-09-25 11:47 [PATCH] scsi_transport_fc: Also check for NOTPRESENT in fc_remote_port_add() Hannes Reinecke
  2017-09-25 12:01 ` Johannes Thumshirn
@ 2017-09-26  1:35 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2017-09-26  1:35 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, Hannes Reinecke


Hannes,

> During failover there is a small race window between
> fc_remote_port_add() and fc_timeout_deleted_rport(); the latter drops
> the lock after setting the port to NOTPRESENT, so if
> fc_remote_port_add() is called right at that time it will fail to
> detect the existing rport and happily adding a new structure, causing
> rports to get registered twice.

Applied to 4.14/scsi-fixes. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2017-09-26  1:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-25 11:47 [PATCH] scsi_transport_fc: Also check for NOTPRESENT in fc_remote_port_add() Hannes Reinecke
2017-09-25 12:01 ` Johannes Thumshirn
2017-09-26  1:35 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox