瀏覽代碼

[SCSI] libfc: stop login after fabric logoff

When removing the fcoe module, several lports were being shut down
through fc_lport_fabric_logoff().

Occasionally, one would enter reset state before fc_lport_destroy()
was called, and since link_up was still true, it would log back in.

If we just clear link_up earlier, then we wouldn't be accepting LOGO
requests from other initiators while we are shutting down.

Fix by changing the LOGO response handler to enter DISABLED instead
of RESET.  Add an fc_lport_enter_disabled() function which does
what fc_lport_enter_reset() did, except it doesn't proceed to FLOGI state.

Move the code that was common between fc_lport_enter_reset() and
fc_lport_enter_disabled() into a new fc_lport_reset_locked() function.

Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Joe Eykholt 16 年之前
父節點
當前提交
1190d92581
共有 1 個文件被更改,包括 34 次插入8 次删除
  1. 34 8
      drivers/scsi/libfc/fc_lport.c

+ 34 - 8
drivers/scsi/libfc/fc_lport.c

@@ -930,19 +930,14 @@ int fc_lport_reset(struct fc_lport *lport)
 EXPORT_SYMBOL(fc_lport_reset);
 EXPORT_SYMBOL(fc_lport_reset);
 
 
 /**
 /**
- * fc_rport_enter_reset() - Reset the local port
+ * fc_lport_reset_locked() - Reset the local port
  * @lport: Fibre Channel local port to be reset
  * @lport: Fibre Channel local port to be reset
  *
  *
  * Locking Note: The lport lock is expected to be held before calling
  * Locking Note: The lport lock is expected to be held before calling
  * this routine.
  * this routine.
  */
  */
-static void fc_lport_enter_reset(struct fc_lport *lport)
+static void fc_lport_reset_locked(struct fc_lport *lport)
 {
 {
-	FC_LPORT_DBG(lport, "Entered RESET state from %s state\n",
-		     fc_lport_state(lport));
-
-	fc_lport_state_enter(lport, LPORT_ST_RESET);
-
 	if (lport->dns_rp)
 	if (lport->dns_rp)
 		lport->tt.rport_logoff(lport->dns_rp);
 		lport->tt.rport_logoff(lport->dns_rp);
 
 
@@ -956,11 +951,42 @@ static void fc_lport_enter_reset(struct fc_lport *lport)
 	lport->tt.exch_mgr_reset(lport, 0, 0);
 	lport->tt.exch_mgr_reset(lport, 0, 0);
 	fc_host_fabric_name(lport->host) = 0;
 	fc_host_fabric_name(lport->host) = 0;
 	fc_host_port_id(lport->host) = 0;
 	fc_host_port_id(lport->host) = 0;
+}
+
+/**
+ * fc_lport_enter_reset() - Reset the local port
+ * @lport: Fibre Channel local port to be reset
+ *
+ * Locking Note: The lport lock is expected to be held before calling
+ * this routine.
+ */
+static void fc_lport_enter_reset(struct fc_lport *lport)
+{
+	FC_LPORT_DBG(lport, "Entered RESET state from %s state\n",
+		     fc_lport_state(lport));
 
 
+	fc_lport_state_enter(lport, LPORT_ST_RESET);
+	fc_lport_reset_locked(lport);
 	if (lport->link_up)
 	if (lport->link_up)
 		fc_lport_enter_flogi(lport);
 		fc_lport_enter_flogi(lport);
 }
 }
 
 
+/**
+ * fc_lport_enter_disabled() - disable the local port
+ * @lport: Fibre Channel local port to be reset
+ *
+ * Locking Note: The lport lock is expected to be held before calling
+ * this routine.
+ */
+static void fc_lport_enter_disabled(struct fc_lport *lport)
+{
+	FC_LPORT_DBG(lport, "Entered disabled state from %s state\n",
+		     fc_lport_state(lport));
+
+	fc_lport_state_enter(lport, LPORT_ST_DISABLED);
+	fc_lport_reset_locked(lport);
+}
+
 /**
 /**
  * fc_lport_error() - Handler for any errors
  * fc_lport_error() - Handler for any errors
  * @lport: The fc_lport object
  * @lport: The fc_lport object
@@ -1382,7 +1408,7 @@ static void fc_lport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
 
 
 	op = fc_frame_payload_op(fp);
 	op = fc_frame_payload_op(fp);
 	if (op == ELS_LS_ACC)
 	if (op == ELS_LS_ACC)
-		fc_lport_enter_reset(lport);
+		fc_lport_enter_disabled(lport);
 	else
 	else
 		fc_lport_error(lport, fp);
 		fc_lport_error(lport, fp);