lnet_net_unlock(0);
- while (!list_empty(&cull)) {
- tp = list_entry(cull.next, struct lnet_test_peer, tp_list);
-
+ while ((tp = list_first_entry_or_null(&cull,
+ struct lnet_test_peer,
+ tp_list)) != NULL) {
list_del(&tp->tp_list);
LIBCFS_FREE(tp, sizeof(*tp));
}
lnet_net_unlock(0);
- while (!list_empty(&cull)) {
- tp = list_entry(cull.next, struct lnet_test_peer, tp_list);
+ while ((tp = list_first_entry_or_null(&cull,
+ struct lnet_test_peer,
+ tp_list)) != NULL) {
list_del(&tp->tp_list);
-
LIBCFS_FREE(tp, sizeof(*tp));
}
}
LASSERT(!list_empty(&rbp->rbp_bufs));
- rb = list_entry(rbp->rbp_bufs.next, struct lnet_rtrbuf, rb_list);
+ rb = list_first_entry(&rbp->rbp_bufs, struct lnet_rtrbuf, rb_list);
list_del(&rb->rb_list);
msg->msg_niov = rbp->rbp_npages;
tq->tq_credits++;
atomic_inc(&ni->ni_tx_credits);
if (tq->tq_credits <= 0) {
- msg2 = list_entry(tq->tq_delayed.next,
- struct lnet_msg, msg_list);
+ msg2 = list_first_entry(&tq->tq_delayed,
+ struct lnet_msg, msg_list);
list_del(&msg2->msg_list);
LASSERT(msg2->msg_txni == ni);
if (txpeer->lpni_txcredits <= 0) {
int msg2_cpt;
- msg2 = list_entry(txpeer->lpni_txq.next,
- struct lnet_msg, msg_list);
+ msg2 = list_first_entry(&txpeer->lpni_txq,
+ struct lnet_msg, msg_list);
list_del(&msg2->msg_list);
spin_unlock(&txpeer->lpni_lock);
if (list_empty(&rbp->rbp_msgs))
return;
- msg = list_entry(rbp->rbp_msgs.next,
- struct lnet_msg, msg_list);
+ msg = list_first_entry(&rbp->rbp_msgs,
+ struct lnet_msg, msg_list);
list_del(&msg->msg_list);
(void)lnet_post_routed_recv_locked(msg, 1);
} else if (!list_empty(&lp->lp_rtrq)) {
int msg2_cpt;
- msg2 = list_entry(lp->lp_rtrq.next,
- struct lnet_msg, msg_list);
+ msg2 = list_first_entry(&lp->lp_rtrq,
+ struct lnet_msg, msg_list);
list_del(&msg2->msg_list);
msg2_cpt = msg2->msg_rx_cpt;
spin_unlock(&lp->lp_lock);
__u32 send_case = sd->sd_send_case;
int rc;
__u32 routing = send_case & REMOTE_DST;
- struct lnet_rsp_tracker *rspt;
+ struct lnet_rsp_tracker *rspt;
/* Increment sequence number of the selected peer, peer net,
* local ni and local net so that we pick the next ones
* in Round Robin.
*/
- best_lpni->lpni_peer_net->lpn_seq++;
+ best_lpni->lpni_peer_net->lpn_peer->lp_send_seq++;
+ best_lpni->lpni_peer_net->lpn_seq =
+ best_lpni->lpni_peer_net->lpn_peer->lp_send_seq;
best_lpni->lpni_seq = best_lpni->lpni_peer_net->lpn_seq;
- best_ni->ni_net->net_seq++;
+ the_lnet.ln_net_seq++;
+ best_ni->ni_net->net_seq = the_lnet.ln_net_seq;
best_ni->ni_seq = best_ni->ni_net->net_seq;
CDEBUG(D_NET, "%s NI seq info: [%d:%d:%d:%u] %s LPNI seq info [%d:%d:%d:%u]\n",
* lnet_select_pathway() function and is never changed.
* It's safe to use it here.
*/
+ final_dst_lpni->lpni_peer_net->lpn_peer->lp_send_seq++;
+ final_dst_lpni->lpni_peer_net->lpn_seq =
+ final_dst_lpni->lpni_peer_net->lpn_peer->lp_send_seq;
+ final_dst_lpni->lpni_seq =
+ final_dst_lpni->lpni_peer_net->lpn_seq;
msg->msg_hdr.dest_nid = final_dst_lpni->lpni_nid;
} else {
/*
return rc;
}
- new_lpni = lnet_find_peer_ni_locked(lnet_nid_to_nid4(&lpni->lpni_nid));
+ new_lpni = lnet_peer_ni_find_locked(&lpni->lpni_nid);
if (!new_lpni) {
lnet_peer_ni_decref_locked(lpni);
return -ENOENT;
int best_lpn_healthv = 0;
__u32 best_lpn_sel_prio = LNET_MAX_SELECTION_PRIORITY;
- CDEBUG(D_NET, "using src nid %s for route restriction\n",
- src_nid ? libcfs_nidstr(src_nid) : "ANY");
+ CDEBUG(D_NET, "%s route (%s) from local NI %s to destination %s\n",
+ LNET_NID_IS_ANY(&sd->sd_rtr_nid) ? "Lookup" : "Specified",
+ libcfs_nidstr(&sd->sd_rtr_nid), libcfs_nidstr(src_nid),
+ libcfs_nidstr(&sd->sd_dst_nid));
/* If a router nid was specified then we are replying to a GET or
* sending an ACK. In this case we use the gateway associated with the
route_found = true;
} else {
CWARN("No peer NI for gateway %s. Attempting to find an alternative route.\n",
- libcfs_nidstr(&sd->sd_rtr_nid));
+ libcfs_nidstr(&sd->sd_rtr_nid));
}
}
if (!route_found) {
- if (sd->sd_msg->msg_routing || (src_nid && !LNET_NID_IS_ANY(src_nid))) {
+ if (sd->sd_msg->msg_routing || !LNET_NID_IS_ANY(src_nid)) {
/* If I'm routing this message then I need to find the
* next hop based on the destination NID
*
libcfs_nidstr(&sd->sd_dst_nid));
return -EHOSTUNREACH;
}
+ CDEBUG(D_NET, "best_rnet %s\n",
+ libcfs_net2str(best_rnet->lrn_net));
} else {
/* we've already looked up the initial lpni using
* dst_nid
if (!rnet)
continue;
- if (!best_lpn) {
- best_lpn = lpn;
- best_rnet = rnet;
- }
+ if (!best_lpn)
+ goto use_lpn;
+ else
+ CDEBUG(D_NET, "n[%s, %s] h[%d, %d], p[%u, %u], s[%d, %d]\n",
+ libcfs_net2str(lpn->lpn_net_id),
+ libcfs_net2str(best_lpn->lpn_net_id),
+ lpn->lpn_healthv,
+ best_lpn->lpn_healthv,
+ lpn->lpn_sel_priority,
+ best_lpn->lpn_sel_priority,
+ lpn->lpn_seq,
+ best_lpn->lpn_seq);
/* select the preferred peer net */
if (best_lpn_healthv > lpn->lpn_healthv)
return -EHOSTUNREACH;
}
+ CDEBUG(D_NET, "selected best_lpn %s\n",
+ libcfs_net2str(best_lpn->lpn_net_id));
+
sd->sd_best_lpni = lnet_find_best_lpni(sd->sd_best_ni,
lnet_nid_to_nid4(&sd->sd_dst_nid),
lp,
* NI's so update the final destination we selected
*/
sd->sd_final_dst_lpni = sd->sd_best_lpni;
-
- /* Increment the sequence number of the remote lpni so
- * we can round robin over the different interfaces of
- * the remote lpni
- */
- sd->sd_best_lpni->lpni_seq++;
}
/*
*gw_peer = gw;
/*
- * increment the sequence numbers since now we're sure we're
- * going to use this path
+ * increment the sequence number since now we're sure we're
+ * going to use this route
*/
if (LNET_NID_IS_ANY(&sd->sd_rtr_nid)) {
LASSERT(best_route && last_route);
best_route->lr_seq = last_route->lr_seq + 1;
- if (best_lpn)
- best_lpn->lpn_seq++;
}
return 0;
__u32 lpn_sel_prio;
__u32 best_net_sel_prio = LNET_MAX_SELECTION_PRIORITY;
__u32 net_sel_prio;
- bool exit = false;
+
+ /* if this is a discovery message and lp_disc_net_id is
+ * specified then use that net to send the discovery on.
+ */
+ if (discovery && peer->lp_disc_net_id) {
+ best_lpn = lnet_peer_get_net_locked(peer, peer->lp_disc_net_id);
+ if (best_lpn && lnet_get_net_locked(best_lpn->lpn_net_id))
+ goto select_best_ni;
+ }
/*
* The peer can have multiple interfaces, some of them can be on
net_healthv = lnet_get_net_healthv_locked(net);
net_sel_prio = net->net_sel_priority;
- /*
- * if this is a discovery message and lp_disc_net_id is
- * specified then use that net to send the discovery on.
- */
- if (peer->lp_disc_net_id == lpn->lpn_net_id &&
- discovery) {
- exit = true;
- goto select_lpn;
- }
-
if (!best_lpn)
goto select_lpn;
+ else
+ CDEBUG(D_NET,
+ "n[%s, %s] ph[%d, %d], pp[%u, %u], nh[%d, %d], np[%u, %u], ps[%u, %u], ns[%u, %u]\n",
+ libcfs_net2str(lpn->lpn_net_id),
+ libcfs_net2str(best_lpn->lpn_net_id),
+ lpn->lpn_healthv,
+ best_lpn_healthv,
+ lpn_sel_prio,
+ best_lpn_sel_prio,
+ net_healthv,
+ best_net_healthv,
+ net_sel_prio,
+ best_net_sel_prio,
+ lpn->lpn_seq,
+ best_lpn->lpn_seq,
+ net->net_seq,
+ best_net->net_seq);
/* always select the lpn with the best health */
if (best_lpn_healthv > lpn->lpn_healthv)
best_lpn_sel_prio = lpn_sel_prio;
best_lpn = lpn;
best_net = net;
-
- if (exit)
- break;
}
if (best_lpn) {
/* Select the best NI on the same net as best_lpn chosen
* above
*/
+select_best_ni:
+ CDEBUG(D_NET, "selected best_lpn %s\n",
+ libcfs_net2str(best_lpn->lpn_net_id));
best_ni = lnet_find_best_ni_on_spec_net(NULL, peer, best_lpn,
msg, md_cpt);
}
* try to send it via non-multi-rail criteria
*/
if (!IS_ERR(src_lpni)) {
- /* Drop ref taken by lnet_nid2peerni_locked() */
+ /* Drop ref taken by lnet_peerni_by_nid_locked() */
lnet_peer_ni_decref_locked(src_lpni);
src_lp = lpni->lpni_peer_net->lpn_peer;
if (lnet_peer_is_multi_rail(src_lp) &&
/* This is only called when the monitor thread has stopped */
lnet_net_lock(0);
- while (!list_empty(&the_lnet.ln_mt_localNIRecovq)) {
- ni = list_entry(the_lnet.ln_mt_localNIRecovq.next,
- struct lnet_ni, ni_recovery);
+ while ((ni = list_first_entry_or_null(&the_lnet.ln_mt_localNIRecovq,
+ struct lnet_ni,
+ ni_recovery)) != NULL) {
list_del_init(&ni->ni_recovery);
lnet_ni_lock(ni);
lnet_unlink_ni_recovery_mdh_locked(ni, 0, true);
true);
lnet_net_lock(0);
/*
- * lnet_find_peer_ni_locked() grabs a refcount for
+ * lnet_peer_ni_find_locked() grabs a refcount for
* us. No need to take it explicitly.
*/
lpni = lnet_peer_ni_find_locked(&nid);
spin_unlock(&lpni->lpni_lock);
}
- /* Drop the ref taken by lnet_find_peer_ni_locked() */
+ /* Drop the ref taken by lnet_peer_ni_find_locked() */
lnet_peer_ni_decref_locked(lpni);
lnet_net_unlock(0);
} else
void
lnet_drop_delayed_msg_list(struct list_head *head, char *reason)
{
- while (!list_empty(head)) {
+ struct lnet_msg *msg;
+
+ while ((msg = list_first_entry_or_null(head, struct lnet_msg,
+ msg_list)) != NULL) {
struct lnet_processid id = {};
- struct lnet_msg *msg;
- msg = list_entry(head->next, struct lnet_msg, msg_list);
list_del(&msg->msg_list);
id.nid = msg->msg_hdr.src_nid;
void
lnet_recv_delayed_msg_list(struct list_head *head)
{
- while (!list_empty(head)) {
- struct lnet_msg *msg;
+ struct lnet_msg *msg;
+
+ while ((msg = list_first_entry_or_null(head, struct lnet_msg,
+ msg_list)) != NULL) {
struct lnet_processid id;
- msg = list_entry(head->next, struct lnet_msg, msg_list);
list_del(&msg->msg_list);
/* md won't disappear under me, since each msg
int
LNetDist(struct lnet_nid *dstnid, struct lnet_nid *srcnid, __u32 *orderp)
{
- struct list_head *e;
struct lnet_ni *ni = NULL;
struct lnet_remotenet *rnet;
__u32 dstnet = LNET_NID_NET(dstnid);
}
rn_list = lnet_net2rnethash(dstnet);
- list_for_each(e, rn_list) {
- rnet = list_entry(e, struct lnet_remotenet, lrn_list);
-
+ list_for_each_entry(rnet, rn_list, lrn_list) {
if (rnet->lrn_net == dstnet) {
struct lnet_route *route;
struct lnet_route *shortest = NULL;