aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libfc
diff options
context:
space:
mode:
authorJoe Eykholt <jeykholt@cisco.com>2009-08-25 17:01:50 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-09-10 13:07:46 -0400
commit48f00902ba40d3e4467782a42258b952437a89f9 (patch)
tree9559e9a92cadd9988ff32940358c8b6d9dee5140 /drivers/scsi/libfc
parentb5cbf083736e14911c32fca2a93c540a92e8413d (diff)
[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>
Diffstat (limited to 'drivers/scsi/libfc')
-rw-r--r--drivers/scsi/libfc/fc_disc.c8
-rw-r--r--drivers/scsi/libfc/fc_lport.c14
-rw-r--r--drivers/scsi/libfc/fc_rport.c11
3 files changed, 15 insertions, 18 deletions
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index 8427396909e8..e6b13bfecf73 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -115,9 +115,6 @@ static void fc_disc_rport_callback(struct fc_lport *lport,
115 case RPORT_EV_LOGO: 115 case RPORT_EV_LOGO:
116 case RPORT_EV_FAILED: 116 case RPORT_EV_FAILED:
117 case RPORT_EV_STOP: 117 case RPORT_EV_STOP:
118 mutex_lock(&disc->disc_mutex);
119 list_del(&rdata->peers);
120 mutex_unlock(&disc->disc_mutex);
121 break; 118 break;
122 default: 119 default:
123 break; 120 break;
@@ -385,9 +382,6 @@ static int fc_disc_new_target(struct fc_disc *disc,
385 rdata = lport->tt.rport_create(lport, ids); 382 rdata = lport->tt.rport_create(lport, ids);
386 if (!rdata) 383 if (!rdata)
387 error = -ENOMEM; 384 error = -ENOMEM;
388 else
389 list_add_tail(&rdata->peers,
390 &disc->rports);
391 } 385 }
392 } 386 }
393 if (rdata) { 387 if (rdata) {
@@ -562,7 +556,6 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
562 rdata = lport->tt.rport_create(lport, &ids); 556 rdata = lport->tt.rport_create(lport, &ids);
563 if (rdata) { 557 if (rdata) {
564 rdata->ops = &fc_disc_rport_ops; 558 rdata->ops = &fc_disc_rport_ops;
565 list_add_tail(&rdata->peers, &disc->rports);
566 lport->tt.rport_login(rdata); 559 lport->tt.rport_login(rdata);
567 } else 560 } else
568 printk(KERN_WARNING "libfc: Failed to allocate " 561 printk(KERN_WARNING "libfc: Failed to allocate "
@@ -709,7 +702,6 @@ static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp)
709 if (rdata) { 702 if (rdata) {
710 rdata->ops = &fc_disc_rport_ops; 703 rdata->ops = &fc_disc_rport_ops;
711 kfree(dp); 704 kfree(dp);
712 list_add_tail(&rdata->peers, &disc->rports);
713 lport->tt.rport_login(rdata); 705 lport->tt.rport_login(rdata);
714 } 706 }
715 return; 707 return;
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 22c0f7bc004f..f33e5732e3fc 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -205,12 +205,11 @@ static void fc_lport_ptp_setup(struct fc_lport *lport,
205 ids.node_name = remote_wwnn; 205 ids.node_name = remote_wwnn;
206 ids.roles = FC_RPORT_ROLE_UNKNOWN; 206 ids.roles = FC_RPORT_ROLE_UNKNOWN;
207 207
208 if (lport->ptp_rp) { 208 mutex_lock(&lport->disc.disc_mutex);
209 if (lport->ptp_rp)
209 lport->tt.rport_logoff(lport->ptp_rp); 210 lport->tt.rport_logoff(lport->ptp_rp);
210 lport->ptp_rp = NULL;
211 }
212
213 lport->ptp_rp = lport->tt.rport_create(lport, &ids); 211 lport->ptp_rp = lport->tt.rport_create(lport, &ids);
212 mutex_unlock(&lport->disc.disc_mutex);
214 213
215 lport->tt.rport_login(lport->ptp_rp); 214 lport->tt.rport_login(lport->ptp_rp);
216 215
@@ -931,10 +930,7 @@ static void fc_lport_reset_locked(struct fc_lport *lport)
931 if (lport->dns_rp) 930 if (lport->dns_rp)
932 lport->tt.rport_logoff(lport->dns_rp); 931 lport->tt.rport_logoff(lport->dns_rp);
933 932
934 if (lport->ptp_rp) { 933 lport->ptp_rp = NULL;
935 lport->tt.rport_logoff(lport->ptp_rp);
936 lport->ptp_rp = NULL;
937 }
938 934
939 lport->tt.disc_stop(lport); 935 lport->tt.disc_stop(lport);
940 936
@@ -1304,7 +1300,9 @@ static void fc_lport_enter_dns(struct fc_lport *lport)
1304 1300
1305 fc_lport_state_enter(lport, LPORT_ST_DNS); 1301 fc_lport_state_enter(lport, LPORT_ST_DNS);
1306 1302
1303 mutex_lock(&lport->disc.disc_mutex);
1307 rdata = lport->tt.rport_create(lport, &ids); 1304 rdata = lport->tt.rport_create(lport, &ids);
1305 mutex_unlock(&lport->disc.disc_mutex);
1308 if (!rdata) 1306 if (!rdata)
1309 goto err; 1307 goto err;
1310 1308
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 6ecf36d4708c..a9087b31bce9 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -91,8 +91,7 @@ static const char *fc_rport_state_names[] = {
91 * @lport: local port. 91 * @lport: local port.
92 * @ids: remote port identifiers. 92 * @ids: remote port identifiers.
93 * 93 *
94 * Locking note: this may be called without locks held, but 94 * Locking note: must be called with the disc_mutex held.
95 * is usually called from discovery with the disc_mutex held.
96 */ 95 */
97static struct fc_rport_priv *fc_rport_create(struct fc_lport *lport, 96static struct fc_rport_priv *fc_rport_create(struct fc_lport *lport,
98 struct fc_rport_identifiers *ids) 97 struct fc_rport_identifiers *ids)
@@ -115,6 +114,8 @@ static struct fc_rport_priv *fc_rport_create(struct fc_lport *lport,
115 rdata->maxframe_size = FC_MIN_MAX_PAYLOAD; 114 rdata->maxframe_size = FC_MIN_MAX_PAYLOAD;
116 INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout); 115 INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout);
117 INIT_WORK(&rdata->event_work, fc_rport_work); 116 INIT_WORK(&rdata->event_work, fc_rport_work);
117 if (ids->port_id != FC_FID_DIR_SERV)
118 list_add(&rdata->peers, &lport->disc.rports);
118 return rdata; 119 return rdata;
119} 120}
120 121
@@ -258,6 +259,12 @@ static void fc_rport_work(struct work_struct *work)
258 port_id = rdata->ids.port_id; 259 port_id = rdata->ids.port_id;
259 mutex_unlock(&rdata->rp_mutex); 260 mutex_unlock(&rdata->rp_mutex);
260 261
262 if (port_id != FC_FID_DIR_SERV) {
263 mutex_lock(&lport->disc.disc_mutex);
264 list_del(&rdata->peers);
265 mutex_unlock(&lport->disc.disc_mutex);
266 }
267
261 if (rport_ops->event_callback) { 268 if (rport_ops->event_callback) {
262 FC_RPORT_DBG(rdata, "callback ev %d\n", event); 269 FC_RPORT_DBG(rdata, "callback ev %d\n", event);
263 rport_ops->event_callback(lport, rdata, event); 270 rport_ops->event_callback(lport, rdata, event);