init_waitqueue_head(&lp->lp_dc_waitq);
spin_lock_init(&lp->lp_lock);
lp->lp_primary_nid = nid;
+ lp->lp_disc_src_nid = LNET_NID_ANY;
if (lnet_peers_start_down())
lp->lp_alive = false;
else
* to ever use a different interface when sending messages to
* myself.
*/
- if (LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
+ if (nid == LNET_NID_LO_0)
lp->lp_state = LNET_PEER_NO_DISCOVERY;
lp->lp_cpt = lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
int rc = 0;
int cpt;
+ if (nid == LNET_NID_LO_0)
+ return LNET_NID_LO_0;
+
cpt = lnet_net_lock_current();
lpni = lnet_nid2peerni_locked(nid, LNET_NID_ANY, cpt);
if (IS_ERR(lpni)) {
lp = lpni->lpni_peer_net->lpn_peer;
while (!lnet_peer_is_uptodate(lp)) {
+ spin_lock(&lp->lp_lock);
+ /* force a full discovery cycle */
+ lp->lp_state |= LNET_PEER_FORCE_PING | LNET_PEER_FORCE_PUSH;
+ spin_unlock(&lp->lp_lock);
+
rc = lnet_discover_peer_locked(lpni, cpt, true);
if (rc)
goto out_decref;
struct lnet_ping_buffer *pbuf;
struct lnet_peer *lp;
- pbuf = LNET_PING_INFO_TO_BUFFER(ev->md.start + ev->offset);
+ pbuf = LNET_PING_INFO_TO_BUFFER(ev->md_start + ev->offset);
/* lnet_find_peer() adds a refcount */
lp = lnet_find_peer(ev->source.nid);
CDEBUG(D_NET, "Peer %s has discovery disabled\n",
libcfs_nid2str(lp->lp_primary_nid));
/*
- * If the peer is going from discovery enabled to
- * discovery disabled, we need to reflect that in our
- * representation of the peer.
+ * Mark the peer for deletion if we already know about it
+ * and it's going from discovery set to no discovery set
*/
- if (!(lp->lp_state & LNET_PEER_NO_DISCOVERY))
+ if (!(lp->lp_state & (LNET_PEER_NO_DISCOVERY |
+ LNET_PEER_DISCOVERING)) &&
+ lp->lp_state & LNET_PEER_DISCOVERED) {
+ CDEBUG(D_NET, "Marking %s:0x%x for deletion\n",
+ libcfs_nid2str(lp->lp_primary_nid),
+ lp->lp_state);
lp->lp_state |= LNET_PEER_MARK_DELETION;
+ }
lp->lp_state |= LNET_PEER_NO_DISCOVERY;
} else if (lp->lp_state & LNET_PEER_NO_DISCOVERY) {
CDEBUG(D_NET, "Peer %s has discovery enabled\n",
{
struct lnet_ping_buffer *pbuf;
- pbuf = LNET_PING_INFO_TO_BUFFER(ev->md.start);
+ pbuf = LNET_PING_INFO_TO_BUFFER(ev->md_start);
spin_lock(&lp->lp_lock);
lp->lp_state &= ~LNET_PEER_PUSH_SENT;
lp->lp_push_error = ev->status;
spin_lock(&lp->lp_lock);
+ lp->lp_disc_src_nid = ev->target.nid;
+
/*
* If some kind of error happened the contents of message
* cannot be used. Set PING_FAILED to trigger a retry.
goto out;
}
- pbuf = LNET_PING_INFO_TO_BUFFER(ev->md.start);
+ pbuf = LNET_PING_INFO_TO_BUFFER(ev->md_start);
if (pbuf->pb_info.pi_magic == __swab32(LNET_PROTO_PING_MAGIC))
lnet_swap_pinginfo(pbuf);
} else {
CDEBUG(D_NET, "Peer %s has discovery disabled\n",
libcfs_nid2str(lp->lp_primary_nid));
- /*
- * If the peer is going from discovery enabled to
- * discovery disabled, we need to reflect that in our
- * representation of the peer.
- */
- if (!(lp->lp_state & LNET_PEER_NO_DISCOVERY))
- lp->lp_state |= LNET_PEER_MARK_DELETION;
lp->lp_state |= LNET_PEER_NO_DISCOVERY;
}
*/
static void lnet_discovery_event_handler(struct lnet_event *event)
{
- struct lnet_peer *lp = event->md.user_ptr;
+ struct lnet_peer *lp = event->md_user_ptr;
struct lnet_ping_buffer *pbuf;
int rc;
}
lnet_net_lock(LNET_LOCK_EX);
if (event->unlinked) {
- pbuf = LNET_PING_INFO_TO_BUFFER(event->md.start);
+ pbuf = LNET_PING_INFO_TO_BUFFER(event->md_start);
lnet_ping_buffer_decref(pbuf);
lnet_peer_decref_locked(lp);
}
* present in curnis[] then this peer is for this node.
*/
for (i = 0; i < ncurnis; i++) {
- if (LNET_NETTYP(LNET_NIDNET(curnis[i])) == LOLND)
+ if (curnis[i] == LNET_NID_LO_0)
continue;
for (j = 1; j < pbuf->pb_info.pi_nnis; j++) {
if (curnis[i] == pbuf->pb_info.pi_ni[j].ns_nid) {
if (pbuf->pb_info.pi_nnis <= 1)
goto out;
nid = pbuf->pb_info.pi_ni[1].ns_nid;
- if (LNET_NETTYP(LNET_NIDNET(lp->lp_primary_nid)) == LOLND) {
+ if (lp->lp_primary_nid == LNET_NID_LO_0) {
rc = lnet_peer_set_primary_nid(lp, nid, flags);
if (!rc)
rc = lnet_peer_merge_data(lp, pbuf);
nnis = max(lp->lp_data_nnis, LNET_INTERFACES_MIN);
rc = lnet_send_ping(pnid, &lp->lp_ping_mdh, nnis, lp,
- the_lnet.ln_dc_eq, false);
+ the_lnet.ln_dc_handler, false);
/*
* if LNetMDBind in lnet_send_ping fails we need to decrement the
return rc ? rc : LNET_REDISCOVER_PEER;
}
+/*
+ * Mark the peer as discovered.
+ */
+static int lnet_peer_discovered(struct lnet_peer *lp)
+__must_hold(&lp->lp_lock)
+{
+ lp->lp_state |= LNET_PEER_DISCOVERED;
+ lp->lp_state &= ~(LNET_PEER_DISCOVERING |
+ LNET_PEER_REDISCOVER);
+
+ CDEBUG(D_NET, "peer %s\n", libcfs_nid2str(lp->lp_primary_nid));
+
+ return 0;
+}
+
/* Active side of push. */
static int lnet_peer_send_push(struct lnet_peer *lp)
__must_hold(&lp->lp_lock)
/* Don't push to a non-multi-rail peer. */
if (!(lp->lp_state & LNET_PEER_MULTI_RAIL)) {
lp->lp_state &= ~LNET_PEER_FORCE_PUSH;
+ /* if peer's NIDs are uptodate then peer is discovered */
+ if (lp->lp_state & LNET_PEER_NIDS_UPTODATE) {
+ rc = lnet_peer_discovered(lp);
+ return rc;
+ }
+
return 0;
}
md.length = LNET_PING_INFO_SIZE(pbuf->pb_nnis);
md.threshold = 2; /* Put/Ack */
md.max_size = 0;
- md.options = 0;
- md.eq_handle = the_lnet.ln_dc_eq;
+ md.options = LNET_MD_TRACK_RESPONSE;
+ md.handler = the_lnet.ln_dc_handler;
md.user_ptr = lp;
- rc = LNetMDBind(md, LNET_UNLINK, &lp->lp_push_mdh);
+ rc = LNetMDBind(&md, LNET_UNLINK, &lp->lp_push_mdh);
if (rc) {
lnet_ping_buffer_decref(pbuf);
CERROR("Can't bind push source MD: %d\n", rc);
goto fail_unlink;
}
- rc = LNetPut(LNET_NID_ANY, lp->lp_push_mdh,
+ rc = LNetPut(lp->lp_disc_src_nid, lp->lp_push_mdh,
LNET_ACK_REQ, id, LNET_RESERVED_PORTAL,
LNET_PROTO_PING_MATCHBITS, 0, 0);
+ /*
+ * reset the discovery nid. There is no need to restrict sending
+ * from that source, if we call lnet_push_update_to_peers(). It'll
+ * get set to a specific NID, if we initiate discovery from the
+ * scratch
+ */
+ lp->lp_disc_src_nid = LNET_NID_ANY;
+
if (rc)
goto fail_unlink;
}
/*
- * Mark the peer as discovered.
- */
-static int lnet_peer_discovered(struct lnet_peer *lp)
-__must_hold(&lp->lp_lock)
-{
- lp->lp_state |= LNET_PEER_DISCOVERED;
- lp->lp_state &= ~(LNET_PEER_DISCOVERING |
- LNET_PEER_REDISCOVER);
-
- CDEBUG(D_NET, "peer %s\n", libcfs_nid2str(lp->lp_primary_nid));
-
- return 0;
-}
-
-
-/*
* Discovering this peer is taking too long. Cancel any Ping or Push
* that discovery is waiting on by unlinking the relevant MDs. The
* lnet_discovery_event_handler() will proceed from here and complete
}
lnet_net_unlock(LNET_LOCK_EX);
- LNetEQFree(the_lnet.ln_dc_eq);
- the_lnet.ln_dc_eq = NULL;
+ lnet_assert_handler_unused(the_lnet.ln_dc_handler);
+ the_lnet.ln_dc_handler = NULL;
the_lnet.ln_dc_state = LNET_DC_STATE_SHUTDOWN;
wake_up(&the_lnet.ln_dc_waitq);
if (the_lnet.ln_dc_state != LNET_DC_STATE_SHUTDOWN)
return -EALREADY;
- the_lnet.ln_dc_eq = LNetEQAlloc(lnet_discovery_event_handler);
- if (IS_ERR(the_lnet.ln_dc_eq)) {
- rc = PTR_ERR(the_lnet.ln_dc_eq);
- CERROR("Can't allocate discovery EQ: %d\n", rc);
- return rc;
- }
-
+ the_lnet.ln_dc_handler = lnet_discovery_event_handler;
the_lnet.ln_dc_state = LNET_DC_STATE_RUNNING;
task = kthread_run(lnet_peer_discovery, NULL, "lnet_discovery");
if (IS_ERR(task)) {
rc = PTR_ERR(task);
CERROR("Can't start peer discovery thread: %d\n", rc);
- LNetEQFree(the_lnet.ln_dc_eq);
- the_lnet.ln_dc_eq = NULL;
+ the_lnet.ln_dc_handler = NULL;
the_lnet.ln_dc_state = LNET_DC_STATE_SHUTDOWN;
}