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));
}
}
static int
-fail_peer(lnet_nid_t nid4, int outgoing)
+fail_peer(struct lnet_nid *nid, int outgoing)
{
struct lnet_test_peer *tp;
struct list_head *el;
struct list_head *next;
- struct lnet_nid nid;
LIST_HEAD(cull);
int fail = 0;
- lnet_nid4_to_nid(nid4, &nid);
/* NB: use lnet_net_lock(0) to serialize operations on test peers */
lnet_net_lock(0);
}
if (LNET_NID_IS_ANY(&tp->tp_nid) || /* fail every peer */
- nid_same(&nid, &tp->tp_nid)) { /* fail this peer */
+ nid_same(nid, &tp->tp_nid)) { /* fail this peer */
fail = 1;
if (tp->tp_threshold != LNET_MD_THRESH_INF) {
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));
}
}
void
-lnet_prep_send(struct lnet_msg *msg, int type, struct lnet_process_id target,
+lnet_prep_send(struct lnet_msg *msg, int type, struct lnet_processid *target,
unsigned int offset, unsigned int len)
{
msg->msg_type = type;
- msg->msg_target.pid = target.pid;
- lnet_nid4_to_nid(target.nid, &msg->msg_target.nid);
+ msg->msg_target = *target;
msg->msg_len = len;
msg->msg_offset = offset;
lnet_setpayloadbuffer(msg);
memset (&msg->msg_hdr, 0, sizeof (msg->msg_hdr));
- msg->msg_hdr.type = cpu_to_le32(type);
+ msg->msg_hdr.type = type;
/* dest_nid will be overwritten by lnet_select_pathway() */
- msg->msg_hdr.dest_nid = cpu_to_le64(target.nid);
- msg->msg_hdr.dest_pid = cpu_to_le32(target.pid);
+ msg->msg_hdr.dest_nid = target->nid;
+ msg->msg_hdr.dest_pid = target->pid;
/* src_nid will be set later */
- msg->msg_hdr.src_pid = cpu_to_le32(the_lnet.ln_pid);
- msg->msg_hdr.payload_length = cpu_to_le32(len);
+ msg->msg_hdr.src_pid = the_lnet.ln_pid;
+ msg->msg_hdr.payload_length = len;
}
void
!list_empty(&lp->lpni_txq));
msg->msg_peertxcredit = 1;
- lp->lpni_txqnob += msg->msg_len + sizeof(struct lnet_hdr);
+ lp->lpni_txqnob += msg->msg_len + sizeof(struct lnet_hdr_nid4);
lp->lpni_txcredits--;
if (lp->lpni_txcredits < lp->lpni_mintxcredits)
}
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);
LASSERT((txpeer->lpni_txcredits < 0) ==
!list_empty(&txpeer->lpni_txq));
- txpeer->lpni_txqnob -= msg->msg_len + sizeof(struct lnet_hdr);
+ txpeer->lpni_txqnob -= msg->msg_len +
+ sizeof(struct lnet_hdr_nid4);
LASSERT(txpeer->lpni_txqnob >= 0);
txpeer->lpni_txcredits++;
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 best_sel_prio;
unsigned int best_dev_prio;
unsigned int dev_idx = UINT_MAX;
- struct page *page = lnet_get_first_page(md, offset);
- msg->msg_rdma_force = lnet_is_rdma_only_page(page);
+ bool gpu = md ? (md->md_flags & LNET_MD_FLAG_GPU) : false;
+
+ if (gpu) {
+ struct page *page = lnet_get_first_page(md, offset);
- if (msg->msg_rdma_force)
dev_idx = lnet_get_dev_idx(page);
+ }
/*
* If there is no peer_ni that we can send to on this network,
* All distances smaller than the NUMA range
* are treated equally.
*/
- if (distance < lnet_numa_range)
+ if (!gpu && distance < lnet_numa_range)
distance = lnet_numa_range;
/*
continue;
if (best_ni)
- CDEBUG(D_NET, "compare ni %s [c:%d, d:%d, s:%d, p:%u, g:%u] with best_ni %s [c:%d, d:%d, s:%d, p:%u, g:%u]\n",
+ CDEBUG(D_NET, "compare ni %s [c:%d, d:%d, s:%d, p:%u, g:%u, h:%d] with best_ni %s [c:%d, d:%d, s:%d, p:%u, g:%u, h:%d]\n",
libcfs_nidstr(&ni->ni_nid), ni_credits, distance,
- ni->ni_seq, ni_sel_prio, ni_dev_prio,
+ ni->ni_seq, ni_sel_prio, ni_dev_prio, ni_healthv,
(best_ni) ? libcfs_nidstr(&best_ni->ni_nid)
: "not selected", best_credits, shortest_distance,
(best_ni) ? best_ni->ni_seq : 0,
- best_sel_prio, best_dev_prio);
+ best_sel_prio, best_dev_prio, best_healthv);
else
goto select_ni;
return best_ni;
}
+static bool
+lnet_reserved_msg(struct lnet_msg *msg)
+{
+ if (msg->msg_type == LNET_MSG_PUT) {
+ if (msg->msg_hdr.msg.put.ptl_index == LNET_RESERVED_PORTAL)
+ return true;
+ } else if (msg->msg_type == LNET_MSG_GET) {
+ if (msg->msg_hdr.msg.get.ptl_index == LNET_RESERVED_PORTAL)
+ return true;
+ }
+ return false;
+}
+
/*
* Traffic to the LNET_RESERVED_PORTAL may not trigger peer discovery,
* because such traffic is required to perform discovery. We therefore
static bool
lnet_msg_discovery(struct lnet_msg *msg)
{
- if (msg->msg_type == LNET_MSG_PUT) {
- if (msg->msg_hdr.msg.put.ptl_index != LNET_RESERVED_PORTAL)
- return true;
- } else if (msg->msg_type == LNET_MSG_GET) {
- if (msg->msg_hdr.msg.get.ptl_index != LNET_RESERVED_PORTAL)
- return true;
- }
- return false;
+ return !(lnet_reserved_msg(msg) || lnet_msg_is_response(msg));
}
#define SRC_SPEC 0x0001
/* No send credit hassles with LOLND */
lnet_ni_addref_locked(the_lnet.ln_loni, cpt);
- msg->msg_hdr.dest_nid =
- cpu_to_le64(lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid));
+ msg->msg_hdr.dest_nid = the_lnet.ln_loni->ni_nid;
if (!msg->msg_routing)
- msg->msg_hdr.src_nid =
- cpu_to_le64(lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid));
+ msg->msg_hdr.src_nid = the_lnet.ln_loni->ni_nid;
msg->msg_target.nid = the_lnet.ln_loni->ni_nid;
lnet_msg_commit(msg, cpt);
msg->msg_txni = the_lnet.ln_loni;
__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",
* originator and set it here.
*/
if (!msg->msg_routing)
- msg->msg_hdr.src_nid =
- cpu_to_le64(lnet_nid_to_nid4(&msg->msg_txni->ni_nid));
+ msg->msg_hdr.src_nid = msg->msg_txni->ni_nid;
if (routing) {
msg->msg_target_is_router = 1;
* lnet_select_pathway() function and is never changed.
* It's safe to use it here.
*/
- /* FIXME handle large-addr nid */
- msg->msg_hdr.dest_nid =
- cpu_to_le64(lnet_nid_to_nid4(&final_dst_lpni->lpni_nid));
+ 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 {
/*
* if we're not routing set the dest_nid to the best peer
* ni NID that we picked earlier in the algorithm.
*/
- msg->msg_hdr.dest_nid =
- cpu_to_le64(lnet_nid_to_nid4(&msg->msg_txpeer->lpni_nid));
+ msg->msg_hdr.dest_nid = msg->msg_txpeer->lpni_nid;
}
/*
if (!rc)
CDEBUG(D_NET, "TRACE: %s(%s:%s) -> %s(%s:%s) %s : %s try# %d\n",
- libcfs_nid2str(msg->msg_hdr.src_nid),
+ libcfs_nidstr(&msg->msg_hdr.src_nid),
libcfs_nidstr(&msg->msg_txni->ni_nid),
libcfs_nidstr(&sd->sd_src_nid),
- libcfs_nid2str(msg->msg_hdr.dest_nid),
+ libcfs_nidstr(&msg->msg_hdr.dest_nid),
libcfs_nidstr(&sd->sd_dst_nid),
libcfs_nidstr(&msg->msg_txpeer->lpni_nid),
libcfs_nidstr(&sd->sd_rtr_nid),
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);
}
lnet_select_preferred_best_ni(struct lnet_send_data *sd)
{
struct lnet_ni *best_ni = NULL;
- struct lnet_peer_ni *best_lpni = sd->sd_best_lpni;
/*
* We must use a consistent source address when sending to a
*
* So we need to pick the NI the peer prefers for this
* particular network.
+ *
+ * An exception is traffic on LNET_RESERVED_PORTAL. Internal LNet
+ * traffic doesn't care which source NI is used, and we don't actually
+ * want to restrict local recovery pings to a single source NI.
*/
+ if (!lnet_reserved_msg(sd->sd_msg))
+ best_ni = lnet_find_existing_preferred_best_ni(sd->sd_best_lpni,
+ sd->sd_cpt);
- best_ni = lnet_find_existing_preferred_best_ni(sd->sd_best_lpni,
- sd->sd_cpt);
-
- /* if best_ni is still not set just pick one */
- if (!best_ni) {
- best_ni =
- lnet_find_best_ni_on_spec_net(NULL, sd->sd_peer,
+ if (!best_ni)
+ best_ni = lnet_find_best_ni_on_spec_net(NULL, sd->sd_peer,
sd->sd_best_lpni->lpni_peer_net,
sd->sd_msg,
sd->sd_md_cpt);
- /* If there is no best_ni we don't have a route */
- if (!best_ni) {
- CERROR("no path to %s from net %s\n",
- libcfs_nidstr(&best_lpni->lpni_nid),
- libcfs_net2str(best_lpni->lpni_net->net_id));
- return -EHOSTUNREACH;
- }
+
+ /* If there is no best_ni we don't have a route */
+ if (!best_ni) {
+ CERROR("no path to %s from net %s\n",
+ libcfs_nidstr(&sd->sd_best_lpni->lpni_nid),
+ libcfs_net2str(sd->sd_best_lpni->lpni_net->net_id));
+ return -EHOSTUNREACH;
}
sd->sd_best_ni = best_ni;
struct lnet_peer *src_lp;
struct lnet_peer_ni *src_lpni;
- src_lpni = lnet_nid2peerni_locked(msg->msg_hdr.src_nid,
- LNET_NID_ANY, cpt);
+ src_lpni = lnet_peerni_by_nid_locked(&msg->msg_hdr.src_nid,
+ NULL, cpt);
/* We don't fail the send if we hit any errors here. We'll just
* 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) &&
struct lnet_mt_event_info {
enum lnet_mt_event_type mt_type;
- lnet_nid_t mt_nid;
+ struct lnet_nid mt_nid;
};
/* called with res_lock held */
list_del_init(&msg->msg_list);
- lpni = lnet_find_peer_ni_locked(msg->msg_hdr.dest_nid);
+ lpni = lnet_peer_ni_find_locked(&msg->msg_hdr.dest_nid);
if (!lpni) {
lnet_net_unlock(cpt);
CERROR("Expected that a peer is already created for %s\n",
- libcfs_nid2str(msg->msg_hdr.dest_nid));
+ libcfs_nidstr(&msg->msg_hdr.dest_nid));
msg->msg_no_resend = true;
lnet_finalize(msg, -EFAULT);
lnet_net_lock(cpt);
struct lnet_handle_md mdh;
struct lnet_ni *tmp;
struct lnet_ni *ni;
- lnet_nid_t nid;
+ struct lnet_nid nid;
int healthv;
int rc;
time64_t now;
* We'll unlink the mdh in this case below.
*/
LNetInvalidateMDHandle(&ni->ni_ping_mdh);
- /* FIXME need to handle large-addr nid */
- nid = lnet_nid_to_nid4(&ni->ni_nid);
+ nid = ni->ni_nid;
/*
* remove the NI from the local queue and drop the
ev_info->mt_type = MT_TYPE_LOCAL_NI;
ev_info->mt_nid = nid;
- rc = lnet_send_ping(nid, &mdh, LNET_INTERFACES_MIN,
+ rc = lnet_send_ping(&nid, &mdh, LNET_INTERFACES_MIN,
ev_info, the_lnet.ln_mt_handler,
true);
/* lookup the nid again */
lnet_net_lock(0);
- ni = lnet_nid2ni_locked(nid, 0);
+ ni = lnet_nid_to_ni_locked(&nid, 0);
if (!ni) {
/*
* the NI has been deleted when we dropped
/* 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);
struct lnet_handle_md mdh;
struct lnet_peer_ni *lpni;
struct lnet_peer_ni *tmp;
- lnet_nid_t nid;
+ struct lnet_nid nid;
int healthv;
int rc;
time64_t now;
/* look at the comments in lnet_recover_local_nis() */
mdh = lpni->lpni_recovery_ping_mdh;
+ nid = lpni->lpni_nid;
LNetInvalidateMDHandle(&lpni->lpni_recovery_ping_mdh);
- /* FIXME handle large-addr nid */
- nid = lnet_nid_to_nid4(&lpni->lpni_nid);
lnet_net_lock(0);
list_del_init(&lpni->lpni_recovery);
lnet_peer_ni_decref_locked(lpni);
ev_info->mt_type = MT_TYPE_PEER_NI;
ev_info->mt_nid = nid;
- rc = lnet_send_ping(nid, &mdh, LNET_INTERFACES_MIN,
+ rc = lnet_send_ping(&nid, &mdh, LNET_INTERFACES_MIN,
ev_info, the_lnet.ln_mt_handler,
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_find_peer_ni_locked(nid);
+ lpni = lnet_peer_ni_find_locked(&nid);
if (!lpni) {
lnet_net_unlock(0);
LNetMDUnlink(mdh);
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
* Returns < 0 if LNetGet fails
*/
int
-lnet_send_ping(lnet_nid_t dest_nid,
+lnet_send_ping(struct lnet_nid *dest_nid,
struct lnet_handle_md *mdh, int nnis,
void *user_data, lnet_handler_t handler, bool recovery)
{
struct lnet_md md = { NULL };
- struct lnet_process_id id;
+ struct lnet_processid id;
struct lnet_ping_buffer *pbuf;
int rc;
- if (dest_nid == LNET_NID_ANY) {
+ if (LNET_NID_IS_ANY(dest_nid)) {
rc = -EHOSTUNREACH;
goto fail_error;
}
goto fail_error;
}
id.pid = LNET_PID_LUSTRE;
- id.nid = dest_nid;
+ id.nid = *dest_nid;
- rc = LNetGet(LNET_NID_ANY, *mdh, id,
+ rc = LNetGet(NULL, *mdh, &id,
LNET_RESERVED_PORTAL,
LNET_PROTO_PING_MATCHBITS, 0, recovery);
lnet_handle_recovery_reply(struct lnet_mt_event_info *ev_info,
int status, bool send, bool unlink_event)
{
- lnet_nid_t nid = ev_info->mt_nid;
+ struct lnet_nid *nid = &ev_info->mt_nid;
if (ev_info->mt_type == MT_TYPE_LOCAL_NI) {
struct lnet_ni *ni;
lnet_net_lock(0);
- ni = lnet_nid2ni_locked(nid, 0);
+ ni = lnet_nid_to_ni_locked(nid, 0);
if (!ni) {
lnet_net_unlock(0);
return;
if (status != 0) {
CERROR("local NI (%s) recovery failed with %d\n",
- libcfs_nid2str(nid), status);
+ libcfs_nidstr(nid), status);
return;
}
/*
int cpt;
cpt = lnet_net_lock_current();
- lpni = lnet_find_peer_ni_locked(nid);
+ lpni = lnet_peer_ni_find_locked(nid);
if (!lpni) {
lnet_net_unlock(cpt);
return;
if (status != 0)
CERROR("peer NI (%s) recovery failed with %d\n",
- libcfs_nid2str(nid), status);
+ libcfs_nidstr(nid), status);
}
}
switch (event->type) {
case LNET_EVENT_UNLINK:
CDEBUG(D_NET, "%s recovery ping unlinked\n",
- libcfs_nid2str(ev_info->mt_nid));
- /* fallthrough */
+ libcfs_nidstr(&ev_info->mt_nid));
+ fallthrough;
case LNET_EVENT_REPLY:
lnet_handle_recovery_reply(ev_info, event->status, false,
event->type == LNET_EVENT_UNLINK);
break;
case LNET_EVENT_SEND:
CDEBUG(D_NET, "%s recovery message sent %s:%d\n",
- libcfs_nid2str(ev_info->mt_nid),
+ libcfs_nidstr(&ev_info->mt_nid),
(event->status) ? "unsuccessfully" :
"successfully", event->status);
lnet_handle_recovery_reply(ev_info, event->status, true, false);
complete(&the_lnet.ln_mt_wait_complete);
/* block until monitor thread signals that it's done */
+ mutex_unlock(&the_lnet.ln_api_mutex);
down(&the_lnet.ln_mt_signal);
+ mutex_lock(&the_lnet.ln_api_mutex);
LASSERT(the_lnet.ln_mt_state == LNET_MT_STATE_SHUTDOWN);
/* perform cleanup tasks */
ready_delay = true;
goto again;
}
- /* fall through */
+ fallthrough;
case LNET_MATCHMD_DROP:
CNETERR("Dropping PUT from %s portal %d match %llu"
{
struct lnet_match_info info;
struct lnet_hdr *hdr = &msg->msg_hdr;
- struct lnet_process_id source_id;
+ struct lnet_processid source_id;
struct lnet_handle_wire reply_wmd;
int rc;
reply_wmd = hdr->msg.get.return_wmd;
- lnet_prep_send(msg, LNET_MSG_REPLY, source_id,
+ lnet_prep_send(msg, LNET_MSG_REPLY, &source_id,
msg->msg_offset, msg->msg_wanted);
msg->msg_hdr.msg.reply.dst_wmd = reply_wmd;
{
void *private = msg->msg_private;
struct lnet_hdr *hdr = &msg->msg_hdr;
- struct lnet_process_id src = {0};
+ struct lnet_processid src = {};
struct lnet_libmd *md;
unsigned int rlength;
unsigned int mlength;
if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
CNETERR("%s: Dropping REPLY from %s for %s "
"MD %#llx.%#llx\n",
- libcfs_nidstr(&ni->ni_nid), libcfs_id2str(src),
+ libcfs_nidstr(&ni->ni_nid), libcfs_idstr(&src),
(md == NULL) ? "invalid" : "inactive",
hdr->msg.reply.dst_wmd.wh_interface_cookie,
hdr->msg.reply.dst_wmd.wh_object_cookie);
(md->md_options & LNET_MD_TRUNCATE) == 0) {
CNETERR("%s: Dropping REPLY from %s length %d "
"for MD %#llx would overflow (%d)\n",
- libcfs_nidstr(&ni->ni_nid), libcfs_id2str(src),
+ libcfs_nidstr(&ni->ni_nid), libcfs_idstr(&src),
rlength, hdr->msg.reply.dst_wmd.wh_object_cookie,
mlength);
lnet_res_unlock(cpt);
}
CDEBUG(D_NET, "%s: Reply from %s of length %d/%d into md %#llx\n",
- libcfs_nidstr(&ni->ni_nid), libcfs_id2str(src),
+ libcfs_nidstr(&ni->ni_nid), libcfs_idstr(&src),
mlength, rlength, hdr->msg.reply.dst_wmd.wh_object_cookie);
lnet_msg_attach_md(msg, md, 0, mlength);
lnet_parse_ack(struct lnet_ni *ni, struct lnet_msg *msg)
{
struct lnet_hdr *hdr = &msg->msg_hdr;
- struct lnet_process_id src = {0};
+ struct lnet_processid src = {};
struct lnet_libmd *md;
int cpt;
/* Don't moan; this is expected */
CDEBUG(D_NET,
"%s: Dropping ACK from %s to %s MD %#llx.%#llx\n",
- libcfs_nidstr(&ni->ni_nid), libcfs_id2str(src),
+ libcfs_nidstr(&ni->ni_nid), libcfs_idstr(&src),
(md == NULL) ? "invalid" : "inactive",
hdr->msg.ack.dst_wmd.wh_interface_cookie,
hdr->msg.ack.dst_wmd.wh_object_cookie);
}
CDEBUG(D_NET, "%s: ACK from %s into md %#llx\n",
- libcfs_nidstr(&ni->ni_nid), libcfs_id2str(src),
+ libcfs_nidstr(&ni->ni_nid), libcfs_idstr(&src),
hdr->msg.ack.dst_wmd.wh_object_cookie);
lnet_msg_attach_md(msg, md, 0, 0);
EXPORT_SYMBOL(lnet_msgtyp2str);
int
-lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
- void *private, int rdma_req)
+lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr,
+ struct lnet_nid *from_nid, void *private, int rdma_req)
{
struct lnet_peer_ni *lpni;
struct lnet_msg *msg;
__u32 payload_length;
lnet_pid_t dest_pid;
- lnet_nid_t dest_nid;
- lnet_nid_t src_nid;
- struct lnet_nid from_nid;
+ struct lnet_nid dest_nid;
+ struct lnet_nid src_nid;
bool push = false;
int for_me;
__u32 type;
int rc = 0;
int cpt;
+ time64_t now = ktime_get_seconds();
LASSERT (!in_interrupt ());
- lnet_nid4_to_nid(from_nid4, &from_nid);
+ type = hdr->type;
+ src_nid = hdr->src_nid;
+ dest_nid = hdr->dest_nid;
+ dest_pid = hdr->dest_pid;
+ payload_length = hdr->payload_length;
- type = le32_to_cpu(hdr->type);
- src_nid = le64_to_cpu(hdr->src_nid);
- dest_nid = le64_to_cpu(hdr->dest_nid);
- dest_pid = le32_to_cpu(hdr->dest_pid);
- payload_length = le32_to_cpu(hdr->payload_length);
-
- /* FIXME handle large-addr nids */
- for_me = (lnet_nid_to_nid4(&ni->ni_nid) == dest_nid);
- cpt = lnet_cpt_of_nid(from_nid4, ni);
+ for_me = nid_same(&ni->ni_nid, &dest_nid);
+ cpt = lnet_nid2cpt(from_nid, ni);
CDEBUG(D_NET, "TRACE: %s(%s) <- %s : %s - %s\n",
- libcfs_nid2str(dest_nid),
+ libcfs_nidstr(&dest_nid),
libcfs_nidstr(&ni->ni_nid),
- libcfs_nid2str(src_nid),
+ libcfs_nidstr(&src_nid),
lnet_msgtyp2str(type),
(for_me) ? "for me" : "routed");
case LNET_MSG_GET:
if (payload_length > 0) {
CERROR("%s, src %s: bad %s payload %d (0 expected)\n",
- libcfs_nid2str(from_nid4),
- libcfs_nid2str(src_nid),
+ libcfs_nidstr(from_nid),
+ libcfs_nidstr(&src_nid),
lnet_msgtyp2str(type), payload_length);
return -EPROTO;
}
(__u32)(for_me ? LNET_MAX_PAYLOAD : LNET_MTU)) {
CERROR("%s, src %s: bad %s payload %d "
"(%d max expected)\n",
- libcfs_nid2str(from_nid4),
- libcfs_nid2str(src_nid),
+ libcfs_nidstr(from_nid),
+ libcfs_nidstr(&src_nid),
lnet_msgtyp2str(type),
payload_length,
for_me ? LNET_MAX_PAYLOAD : LNET_MTU);
default:
CERROR("%s, src %s: Bad message type 0x%x\n",
- libcfs_nid2str(from_nid4),
- libcfs_nid2str(src_nid), type);
+ libcfs_nidstr(from_nid),
+ libcfs_nidstr(&src_nid), type);
return -EPROTO;
}
- if (the_lnet.ln_routing &&
- ni->ni_net->net_last_alive != ktime_get_real_seconds()) {
+ /* Only update net_last_alive for incoming GETs on the reserved portal
+ * (i.e. incoming lnet/discovery pings).
+ * This avoids situations where the router's own traffic results in NI
+ * status changes
+ */
+ if (the_lnet.ln_routing && type == LNET_MSG_GET &&
+ hdr->msg.get.ptl_index == LNET_RESERVED_PORTAL &&
+ !lnet_islocalnid(&src_nid) &&
+ ni->ni_net->net_last_alive != now) {
lnet_ni_lock(ni);
spin_lock(&ni->ni_net->net_lock);
- ni->ni_net->net_last_alive = ktime_get_real_seconds();
+ ni->ni_net->net_last_alive = now;
spin_unlock(&ni->ni_net->net_lock);
push = lnet_ni_set_status_locked(ni, LNET_NI_STATUS_UP);
lnet_ni_unlock(ni);
* or malicious so we chop them off at the knees :) */
if (!for_me) {
- if (LNET_NIDNET(dest_nid) == LNET_NID_NET(&ni->ni_nid)) {
+ if (LNET_NID_NET(&dest_nid) == LNET_NID_NET(&ni->ni_nid)) {
/* should have gone direct */
CERROR("%s, src %s: Bad dest nid %s "
"(should have been sent direct)\n",
- libcfs_nid2str(from_nid4),
- libcfs_nid2str(src_nid),
- libcfs_nid2str(dest_nid));
+ libcfs_nidstr(from_nid),
+ libcfs_nidstr(&src_nid),
+ libcfs_nidstr(&dest_nid));
return -EPROTO;
}
- if (lnet_islocalnid4(dest_nid)) {
+ if (lnet_islocalnid(&dest_nid)) {
/* dest is another local NI; sender should have used
* this node's NID on its own network */
CERROR("%s, src %s: Bad dest nid %s "
"(it's my nid but on a different network)\n",
- libcfs_nid2str(from_nid4),
- libcfs_nid2str(src_nid),
- libcfs_nid2str(dest_nid));
+ libcfs_nidstr(from_nid),
+ libcfs_nidstr(&src_nid),
+ libcfs_nidstr(&dest_nid));
return -EPROTO;
}
if (rdma_req && type == LNET_MSG_GET) {
CERROR("%s, src %s: Bad optimized GET for %s "
"(final destination must be me)\n",
- libcfs_nid2str(from_nid4),
- libcfs_nid2str(src_nid),
- libcfs_nid2str(dest_nid));
+ libcfs_nidstr(from_nid),
+ libcfs_nidstr(&src_nid),
+ libcfs_nidstr(&dest_nid));
return -EPROTO;
}
if (!the_lnet.ln_routing) {
CERROR("%s, src %s: Dropping message for %s "
"(routing not enabled)\n",
- libcfs_nid2str(from_nid4),
- libcfs_nid2str(src_nid),
- libcfs_nid2str(dest_nid));
+ libcfs_nidstr(from_nid),
+ libcfs_nidstr(&src_nid),
+ libcfs_nidstr(&dest_nid));
goto drop;
}
}
* call back lnd_recv() come what may... */
if (!list_empty(&the_lnet.ln_test_peers) && /* normally we don't */
- fail_peer(src_nid, 0)) { /* shall we now? */
+ fail_peer(&src_nid, 0)) { /* shall we now? */
CERROR("%s, src %s: Dropping %s to simulate failure\n",
- libcfs_nid2str(from_nid4), libcfs_nid2str(src_nid),
+ libcfs_nidstr(from_nid), libcfs_nidstr(&src_nid),
lnet_msgtyp2str(type));
goto drop;
}
- /* FIXME need to support large-addr nid */
if (!list_empty(&the_lnet.ln_drop_rules) &&
- lnet_drop_rule_match(hdr, lnet_nid_to_nid4(&ni->ni_nid), NULL)) {
+ lnet_drop_rule_match(hdr, &ni->ni_nid, NULL)) {
CDEBUG(D_NET,
"%s, src %s, dst %s: Dropping %s to simulate silent message loss\n",
- libcfs_nid2str(from_nid4), libcfs_nid2str(src_nid),
- libcfs_nid2str(dest_nid), lnet_msgtyp2str(type));
+ libcfs_nidstr(from_nid), libcfs_nidstr(&src_nid),
+ libcfs_nidstr(&dest_nid), lnet_msgtyp2str(type));
goto drop;
}
msg = lnet_msg_alloc();
if (msg == NULL) {
CERROR("%s, src %s: Dropping %s (out of memory)\n",
- libcfs_nid2str(from_nid4), libcfs_nid2str(src_nid),
+ libcfs_nidstr(from_nid), libcfs_nidstr(&src_nid),
lnet_msgtyp2str(type));
goto drop;
}
msg->msg_offset = 0;
msg->msg_hdr = *hdr;
/* for building message event */
- msg->msg_from = from_nid;
+ msg->msg_from = *from_nid;
if (!for_me) {
- msg->msg_target.pid = dest_pid;
- lnet_nid4_to_nid(dest_nid, &msg->msg_target.nid);
- msg->msg_routing = 1;
-
- } else {
- /* convert common msg->hdr fields to host byteorder */
- msg->msg_hdr.type = type;
- msg->msg_hdr.src_nid = src_nid;
- msg->msg_hdr.src_pid = le32_to_cpu(msg->msg_hdr.src_pid);
- msg->msg_hdr.dest_nid = dest_nid;
- msg->msg_hdr.dest_pid = dest_pid;
- msg->msg_hdr.payload_length = payload_length;
+ msg->msg_target.pid = dest_pid;
+ msg->msg_target.nid = dest_nid;
+ msg->msg_routing = 1;
}
lnet_net_lock(cpt);
- lpni = lnet_peerni_by_nid_locked(&from_nid, &ni->ni_nid, cpt);
+ lpni = lnet_peerni_by_nid_locked(from_nid, &ni->ni_nid, cpt);
if (IS_ERR(lpni)) {
lnet_net_unlock(cpt);
rc = PTR_ERR(lpni);
CERROR("%s, src %s: Dropping %s (error %d looking up sender)\n",
- libcfs_nid2str(from_nid4), libcfs_nid2str(src_nid),
+ libcfs_nidstr(from_nid), libcfs_nidstr(&src_nid),
lnet_msgtyp2str(type), rc);
lnet_msg_free(msg);
if (rc == -ESHUTDOWN)
/* We are shutting down. Don't do anything more */
- return 0;
+ return rc;
goto drop;
}
*/
if (((lnet_drop_asym_route && for_me) ||
!lpni->lpni_peer_net->lpn_peer->lp_alive) &&
- LNET_NIDNET(src_nid) != LNET_NIDNET(from_nid4)) {
- __u32 src_net_id = LNET_NIDNET(src_nid);
+ LNET_NID_NET(&src_nid) != LNET_NID_NET(from_nid)) {
+ __u32 src_net_id = LNET_NID_NET(&src_nid);
struct lnet_peer *gw = lpni->lpni_peer_net->lpn_peer;
struct lnet_route *route;
bool found = false;
* => asymmetric routing detected but forbidden
*/
CERROR("%s, src %s: Dropping asymmetrical route %s\n",
- libcfs_nid2str(from_nid4),
- libcfs_nid2str(src_nid), lnet_msgtyp2str(type));
+ libcfs_nidstr(from_nid),
+ libcfs_nidstr(&src_nid), lnet_msgtyp2str(type));
lnet_msg_free(msg);
goto drop;
}
}
}
- lpni->lpni_last_alive = ktime_get_seconds();
+ lpni->lpni_last_alive = now;
msg->msg_rxpeer = lpni;
msg->msg_rxni = ni;
lnet_ni_addref_locked(ni, cpt);
/* Multi-Rail: Primary NID of source. */
- lnet_peer_primary_nid_locked(src_nid, &msg->msg_initiator);
+ lnet_peer_primary_nid_locked(&src_nid, &msg->msg_initiator);
/*
* mark the status of this lpni as UP since we received a message
void
lnet_drop_delayed_msg_list(struct list_head *head, char *reason)
{
- while (!list_empty(head)) {
- struct lnet_process_id id = {0};
- 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);
id.nid = msg->msg_hdr.src_nid;
CWARN("Dropping delayed PUT from %s portal %d match %llu"
" offset %d length %d: %s\n",
- libcfs_id2str(id),
+ libcfs_idstr(&id),
msg->msg_hdr.msg.put.ptl_index,
msg->msg_hdr.msg.put.match_bits,
msg->msg_hdr.msg.put.offset,
void
lnet_recv_delayed_msg_list(struct list_head *head)
{
- while (!list_empty(head)) {
- struct lnet_msg *msg;
- struct lnet_process_id id;
+ 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
CDEBUG(D_NET, "Resuming delayed PUT from %s portal %d "
"match %llu offset %d length %d.\n",
- libcfs_id2str(id), msg->msg_hdr.msg.put.ptl_index,
+ libcfs_idstr(&id), msg->msg_hdr.msg.put.ptl_index,
msg->msg_hdr.msg.put.match_bits,
msg->msg_hdr.msg.put.offset,
msg->msg_hdr.payload_length);
* \see struct lnet_event::hdr_data and lnet_event_kind_t.
*/
int
-LNetPut(lnet_nid_t self4, struct lnet_handle_md mdh, enum lnet_ack_req ack,
- struct lnet_process_id target, unsigned int portal,
+LNetPut(struct lnet_nid *self, struct lnet_handle_md mdh, enum lnet_ack_req ack,
+ struct lnet_processid *target, unsigned int portal,
__u64 match_bits, unsigned int offset,
__u64 hdr_data)
{
int cpt;
int rc;
struct lnet_rsp_tracker *rspt = NULL;
- struct lnet_nid self;
LASSERT(the_lnet.ln_refcount > 0);
- lnet_nid4_to_nid(self4, &self);
-
if (!list_empty(&the_lnet.ln_test_peers) && /* normally we don't */
- fail_peer(target.nid, 1)) { /* shall we now? */
+ fail_peer(&target->nid, 1)) { /* shall we now? */
CERROR("Dropping PUT to %s: simulated failure\n",
- libcfs_id2str(target));
+ libcfs_idstr(target));
return -EIO;
}
msg = lnet_msg_alloc();
if (msg == NULL) {
CERROR("Dropping PUT to %s: ENOMEM on struct lnet_msg\n",
- libcfs_id2str(target));
+ libcfs_idstr(target));
return -ENOMEM;
}
msg->msg_vmflush = !!(current->flags & PF_MEMALLOC);
rspt = lnet_rspt_alloc(cpt);
if (!rspt) {
CERROR("Dropping PUT to %s: ENOMEM on response tracker\n",
- libcfs_id2str(target));
+ libcfs_idstr(target));
return -ENOMEM;
}
INIT_LIST_HEAD(&rspt->rspt_on_list);
md = lnet_handle2md(&mdh);
if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
CERROR("Dropping PUT (%llu:%d:%s): MD (%d) invalid\n",
- match_bits, portal, libcfs_id2str(target),
+ match_bits, portal, libcfs_idstr(target),
md == NULL ? -1 : md->md_threshold);
if (md != NULL && md->md_me != NULL)
CERROR("Source MD also attached to portal %d\n",
return -ENOENT;
}
- CDEBUG(D_NET, "LNetPut -> %s\n", libcfs_id2str(target));
+ CDEBUG(D_NET, "%s -> %s\n", __func__, libcfs_idstr(target));
lnet_msg_attach_md(msg, md, 0, 0);
CFS_FAIL_ONCE))
rc = -EIO;
else
- rc = lnet_send(&self, msg, NULL);
+ rc = lnet_send(self, msg, NULL);
if (rc != 0) {
CNETERR("Error sending PUT to %s: %d\n",
- libcfs_id2str(target), rc);
+ libcfs_idstr(target), rc);
msg->msg_no_resend = true;
lnet_finalize(msg, rc);
}
getmsg->msg_txpeer->lpni_peer_net->lpn_peer->lp_primary_nid;
msg->msg_from = peer_id->nid;
msg->msg_type = LNET_MSG_GET; /* flag this msg as an "optimized" GET */
- msg->msg_hdr.src_nid = lnet_nid_to_nid4(&peer_id->nid);
+ msg->msg_hdr.src_nid = peer_id->nid;
msg->msg_hdr.payload_length = getmd->md_length;
msg->msg_receiving = 1; /* required by lnet_msg_attach_md */
* \retval -ENOENT Invalid MD object.
*/
int
-LNetGet(lnet_nid_t self4, struct lnet_handle_md mdh,
- struct lnet_process_id target, unsigned int portal,
+LNetGet(struct lnet_nid *self, struct lnet_handle_md mdh,
+ struct lnet_processid *target, unsigned int portal,
__u64 match_bits, unsigned int offset, bool recovery)
{
struct lnet_msg *msg;
struct lnet_rsp_tracker *rspt;
int cpt;
int rc;
- struct lnet_nid self;
LASSERT(the_lnet.ln_refcount > 0);
- lnet_nid4_to_nid(self4, &self);
-
if (!list_empty(&the_lnet.ln_test_peers) && /* normally we don't */
- fail_peer(target.nid, 1)) /* shall we now? */
+ fail_peer(&target->nid, 1)) /* shall we now? */
{
CERROR("Dropping GET to %s: simulated failure\n",
- libcfs_id2str(target));
+ libcfs_idstr(target));
return -EIO;
}
msg = lnet_msg_alloc();
if (!msg) {
CERROR("Dropping GET to %s: ENOMEM on struct lnet_msg\n",
- libcfs_id2str(target));
+ libcfs_idstr(target));
return -ENOMEM;
}
rspt = lnet_rspt_alloc(cpt);
if (!rspt) {
CERROR("Dropping GET to %s: ENOMEM on response tracker\n",
- libcfs_id2str(target));
+ libcfs_idstr(target));
return -ENOMEM;
}
INIT_LIST_HEAD(&rspt->rspt_on_list);
md = lnet_handle2md(&mdh);
if (md == NULL || md->md_threshold == 0 || md->md_me != NULL) {
CERROR("Dropping GET (%llu:%d:%s): MD (%d) invalid\n",
- match_bits, portal, libcfs_id2str(target),
+ match_bits, portal, libcfs_idstr(target),
md == NULL ? -1 : md->md_threshold);
if (md != NULL && md->md_me != NULL)
CERROR("REPLY MD also attached to portal %d\n",
return -ENOENT;
}
- CDEBUG(D_NET, "LNetGet -> %s\n", libcfs_id2str(target));
+ CDEBUG(D_NET, "%s -> %s\n", __func__, libcfs_idstr(target));
lnet_msg_attach_md(msg, md, 0, 0);
else
lnet_rspt_free(rspt, cpt);
- rc = lnet_send(&self, msg, NULL);
+ rc = lnet_send(self, msg, NULL);
if (rc < 0) {
CNETERR("Error sending GET to %s: %d\n",
- libcfs_id2str(target), rc);
+ libcfs_idstr(target), rc);
msg->msg_no_resend = true;
lnet_finalize(msg, rc);
}
* \retval -EHOSTUNREACH If \a dstnid is not reachable.
*/
int
-LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
+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_NIDNET(dstnid);
+ __u32 dstnet = LNET_NID_NET(dstnid);
int hops;
int cpt;
__u32 order = 2;
struct list_head *rn_list;
- bool matched_dstnet = false;
+ struct lnet_ni *matched_dstnet = NULL;
/* if !local_nid_dist_zero, I don't return a distance of 0 ever
* (when lustre sees a distance of 0, it substitutes 0@lo), so I
* keep order 0 free for 0@lo and order 1 free for a local NID
- * match */
+ * match
+ * WARNING: dstnid and srcnid might point to same place.
+ * Don't set *srcnid until late.
+ */
LASSERT(the_lnet.ln_refcount > 0);
cpt = lnet_net_lock_current();
while ((ni = lnet_get_next_ni_locked(NULL, ni))) {
- /* FIXME support large-addr nid */
- if (lnet_nid_to_nid4(&ni->ni_nid) == dstnid) {
- if (srcnidp != NULL)
- *srcnidp = dstnid;
+ if (nid_same(&ni->ni_nid, dstnid)) {
if (orderp != NULL) {
- if (dstnid == LNET_NID_LO_0)
+ if (nid_is_lo0(dstnid))
*orderp = 0;
else
*orderp = 1;
}
+ if (srcnid)
+ *srcnid = *dstnid;
lnet_net_unlock(cpt);
return local_nid_dist_zero ? 0 : 1;
}
if (!matched_dstnet && LNET_NID_NET(&ni->ni_nid) == dstnet) {
- matched_dstnet = true;
+ matched_dstnet = ni;
/* We matched the destination net, but we may have
* additional local NIs to inspect.
*
- * We record the nid and order as appropriate, but
+ * We record the order as appropriate, but
* they may be overwritten if we match local NI above.
*/
- if (srcnidp)
- /* FIXME support large-addr nids */
- *srcnidp = lnet_nid_to_nid4(&ni->ni_nid);
if (orderp) {
/* Check if ni was originally created in
}
if (matched_dstnet) {
+ if (srcnid)
+ *srcnid = matched_dstnet->ni_nid;
lnet_net_unlock(cpt);
return 1;
}
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;
LASSERT(shortest != NULL);
hops = shortest_hops;
- if (srcnidp != NULL) {
+ if (srcnid) {
struct lnet_net *net;
net = lnet_get_net_locked(shortest->lr_lnet);
LASSERT(net);
ni = lnet_get_next_ni_locked(net, NULL);
- /* FIXME support large-addr nids */
- *srcnidp = lnet_nid_to_nid4(&ni->ni_nid);
+ *srcnid = ni->ni_nid;
}
if (orderp != NULL)
*orderp = order;