All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christof Schmitt <christof.schmitt@de.ibm.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org, linux-s390@vger.kernel.org,
	schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com,
	Christof Schmitt <christof.schmitt@de.ibm.com>
Subject: [patch 15/15] zfcp: Fix oops when port disappears
Date: Fri, 17 Apr 2009 15:08:15 +0200	[thread overview]
Message-ID: <20090417131123.790167000@de.ibm.com> (raw)
In-Reply-To: 20090417130800.923944000@de.ibm.com

[-- Attachment #1: s390-sles11-12-05-zfcp_fcp_port_handling.patch --]
[-- Type: text/plain, Size: 3238 bytes --]

From: Christof Schmitt <christof.schmitt@de.ibm.com>

The zfcp_port might have been removed, while the FC fast_io_fail timer
is still running and could trigger the terminate_rport_io callback.
Set the pointer to the zfcp_port to NULL and check accordingly
before using it.

Reviewed-by: Martin Petermann <martin@linux.vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
---
 drivers/s390/scsi/zfcp_aux.c  |    3 +--
 drivers/s390/scsi/zfcp_fsf.c  |    4 ++++
 drivers/s390/scsi/zfcp_scsi.c |   25 +++++++++++++++++++------
 3 files changed, 24 insertions(+), 8 deletions(-)

--- a/drivers/s390/scsi/zfcp_aux.c	2009-04-17 15:03:37.000000000 +0200
+++ b/drivers/s390/scsi/zfcp_aux.c	2009-04-17 15:04:00.000000000 +0200
@@ -671,8 +671,7 @@ void zfcp_port_dequeue(struct zfcp_port 
 	list_del(&port->list);
 	write_unlock_irq(&zfcp_data.config_lock);
 	if (port->rport)
-		fc_remote_port_delete(port->rport);
-	port->rport = NULL;
+		port->rport->dd_data = NULL;
 	zfcp_adapter_put(port->adapter);
 	sysfs_remove_group(&port->sysfs_device.kobj, &zfcp_sysfs_port_attrs);
 	device_unregister(&port->sysfs_device);
--- a/drivers/s390/scsi/zfcp_scsi.c	2009-04-17 15:03:49.000000000 +0200
+++ b/drivers/s390/scsi/zfcp_scsi.c	2009-04-17 15:04:00.000000000 +0200
@@ -486,10 +486,12 @@ static void zfcp_set_rport_dev_loss_tmo(
  */
 static void zfcp_scsi_dev_loss_tmo_callbk(struct fc_rport *rport)
 {
-	struct zfcp_port *port = rport->dd_data;
+	struct zfcp_port *port;
 
 	write_lock_irq(&zfcp_data.config_lock);
-	port->rport = NULL;
+	port = rport->dd_data;
+	if (port)
+		port->rport = NULL;
 	write_unlock_irq(&zfcp_data.config_lock);
 }
 
@@ -503,9 +505,18 @@ static void zfcp_scsi_dev_loss_tmo_callb
  */
 static void zfcp_scsi_terminate_rport_io(struct fc_rport *rport)
 {
-	struct zfcp_port *port = rport->dd_data;
+	struct zfcp_port *port;
+
+	write_lock_irq(&zfcp_data.config_lock);
+	port = rport->dd_data;
+	if (port)
+		zfcp_port_get(port);
+	write_unlock_irq(&zfcp_data.config_lock);
 
-	zfcp_erp_port_reopen(port, 0, "sctrpi1", NULL);
+	if (port) {
+		zfcp_erp_port_reopen(port, 0, "sctrpi1", NULL);
+		zfcp_port_put(port);
+	}
 }
 
 static void zfcp_scsi_rport_register(struct zfcp_port *port)
@@ -534,8 +545,10 @@ static void zfcp_scsi_rport_register(str
 
 static void zfcp_scsi_rport_block(struct zfcp_port *port)
 {
-	if (port->rport)
-		fc_remote_port_delete(port->rport);
+	struct fc_rport *rport = port->rport;
+
+	if (rport)
+		fc_remote_port_delete(rport);
 }
 
 void zfcp_scsi_schedule_rport_register(struct zfcp_port *port)
--- a/drivers/s390/scsi/zfcp_fsf.c	2009-04-17 15:03:52.000000000 +0200
+++ b/drivers/s390/scsi/zfcp_fsf.c	2009-04-17 15:04:00.000000000 +0200
@@ -172,12 +172,16 @@ static void zfcp_fsf_link_down_info_eval
 					 struct fsf_link_down_info *link_down)
 {
 	struct zfcp_adapter *adapter = req->adapter;
+	unsigned long flags;
 
 	if (atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED)
 		return;
 
 	atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
+
+	read_lock_irqsave(&zfcp_data.config_lock, flags);
 	zfcp_scsi_schedule_rports_block(adapter);
+	read_unlock_irqrestore(&zfcp_data.config_lock, flags);
 
 	if (!link_down)
 		goto out;

      parent reply	other threads:[~2009-04-17 13:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-17 13:08 [patch 00/15] zfcp fixes for 2.6.30-rc2 Christof Schmitt
2009-04-17 13:08 ` [patch 01/15] zfcp: Avoid referencing freed memory in req send Christof Schmitt
2009-04-17 13:08 ` [patch 02/15] zfcp: Enable auto-port discovery for NPIV Christof Schmitt
2009-04-17 13:08 ` [patch 03/15] zfcp: Dont call zfcp_fsf_req_free on NULL pointer Christof Schmitt
2009-04-17 13:08 ` [patch 04/15] zfcp: Dont block zfcp_wq with scan Christof Schmitt
2009-04-17 13:08 ` [patch 05/15] zfcp: Set WKA-port to offline on adapter deactivation Christof Schmitt
2009-04-17 13:08 ` [patch 06/15] zfcp: avoid false ERP complete due to sema race Christof Schmitt
2009-04-17 13:08 ` [patch 07/15] zfcp: no port recovery after storage side error inject Christof Schmitt
2009-04-17 13:08 ` [patch 08/15] zfcp: remove unit will fail if add unit is not finished Christof Schmitt
2009-04-17 13:08 ` [patch 09/15] zfcp: Let actcli handle control file errors Christof Schmitt
2009-04-17 13:08 ` [patch 10/15] zfcp: no port recovery after ADISC request timeout Christof Schmitt
2009-04-17 13:08 ` [patch 11/15] zfcp: Fix abort handler for completions in progress Christof Schmitt
2009-04-17 13:08 ` [patch 12/15] zfcp: revert previous patch for sbal counting Christof Schmitt
2009-04-17 13:08 ` [patch 13/15] zfcp: Fix port reference counting Christof Schmitt
2009-04-17 13:08 ` [patch 14/15] zfcp: Reference counting for cfdc requests Christof Schmitt
2009-04-17 13:08 ` Christof Schmitt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090417131123.790167000@de.ibm.com \
    --to=christof.schmitt@de.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.