case RPORT_EV_LOGO:
case RPORT_EV_FAILED:
case RPORT_EV_STOP:
- mutex_lock(&disc->disc_mutex);
- list_del(&rdata->peers);
- mutex_unlock(&disc->disc_mutex);
break;
default:
break;
rdata = lport->tt.rport_create(lport, ids);
if (!rdata)
error = -ENOMEM;
- else
- list_add_tail(&rdata->peers,
- &disc->rports);
}
}
if (rdata) {
rdata = lport->tt.rport_create(lport, &ids);
if (rdata) {
rdata->ops = &fc_disc_rport_ops;
- list_add_tail(&rdata->peers, &disc->rports);
lport->tt.rport_login(rdata);
} else
printk(KERN_WARNING "libfc: Failed to allocate "
if (rdata) {
rdata->ops = &fc_disc_rport_ops;
kfree(dp);
- list_add_tail(&rdata->peers, &disc->rports);
lport->tt.rport_login(rdata);
}
return;
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);
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);
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;
* @lport: local port.
* @ids: remote port identifiers.
*
- * Locking note: this may be called without locks held, but
- * is usually called from discovery with the disc_mutex held.
+ * Locking note: must be called with the disc_mutex held.
*/
static struct fc_rport_priv *fc_rport_create(struct fc_lport *lport,
struct fc_rport_identifiers *ids)
rdata->maxframe_size = FC_MIN_MAX_PAYLOAD;
INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout);
INIT_WORK(&rdata->event_work, fc_rport_work);
+ if (ids->port_id != FC_FID_DIR_SERV)
+ list_add(&rdata->peers, &lport->disc.rports);
return rdata;
}
port_id = rdata->ids.port_id;
mutex_unlock(&rdata->rp_mutex);
+ if (port_id != FC_FID_DIR_SERV) {
+ mutex_lock(&lport->disc.disc_mutex);
+ list_del(&rdata->peers);
+ mutex_unlock(&lport->disc.disc_mutex);
+ }
+
if (rport_ops->event_callback) {
FC_RPORT_DBG(rdata, "callback ev %d\n", event);
rport_ops->event_callback(lport, rdata, event);