[SCSI] libfc: make rport module maintain the rport list

The list of remote ports (struct fc_rport_priv) has been
maintained by the discovery module.  In preparation for having
lport->tt.rport_create() do a lookup first, maintain the
rports list in the rport module.  It will still be protected
by the disc_mutex.

The DNS rport is an exception for until after further patches.
For now, do not add it to the list.

The point-to-point rport will be in the discovery list.
So at shutdown, it doesn't need to be separately logged out.

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@suse.de>
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 22c0f7b..f33e573 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -205,12 +205,11 @@
 	ids.node_name = remote_wwnn;
 	ids.roles = FC_RPORT_ROLE_UNKNOWN;
 
-	if (lport->ptp_rp) {
+	mutex_lock(&lport->disc.disc_mutex);
+	if (lport->ptp_rp)
 		lport->tt.rport_logoff(lport->ptp_rp);
-		lport->ptp_rp = NULL;
-	}
-
 	lport->ptp_rp = lport->tt.rport_create(lport, &ids);
+	mutex_unlock(&lport->disc.disc_mutex);
 
 	lport->tt.rport_login(lport->ptp_rp);
 
@@ -931,10 +930,7 @@
 	if (lport->dns_rp)
 		lport->tt.rport_logoff(lport->dns_rp);
 
-	if (lport->ptp_rp) {
-		lport->tt.rport_logoff(lport->ptp_rp);
-		lport->ptp_rp = NULL;
-	}
+	lport->ptp_rp = NULL;
 
 	lport->tt.disc_stop(lport);
 
@@ -1304,7 +1300,9 @@
 
 	fc_lport_state_enter(lport, LPORT_ST_DNS);
 
+	mutex_lock(&lport->disc.disc_mutex);
 	rdata = lport->tt.rport_create(lport, &ids);
+	mutex_unlock(&lport->disc.disc_mutex);
 	if (!rdata)
 		goto err;