From 36dd83ee8e143a4726317565e1bdc8834edcbe70 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Wed, 18 Aug 2021 16:31:46 -0400 Subject: [PATCH] LU-10391 lnet: change lp_primary_nid to struct lnet_nid Change lp_primary_nid in struct lnet_peer to struct lnet_nid. Test-Parameters: trivial Test-Parameters: serverversion=2.12 serverdistro=el7.9 testlist=runtests Test-Parameters: clientversion=2.12 testlist=runtests Signed-off-by: Mr NeilBrown Change-Id: I386e85062257f6f8832ffdf4b9603c0e1c072dae Reviewed-on: https://review.whamcloud.com/42102 Reviewed-by: James Simmons Tested-by: jenkins Tested-by: Maloo Reviewed-by: Chris Horn Reviewed-by: Serguei Smirnov Reviewed-by: Oleg Drokin --- lnet/include/lnet/lib-lnet.h | 10 +- lnet/include/lnet/lib-types.h | 2 +- lnet/lnet/api-ni.c | 43 ++++++-- lnet/lnet/lib-move.c | 7 +- lnet/lnet/peer.c | 247 ++++++++++++++++++++++++------------------ lnet/lnet/router.c | 42 +++---- lnet/lnet/router_proc.c | 4 +- lnet/lnet/udsp.c | 8 +- 8 files changed, 216 insertions(+), 147 deletions(-) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 30b87c7..fbbc0d6 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -520,7 +520,8 @@ lnet_net2rnethash(__u32 net) extern const struct lnet_lnd the_lolnd; extern int avoid_asym_router_failure; -extern unsigned int lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number); +extern unsigned int lnet_nid_cpt_hash(struct lnet_nid *nid, + unsigned int number); extern int lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni); extern int lnet_cpt_of_nid(lnet_nid_t nid, struct lnet_ni *ni); extern struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt); @@ -907,6 +908,7 @@ struct lnet_peer_ni *lnet_nid2peerni_ex(lnet_nid_t nid, int cpt); struct lnet_peer_ni *lnet_peer_get_ni_locked(struct lnet_peer *lp, lnet_nid_t nid); struct lnet_peer_ni *lnet_find_peer_ni_locked(lnet_nid_t nid); +struct lnet_peer_ni *lnet_peer_ni_find_locked(struct lnet_nid *nid); struct lnet_peer *lnet_find_peer(lnet_nid_t nid); void lnet_peer_net_added(struct lnet_net *net); lnet_nid_t lnet_peer_primary_nid_locked(lnet_nid_t nid); @@ -978,8 +980,8 @@ lnet_peer_ni_is_configured(struct lnet_peer_ni *lpni) static inline bool lnet_peer_ni_is_primary(struct lnet_peer_ni *lpni) { - return lnet_nid_to_nid4(&lpni->lpni_nid) == - lpni->lpni_peer_net->lpn_peer->lp_primary_nid; + return nid_same(&lpni->lpni_nid, + &lpni->lpni_peer_net->lpn_peer->lp_primary_nid); } bool lnet_peer_is_uptodate(struct lnet_peer *lp); @@ -1153,7 +1155,7 @@ lnet_set_route_aliveness(struct lnet_route *route, bool alive) if (old != alive) CERROR("route to %s through %s has gone from %s to %s\n", libcfs_net2str(route->lr_net), - libcfs_nid2str(route->lr_gateway->lp_primary_nid), + libcfs_nidstr(&route->lr_gateway->lp_primary_nid), old ? "up" : "down", alive ? "up" : "down"); } diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index 6946e90..0543264 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -660,7 +660,7 @@ struct lnet_peer { struct list_head lp_rtr_list; /* primary NID of the peer */ - lnet_nid_t lp_primary_nid; + struct lnet_nid lp_primary_nid; /* source NID to use during discovery */ lnet_nid_t lp_disc_src_nid; diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index fb2fbdf..9f67e03 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -1507,8 +1507,8 @@ lnet_net_is_pref_rtr_locked(struct lnet_net *net, lnet_nid_t rtr_nid) return false; } -unsigned int -lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number) +static unsigned int +lnet_nid4_cpt_hash(lnet_nid_t nid, unsigned int number) { __u64 key = nid; unsigned int val; @@ -1526,12 +1526,33 @@ lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number) return (unsigned int)(key + val + (val >> 1)) % number; } +unsigned int +lnet_nid_cpt_hash(struct lnet_nid *nid, unsigned int number) +{ + unsigned int val; + u32 h = 0; + int i; + + LASSERT(number >= 1 && number <= LNET_CPT_NUMBER); + + if (number == 1) + return 0; + + if (nid_is_nid4(nid)) + return lnet_nid4_cpt_hash(lnet_nid_to_nid4(nid), number); + + for (i = 0; i < 4; i++) + h = hash_32(nid->nid_addr[i]^h, 32); + val = hash_32(LNET_NID_NET(nid) ^ h, LNET_CPT_BITS); + if (val < number) + return val; + return (unsigned int)(h + val + (val >> 1)) % number; +} + int lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni) { struct lnet_net *net; - /* FIXME handle long-addr nid */ - lnet_nid_t nid4 = lnet_nid_to_nid4(nid); /* must called with hold of lnet_net_lock */ if (LNET_CPT_NUMBER == 1) @@ -1546,20 +1567,20 @@ lnet_cpt_of_nid_locked(struct lnet_nid *nid, struct lnet_ni *ni) */ if (ni != NULL) { if (ni->ni_cpts != NULL) - return ni->ni_cpts[lnet_nid_cpt_hash(nid4, + return ni->ni_cpts[lnet_nid_cpt_hash(nid, ni->ni_ncpts)]; else - return lnet_nid_cpt_hash(nid4, LNET_CPT_NUMBER); + return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER); } /* no NI provided so look at the net */ net = lnet_get_net_locked(LNET_NID_NET(nid)); if (net != NULL && net->net_cpts != NULL) { - return net->net_cpts[lnet_nid_cpt_hash(nid4, net->net_ncpts)]; + return net->net_cpts[lnet_nid_cpt_hash(nid, net->net_ncpts)]; } - return lnet_nid_cpt_hash(nid4, LNET_CPT_NUMBER); + return lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER); } int @@ -4308,7 +4329,8 @@ LNetCtl(unsigned int cmd, void *arg) mutex_lock(&the_lnet.ln_api_mutex); lp = lnet_find_peer(ping->ping_id.nid); if (lp) { - ping->ping_id.nid = lp->lp_primary_nid; + ping->ping_id.nid = + lnet_nid_to_nid4(&lp->lp_primary_nid); ping->mr_info = lnet_peer_is_multi_rail(lp); lnet_peer_decref_locked(lp); } @@ -4331,7 +4353,8 @@ LNetCtl(unsigned int cmd, void *arg) mutex_lock(&the_lnet.ln_api_mutex); lp = lnet_find_peer(discover->ping_id.nid); if (lp) { - discover->ping_id.nid = lp->lp_primary_nid; + discover->ping_id.nid = + lnet_nid_to_nid4(&lp->lp_primary_nid); discover->mr_info = lnet_peer_is_multi_rail(lp); lnet_peer_decref_locked(lp); } diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index 9479cfa..b5fad9c 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -1511,7 +1511,7 @@ lnet_find_route_locked(struct lnet_remotenet *rnet, __u32 src_net, list_for_each_entry(route, &rnet->lrn_routes, lr_list) { if (!lnet_is_route_alive(route)) continue; - gw_pnid = route->lr_gateway->lp_primary_nid; + gw_pnid = lnet_nid_to_nid4(&route->lr_gateway->lp_primary_nid); /* no protection on below fields, but it's harmless */ if (last_route && (last_route->lr_seq - route->lr_seq < 0)) @@ -2137,7 +2137,7 @@ lnet_initiate_peer_discovery(struct lnet_peer_ni *lpni, struct lnet_msg *msg, lnet_peer_ni_decref_locked(new_lpni); CDEBUG(D_NET, "msg %p delayed. %s pending discovery\n", - msg, libcfs_nid2str(peer->lp_primary_nid)); + msg, libcfs_nidstr(&peer->lp_primary_nid)); return LNET_DC_WAIT; } @@ -5104,7 +5104,8 @@ lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg) libcfs_nidstr(&ni->ni_nid), libcfs_id2str(peer_id), getmd); /* setup information for lnet_build_msg_event */ - msg->msg_initiator = getmsg->msg_txpeer->lpni_peer_net->lpn_peer->lp_primary_nid; + msg->msg_initiator = + lnet_nid_to_nid4(&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 = peer_id.nid; diff --git a/lnet/lnet/peer.c b/lnet/lnet/peer.c index a2b339b..fb42ff2 100644 --- a/lnet/lnet/peer.c +++ b/lnet/lnet/peer.c @@ -149,13 +149,15 @@ lnet_peer_tables_create(void) } static struct lnet_peer_ni * -lnet_peer_ni_alloc(lnet_nid_t nid) +lnet_peer_ni_alloc(lnet_nid_t nid4) { struct lnet_peer_ni *lpni; struct lnet_net *net; + struct lnet_nid nid; int cpt; - cpt = lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER); + lnet_nid4_to_nid(nid4, &nid); + cpt = lnet_nid_cpt_hash(&nid, LNET_CPT_NUMBER); LIBCFS_CPT_ALLOC(lpni, lnet_cpt_table(), cpt, sizeof(*lpni)); if (!lpni) @@ -178,11 +180,11 @@ lnet_peer_ni_alloc(lnet_nid_t nid) else lpni->lpni_ns_status = LNET_NI_STATUS_UP; lpni->lpni_ping_feats = LNET_PING_FEAT_INVAL; - lnet_nid4_to_nid(nid, &lpni->lpni_nid); + lpni->lpni_nid = nid; lpni->lpni_cpt = cpt; atomic_set(&lpni->lpni_healthv, LNET_MAX_HEALTH_VALUE); - net = lnet_get_net_locked(LNET_NIDNET(nid)); + net = lnet_get_net_locked(LNET_NID_NET(&nid)); lpni->lpni_net = net; if (net) { lpni->lpni_txcredits = net->net_tunables.lct_peer_tx_credits; @@ -244,10 +246,12 @@ lnet_destroy_peer_net_locked(struct lnet_peer_net *lpn) } static struct lnet_peer * -lnet_peer_alloc(lnet_nid_t nid) +lnet_peer_alloc(lnet_nid_t nid4) { struct lnet_peer *lp; + struct lnet_nid nid; + lnet_nid4_to_nid(nid4, &nid); LIBCFS_CPT_ALLOC(lp, lnet_cpt_table(), CFS_CPT_ANY, sizeof(*lp)); if (!lp) return NULL; @@ -283,11 +287,11 @@ lnet_peer_alloc(lnet_nid_t nid) * to ever use a different interface when sending messages to * myself. */ - if (nid == LNET_NID_LO_0) + if (nid_is_lo0(&nid)) lp->lp_state = LNET_PEER_NO_DISCOVERY; - lp->lp_cpt = lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER); + lp->lp_cpt = lnet_nid_cpt_hash(&nid, LNET_CPT_NUMBER); - CDEBUG(D_NET, "%p nid %s\n", lp, libcfs_nid2str(lp->lp_primary_nid)); + CDEBUG(D_NET, "%p nid %s\n", lp, libcfs_nidstr(&lp->lp_primary_nid)); return lp; } @@ -295,7 +299,7 @@ lnet_peer_alloc(lnet_nid_t nid) void lnet_destroy_peer_locked(struct lnet_peer *lp) { - CDEBUG(D_NET, "%p nid %s\n", lp, libcfs_nid2str(lp->lp_primary_nid)); + CDEBUG(D_NET, "%p nid %s\n", lp, libcfs_nidstr(&lp->lp_primary_nid)); LASSERT(atomic_read(&lp->lp_refcount) == 0); LASSERT(lp->lp_rtr_refcount == 0); @@ -378,7 +382,7 @@ lnet_peer_detach_peer_ni_locked(struct lnet_peer_ni *lpni) wake_up(&the_lnet.ln_dc_waitq); } CDEBUG(D_NET, "peer %s NID %s\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), libcfs_nidstr(&lpni->lpni_nid)); } @@ -457,7 +461,7 @@ lnet_peer_del_locked(struct lnet_peer *peer) struct lnet_peer_ni *lpni = NULL, *lpni2; int rc = 0, rc2 = 0; - CDEBUG(D_NET, "peer %s\n", libcfs_nid2str(peer->lp_primary_nid)); + CDEBUG(D_NET, "peer %s\n", libcfs_nidstr(&peer->lp_primary_nid)); spin_lock(&peer->lp_lock); peer->lp_state |= LNET_PEER_MARK_DELETED; @@ -527,13 +531,15 @@ lnet_peer_del(struct lnet_peer *peer) * -EBUSY: The lnet_peer_ni is the primary, and not the only peer_ni. */ static int -lnet_peer_del_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags) +lnet_peer_del_nid(struct lnet_peer *lp, lnet_nid_t nid4, unsigned int flags) { struct lnet_peer_ni *lpni; - lnet_nid_t primary_nid = lp->lp_primary_nid; + struct lnet_nid primary_nid = lp->lp_primary_nid; + struct lnet_nid nid; int rc = 0; bool force = (flags & LNET_PEER_RTR_NI_FORCE_DEL) ? true : false; + lnet_nid4_to_nid(nid4, &nid); if (!(flags & LNET_PEER_CONFIGURED)) { if (lp->lp_state & LNET_PEER_CONFIGURED) { rc = -EPERM; @@ -545,12 +551,12 @@ lnet_peer_del_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags) * deleting it */ if (lp->lp_state & LNET_PEER_LOCK_PRIMARY && - primary_nid == nid) { + nid_same(&primary_nid, &nid)) { rc = -EPERM; goto out; } - lpni = lnet_find_peer_ni_locked(nid); + lpni = lnet_peer_ni_find_locked(&nid); if (!lpni) { rc = -ENOENT; goto out; @@ -565,19 +571,19 @@ lnet_peer_del_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags) * This function only allows deletion of the primary NID if it * is the only NID. */ - if (nid == lp->lp_primary_nid && lp->lp_nnis != 1 && !force) { + if (nid_same(&nid, &lp->lp_primary_nid) && lp->lp_nnis != 1 && !force) { rc = -EBUSY; goto out; } lnet_net_lock(LNET_LOCK_EX); - if (nid == lp->lp_primary_nid && lp->lp_nnis != 1 && force) { + if (nid_same(&nid, &lp->lp_primary_nid) && lp->lp_nnis != 1 && force) { struct lnet_peer_ni *lpni2; /* assign the next peer_ni to be the primary */ lpni2 = lnet_get_next_peer_ni_locked(lp, NULL, lpni); LASSERT(lpni2); - lp->lp_primary_nid = lnet_nid_to_nid4(&lpni2->lpni_nid); + lp->lp_primary_nid = lpni2->lpni_nid; } rc = lnet_peer_ni_del_locked(lpni, force); @@ -585,7 +591,8 @@ lnet_peer_del_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags) out: CDEBUG(D_NET, "peer %s NID %s flags %#x: %d\n", - libcfs_nid2str(primary_nid), libcfs_nid2str(nid), flags, rc); + libcfs_nidstr(&primary_nid), libcfs_nidstr(&nid), + flags, rc); return rc; } @@ -606,8 +613,8 @@ lnet_peer_table_cleanup_locked(struct lnet_net *net, continue; peer = lpni->lpni_peer_net->lpn_peer; - if (peer->lp_primary_nid != - lnet_nid_to_nid4(&lpni->lpni_nid)) { + if (!nid_same(&peer->lp_primary_nid, + &lpni->lpni_nid)) { lnet_peer_ni_del_locked(lpni, false); continue; } @@ -653,7 +660,9 @@ lnet_peer_table_del_rtrs_locked(struct lnet_net *net, if (!lnet_isrouter(lp)) continue; - gw_nid = lp->lpni_peer_net->lpn_peer->lp_primary_nid; + /* FIXME handle large-addr nid */ + gw_nid = lnet_nid_to_nid4( + &lp->lpni_peer_net->lpn_peer->lp_primary_nid); lnet_net_unlock(LNET_LOCK_EX); lnet_del_route(LNET_NET_ANY, gw_nid); @@ -718,7 +727,7 @@ lnet_find_peer_ni_locked(lnet_nid_t nid4) lnet_nid4_to_nid(nid4, &nid); - cpt = lnet_nid_cpt_hash(nid4, LNET_CPT_NUMBER); + cpt = lnet_nid_cpt_hash(&nid, LNET_CPT_NUMBER); ptable = the_lnet.ln_peer_tables[cpt]; lpni = lnet_get_peer_ni_locked(ptable, &nid); @@ -727,6 +736,21 @@ lnet_find_peer_ni_locked(lnet_nid_t nid4) } struct lnet_peer_ni * +lnet_peer_ni_find_locked(struct lnet_nid *nid) +{ + struct lnet_peer_ni *lpni; + struct lnet_peer_table *ptable; + int cpt; + + cpt = lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER); + + ptable = the_lnet.ln_peer_tables[cpt]; + lpni = lnet_get_peer_ni_locked(ptable, nid); + + return lpni; +} + +struct lnet_peer_ni * lnet_peer_get_ni_locked(struct lnet_peer *lp, lnet_nid_t nid) { struct lnet_peer_net *lpn; @@ -901,9 +925,11 @@ int lnet_get_peer_list(u32 *countp, u32 *sizep, struct lnet_process_id __user *i for (cpt = 0; cpt < lncpt; cpt++) { ptable = the_lnet.ln_peer_tables[cpt]; list_for_each_entry(lp, &ptable->pt_peer_list, lp_peer_list) { + if (!nid_is_nid4(&lp->lp_primary_nid)) + continue; if (i >= count) goto done; - id.nid = lp->lp_primary_nid; + id.nid = lnet_nid_to_nid4(&lp->lp_primary_nid); if (copy_to_user(&ids[i], &id, sizeof(id))) goto done; i++; @@ -1211,7 +1237,7 @@ out: spin_unlock(&lpni->lpni_lock); } CDEBUG(D_NET, "peer %s nid %s: %d\n", - libcfs_nid2str(lp->lp_primary_nid), libcfs_nid2str(nid), rc); + libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(nid), rc); return rc; } @@ -1270,7 +1296,7 @@ remove_nid_entry: LIBCFS_FREE(ne, sizeof(*ne)); out: CDEBUG(D_NET, "peer %s nid %s: %d\n", - libcfs_nid2str(lp->lp_primary_nid), libcfs_nid2str(nid), rc); + libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(nid), rc); return rc; } @@ -1300,12 +1326,14 @@ lnet_peer_clr_pref_nids(struct lnet_peer_ni *lpni) lnet_nid_t lnet_peer_primary_nid_locked(lnet_nid_t nid) { + /* FIXME handle large-addr nid */ struct lnet_peer_ni *lpni; lnet_nid_t primary_nid = nid; lpni = lnet_find_peer_ni_locked(nid); if (lpni) { - primary_nid = lpni->lpni_peer_net->lpn_peer->lp_primary_nid; + primary_nid = lnet_nid_to_nid4( + &lpni->lpni_peer_net->lpn_peer->lp_primary_nid); lnet_peer_ni_decref_locked(lpni); } @@ -1387,6 +1415,7 @@ unlock: } EXPORT_SYMBOL(LNetAddPeer); +/* FIXME support large-addr nid */ lnet_nid_t LNetPrimaryNID(lnet_nid_t nid) { @@ -1439,7 +1468,7 @@ LNetPrimaryNID(lnet_nid_t nid) } lp = lpni->lpni_peer_net->lpn_peer; } - primary_nid = lp->lp_primary_nid; + primary_nid = lnet_nid_to_nid4(&lp->lp_primary_nid); out_decref: lnet_peer_ni_decref_locked(lpni); out_unlock: @@ -1505,7 +1534,7 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp, /* Add peer_ni to peer_net */ lpni->lpni_peer_net = lpn; - if (lp->lp_primary_nid == lnet_nid_to_nid4(&lpni->lpni_nid)) + if (nid_same(&lp->lp_primary_nid, &lpni->lpni_nid)) list_add(&lpni->lpni_peer_nis, &lpn->lpn_peer_nis); else list_add_tail(&lpni->lpni_peer_nis, &lpn->lpn_peer_nis); @@ -1516,7 +1545,7 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp, if (!lpn->lpn_peer) { new_lpn = true; lpn->lpn_peer = lp; - if (lp->lp_primary_nid == lnet_nid_to_nid4(&lpni->lpni_nid)) + if (nid_same(&lp->lp_primary_nid, &lpni->lpni_nid)) list_add(&lpn->lpn_peer_nets, &lp->lp_peer_nets); else list_add_tail(&lpn->lpn_peer_nets, &lp->lp_peer_nets); @@ -1562,7 +1591,7 @@ lnet_peer_attach_peer_ni(struct lnet_peer *lp, libcfs_nidstr(&lpni->lpni_nid)); CDEBUG(D_NET, "peer %s NID %s flags %#x\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), libcfs_nidstr(&lpni->lpni_nid), flags); lnet_peer_ni_decref_locked(lpni); lnet_net_unlock(LNET_LOCK_EX); @@ -1601,13 +1630,13 @@ lnet_peer_add(lnet_nid_t nid, unsigned flags) * that an existing peer is being modified. */ if (lp->lp_state & LNET_PEER_CONFIGURED) { - if (lp->lp_primary_nid != nid) + if (lnet_nid_to_nid4(&lp->lp_primary_nid) != nid) rc = -EEXIST; else if ((lp->lp_state ^ flags) & LNET_PEER_MULTI_RAIL) rc = -EPERM; goto out; } else if (!(flags & LNET_PEER_CONFIGURED)) { - if (lp->lp_primary_nid == nid) { + if (lnet_nid_to_nid4(&lp->lp_primary_nid) == nid) { rc = -EEXIST; goto out; } @@ -1767,7 +1796,7 @@ out_free_lpni: lnet_peer_ni_decref_locked(lpni); out: CDEBUG(D_NET, "peer %s NID %s flags %#x: %d\n", - libcfs_nid2str(lp->lp_primary_nid), libcfs_nid2str(nid), + libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(nid), flags, rc); return rc; } @@ -1778,16 +1807,17 @@ out: * Call with the lnet_api_mutex held. */ static int -lnet_peer_set_primary_nid(struct lnet_peer *lp, lnet_nid_t nid, unsigned flags) +lnet_peer_set_primary_nid(struct lnet_peer *lp, lnet_nid_t nid, + unsigned int flags) { - lnet_nid_t old = lp->lp_primary_nid; + struct lnet_nid old = lp->lp_primary_nid; int rc = 0; - if (lp->lp_primary_nid == nid) + if (lnet_nid_to_nid4(&lp->lp_primary_nid) == nid) goto out; if (!(lp->lp_state & LNET_PEER_LOCK_PRIMARY)) - lp->lp_primary_nid = nid; + lnet_nid4_to_nid(nid, &lp->lp_primary_nid); rc = lnet_peer_add_nid(lp, nid, flags); if (rc) { @@ -1804,7 +1834,7 @@ out: return 0; CDEBUG(D_NET, "peer %s NID %s: %d\n", - libcfs_nid2str(old), libcfs_nid2str(nid), rc); + libcfs_nidstr(&old), libcfs_nid2str(nid), rc); return rc; } @@ -1915,10 +1945,10 @@ lnet_add_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid, bool mr, bool temp) } /* Primary NID must match */ - if (lp->lp_primary_nid != prim_nid) { + if (lnet_nid_to_nid4(&lp->lp_primary_nid) != prim_nid) { CDEBUG(D_NET, "prim_nid %s is not primary for peer %s\n", libcfs_nid2str(prim_nid), - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); return -ENODEV; } @@ -1959,10 +1989,10 @@ lnet_del_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid) lnet_peer_ni_decref_locked(lpni); lp = lpni->lpni_peer_net->lpn_peer; - if (prim_nid != lp->lp_primary_nid) { + if (prim_nid != lnet_nid_to_nid4(&lp->lp_primary_nid)) { CDEBUG(D_NET, "prim_nid %s is not primary for peer %s\n", libcfs_nid2str(prim_nid), - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); return -ENODEV; } @@ -1975,7 +2005,7 @@ lnet_del_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid) } lnet_net_unlock(LNET_LOCK_EX); - if (nid == LNET_NID_ANY || nid == lp->lp_primary_nid) + if (nid == LNET_NID_ANY || nid == lnet_nid_to_nid4(&lp->lp_primary_nid)) return lnet_peer_del(lp); flags = LNET_PEER_CONFIGURED; @@ -2231,7 +2261,7 @@ static int lnet_peer_queue_for_discovery(struct lnet_peer *lp) } CDEBUG(D_NET, "Queue peer %s: %d\n", - libcfs_nid2str(lp->lp_primary_nid), rc); + libcfs_nidstr(&lp->lp_primary_nid), rc); return rc; } @@ -2247,7 +2277,7 @@ static void lnet_peer_discovery_complete(struct lnet_peer *lp) LIST_HEAD(pending_msgs); CDEBUG(D_NET, "Discovery complete. Dequeue peer %s\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); list_del_init(&lp->lp_dc_list); spin_lock(&lp->lp_lock); @@ -2318,7 +2348,7 @@ void lnet_peer_push_event(struct lnet_event *ev) lp->lp_state |= LNET_PEER_FORCE_PING; CDEBUG(D_NET, "Push Put error %d from %s (source %s)\n", ev->status, - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(ev->source.nid)); goto out; } @@ -2331,7 +2361,7 @@ void lnet_peer_push_event(struct lnet_event *ev) lp->lp_state &= ~LNET_PEER_NIDS_UPTODATE; lp->lp_state |= LNET_PEER_FORCE_PING; CDEBUG(D_NET, "Corrupted Push from %s\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); goto out; } @@ -2348,7 +2378,7 @@ void lnet_peer_push_event(struct lnet_event *ev) */ if (!(pbuf->pb_info.pi_features & LNET_PING_FEAT_MULTI_RAIL)) { CERROR("Push from non-Multi-Rail peer %s dropped\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); goto out; } @@ -2358,7 +2388,7 @@ void lnet_peer_push_event(struct lnet_event *ev) */ if (!(pbuf->pb_info.pi_features & LNET_PING_FEAT_DISCOVERY)) { CDEBUG(D_NET, "Peer %s has discovery disabled\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); /* * Mark the peer for deletion if we already know about it * and it's going from discovery set to no discovery set @@ -2367,14 +2397,14 @@ void lnet_peer_push_event(struct lnet_event *ev) 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), + libcfs_nidstr(&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", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); lp->lp_state &= ~LNET_PEER_NO_DISCOVERY; } @@ -2386,19 +2416,19 @@ void lnet_peer_push_event(struct lnet_event *ev) */ if (lp->lp_state & LNET_PEER_MULTI_RAIL) { CDEBUG(D_NET, "peer %s(%p) is MR\n", - libcfs_nid2str(lp->lp_primary_nid), lp); + libcfs_nidstr(&lp->lp_primary_nid), lp); } else if (lp->lp_state & LNET_PEER_CONFIGURED) { CWARN("Push says %s is Multi-Rail, DLC says not\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); } else if (lnet_peer_discovery_disabled) { CDEBUG(D_NET, "peer %s(%p) not MR: DD disabled locally\n", - libcfs_nid2str(lp->lp_primary_nid), lp); + libcfs_nidstr(&lp->lp_primary_nid), lp); } else if (lp->lp_state & LNET_PEER_NO_DISCOVERY) { CDEBUG(D_NET, "peer %s(%p) not MR: DD disabled remotely\n", - libcfs_nid2str(lp->lp_primary_nid), lp); + libcfs_nidstr(&lp->lp_primary_nid), lp); } else { CDEBUG(D_NET, "peer %s(%p) is MR capable\n", - libcfs_nid2str(lp->lp_primary_nid), lp); + libcfs_nidstr(&lp->lp_primary_nid), lp); lp->lp_state |= LNET_PEER_MULTI_RAIL; lnet_peer_clr_non_mr_pref_nids(lp); } @@ -2414,7 +2444,7 @@ void lnet_peer_push_event(struct lnet_event *ev) lp->lp_state &= ~LNET_PEER_NIDS_UPTODATE; lp->lp_state |= LNET_PEER_FORCE_PING; CDEBUG(D_NET, "Truncated Push from %s (%d nids)\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), pbuf->pb_info.pi_nnis); goto out; } @@ -2436,7 +2466,7 @@ void lnet_peer_push_event(struct lnet_event *ev) memcpy(&lp->lp_data->pb_info, &pbuf->pb_info, LNET_PING_INFO_SIZE(pbuf->pb_info.pi_nnis)); CDEBUG(D_NET, "Ping/Push race from %s: %u vs %u\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), LNET_PING_BUFFER_SEQNO(pbuf), LNET_PING_BUFFER_SEQNO(lp->lp_data)); } @@ -2452,7 +2482,7 @@ void lnet_peer_push_event(struct lnet_event *ev) if (!lp->lp_data) { lp->lp_state |= LNET_PEER_FORCE_PING; CDEBUG(D_NET, "Cannot allocate Push buffer for %s %u\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), LNET_PING_BUFFER_SEQNO(pbuf)); goto out; } @@ -2462,7 +2492,7 @@ void lnet_peer_push_event(struct lnet_event *ev) LNET_PING_INFO_SIZE(pbuf->pb_info.pi_nnis)); lp->lp_state |= LNET_PEER_DATA_PRESENT; CDEBUG(D_NET, "Received Push %s %u\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), LNET_PING_BUFFER_SEQNO(pbuf)); out: @@ -2588,7 +2618,7 @@ again: goto again; CDEBUG(D_NET, "peer %s NID %s: %d. %s\n", - (lp ? libcfs_nid2str(lp->lp_primary_nid) : "(none)"), + (lp ? libcfs_nidstr(&lp->lp_primary_nid) : "(none)"), libcfs_nidstr(&lpni->lpni_nid), rc, (!block) ? "pending discovery" : "discovery complete"); @@ -2612,7 +2642,7 @@ lnet_discovery_event_ack(struct lnet_peer *lp, struct lnet_event *ev) spin_unlock(&lp->lp_lock); CDEBUG(D_NET, "peer %s ev->status %d\n", - libcfs_nid2str(lp->lp_primary_nid), ev->status); + libcfs_nidstr(&lp->lp_primary_nid), ev->status); } /* Handle a Reply message. This is the reply to a Ping message. */ @@ -2636,7 +2666,7 @@ lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev) lp->lp_ping_error = ev->status; CDEBUG(D_NET, "Ping Reply error %d from %s (source %s)\n", ev->status, - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(ev->source.nid)); goto out; } @@ -2654,7 +2684,7 @@ lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev) lp->lp_state |= LNET_PEER_PING_FAILED; lp->lp_ping_error = 0; CDEBUG(D_NET, "Corrupted Ping Reply from %s: %d\n", - libcfs_nid2str(lp->lp_primary_nid), rc); + libcfs_nidstr(&lp->lp_primary_nid), rc); goto out; } @@ -2665,7 +2695,7 @@ lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev) if (!(pbuf->pb_info.pi_features & LNET_PING_FEAT_DISCOVERY) || lnet_peer_discovery_disabled) { CDEBUG(D_NET, "Peer %s has discovery disabled\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); /* Detect whether this peer has toggled discovery from on to * off and whether we can delete and re-create the peer. Peers @@ -2684,14 +2714,14 @@ lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev) (lp->lp_state & (LNET_PEER_DISCOVERED | LNET_PEER_MULTI_RAIL))) { CDEBUG(D_NET, "Marking %s:0x%x for deletion\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), lp->lp_state); lp->lp_state |= LNET_PEER_MARK_DELETION; } lp->lp_state |= LNET_PEER_NO_DISCOVERY; } else { CDEBUG(D_NET, "Peer %s has discovery enabled\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); lp->lp_state &= ~LNET_PEER_NO_DISCOVERY; } @@ -2703,31 +2733,31 @@ lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev) if (pbuf->pb_info.pi_features & LNET_PING_FEAT_MULTI_RAIL) { if (lp->lp_state & LNET_PEER_MULTI_RAIL) { CDEBUG(D_NET, "peer %s(%p) is MR\n", - libcfs_nid2str(lp->lp_primary_nid), lp); + libcfs_nidstr(&lp->lp_primary_nid), lp); } else if (lp->lp_state & LNET_PEER_CONFIGURED) { CWARN("Reply says %s is Multi-Rail, DLC says not\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); } else if (lnet_peer_discovery_disabled) { CDEBUG(D_NET, "peer %s(%p) not MR: DD disabled locally\n", - libcfs_nid2str(lp->lp_primary_nid), lp); + libcfs_nidstr(&lp->lp_primary_nid), lp); } else if (lp->lp_state & LNET_PEER_NO_DISCOVERY) { CDEBUG(D_NET, "peer %s(%p) not MR: DD disabled remotely\n", - libcfs_nid2str(lp->lp_primary_nid), lp); + libcfs_nidstr(&lp->lp_primary_nid), lp); } else { CDEBUG(D_NET, "peer %s(%p) is MR capable\n", - libcfs_nid2str(lp->lp_primary_nid), lp); + libcfs_nidstr(&lp->lp_primary_nid), lp); lp->lp_state |= LNET_PEER_MULTI_RAIL; lnet_peer_clr_non_mr_pref_nids(lp); } } else if (lp->lp_state & LNET_PEER_MULTI_RAIL) { if (lp->lp_state & LNET_PEER_CONFIGURED) { CWARN("DLC says %s is Multi-Rail, Reply says not\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); } else { CERROR("Multi-Rail state vanished from %s\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); lp->lp_state &= ~LNET_PEER_MULTI_RAIL; } } @@ -2749,7 +2779,7 @@ lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev) lp->lp_state |= LNET_PEER_PING_FAILED; lp->lp_ping_error = 0; CDEBUG(D_NET, "Truncated Reply from %s (%d nids)\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), pbuf->pb_info.pi_nnis); goto out; } @@ -2760,10 +2790,11 @@ lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev) */ if (pbuf->pb_info.pi_features & LNET_PING_FEAT_MULTI_RAIL && pbuf->pb_info.pi_nnis > 1 && - lp->lp_primary_nid == pbuf->pb_info.pi_ni[1].ns_nid) { + lnet_nid_to_nid4(&lp->lp_primary_nid) == + pbuf->pb_info.pi_ni[1].ns_nid) { if (LNET_PING_BUFFER_SEQNO(pbuf) < lp->lp_peer_seqno) CDEBUG(D_NET, "peer %s: seq# got %u have %u. peer rebooted?\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), LNET_PING_BUFFER_SEQNO(pbuf), lp->lp_peer_seqno); @@ -2772,7 +2803,8 @@ lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev) /* We're happy with the state of the data in the buffer. */ CDEBUG(D_NET, "peer %s data present %u. state = 0x%x\n", - libcfs_nid2str(lp->lp_primary_nid), lp->lp_peer_seqno, lp->lp_state); + libcfs_nidstr(&lp->lp_primary_nid), lp->lp_peer_seqno, + lp->lp_state); if (lp->lp_state & LNET_PEER_DATA_PRESENT) lnet_ping_buffer_decref(lp->lp_data); else @@ -2842,7 +2874,7 @@ lnet_discovery_event_unlink(struct lnet_peer *lp, struct lnet_event *ev) lp->lp_state |= LNET_PEER_PING_FAILED; lp->lp_ping_error = -ETIMEDOUT; CDEBUG(D_NET, "Ping Unlink for message to peer %s\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); } /* We've passed through LNetPut() */ if (lp->lp_state & LNET_PEER_PUSH_SENT) { @@ -2850,7 +2882,7 @@ lnet_discovery_event_unlink(struct lnet_peer *lp, struct lnet_event *ev) lp->lp_state |= LNET_PEER_PUSH_FAILED; lp->lp_push_error = -ETIMEDOUT; CDEBUG(D_NET, "Push Unlink for message to peer %s\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); } spin_unlock(&lp->lp_lock); } @@ -3029,7 +3061,7 @@ static int lnet_peer_merge_data(struct lnet_peer *lp, if (rc) { CERROR("Error adding NID %s to peer %s: %d\n", libcfs_nid2str(addnis[i].ns_nid), - libcfs_nid2str(lp->lp_primary_nid), rc); + libcfs_nidstr(&lp->lp_primary_nid), rc); if (rc == -ENOMEM) goto out; } @@ -3053,7 +3085,7 @@ static int lnet_peer_merge_data(struct lnet_peer *lp, if (rc) { CERROR("Error deleting NID %s from peer %s: %d\n", libcfs_nid2str(delnis[i]), - libcfs_nid2str(lp->lp_primary_nid), rc); + libcfs_nidstr(&lp->lp_primary_nid), rc); if (rc == -ENOMEM) goto out; } @@ -3091,7 +3123,8 @@ out: CFS_FREE_PTR_ARRAY(addnis, nnis); CFS_FREE_PTR_ARRAY(delnis, nnis); lnet_ping_buffer_decref(pbuf); - CDEBUG(D_NET, "peer %s (%p): %d\n", libcfs_nid2str(lp->lp_primary_nid), lp, rc); + CDEBUG(D_NET, "peer %s (%p): %d\n", + libcfs_nidstr(&lp->lp_primary_nid), lp, rc); if (rc) { spin_lock(&lp->lp_lock); @@ -3160,7 +3193,7 @@ lnet_peer_set_primary_data(struct lnet_peer *lp, struct lnet_ping_buffer *pbuf) if (pbuf) return lnet_peer_merge_data(lp, pbuf); - CDEBUG(D_NET, "peer %s\n", libcfs_nid2str(lp->lp_primary_nid)); + CDEBUG(D_NET, "peer %s\n", libcfs_nidstr(&lp->lp_primary_nid)); return 0; } @@ -3195,7 +3228,7 @@ __must_hold(&lp->lp_lock) lp->lp_state &= ~(LNET_PEER_DISCOVERING | LNET_PEER_FORCE_PING | LNET_PEER_FORCE_PUSH); CDEBUG(D_NET, "peer %s(%p) state %#x\n", - libcfs_nid2str(lp->lp_primary_nid), lp, lp->lp_state); + libcfs_nidstr(&lp->lp_primary_nid), lp, lp->lp_state); /* no-op if lnet_peer_del() has already been called on this peer */ if (lp->lp_state & LNET_PEER_MARK_DELETED) @@ -3305,7 +3338,7 @@ __must_hold(&lp->lp_lock) if (pbuf->pb_info.pi_nnis <= 1) goto out; nid = pbuf->pb_info.pi_ni[1].ns_nid; - if (lp->lp_primary_nid == LNET_NID_LO_0) { + if (nid_is_lo0(&lp->lp_primary_nid)) { rc = lnet_peer_set_primary_nid(lp, nid, flags); if (!rc) rc = lnet_peer_merge_data(lp, pbuf); @@ -3317,8 +3350,9 @@ __must_hold(&lp->lp_lock) * to update the status of the nids that we currently have * recorded in that peer. */ - } else if (lp->lp_primary_nid == nid || - (lnet_is_nid_in_ping_info(lp->lp_primary_nid, &pbuf->pb_info) && + } else if (lnet_nid_to_nid4(&lp->lp_primary_nid) == nid || + (lnet_is_nid_in_ping_info(lnet_nid_to_nid4(&lp->lp_primary_nid), + &pbuf->pb_info) && lnet_is_discovery_disabled(lp))) { rc = lnet_peer_merge_data(lp, pbuf); } else { @@ -3327,7 +3361,7 @@ __must_hold(&lp->lp_lock) rc = lnet_peer_set_primary_nid(lp, nid, flags); if (rc) { CERROR("Primary NID error %s versus %s: %d\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), libcfs_nid2str(nid), rc); } else { rc = lnet_peer_merge_data(lp, pbuf); @@ -3367,7 +3401,8 @@ __must_hold(&lp->lp_lock) } } out: - CDEBUG(D_NET, "peer %s(%p): %d. state = 0x%x\n", libcfs_nid2str(lp->lp_primary_nid), lp, rc, + CDEBUG(D_NET, "peer %s(%p): %d. state = 0x%x\n", + libcfs_nidstr(&lp->lp_primary_nid), lp, rc, lp->lp_state); mutex_unlock(&the_lnet.ln_api_mutex); @@ -3401,7 +3436,7 @@ __must_hold(&lp->lp_lock) LNetMDUnlink(mdh); CDEBUG(D_NET, "peer %s:%d\n", - libcfs_nid2str(lp->lp_primary_nid), rc); + libcfs_nidstr(&lp->lp_primary_nid), rc); spin_lock(&lp->lp_lock); return rc ? rc : LNET_REDISCOVER_PEER; @@ -3426,7 +3461,8 @@ __must_hold(&lp->lp_lock) nnis = max(lp->lp_data_nnis, LNET_INTERFACES_MIN); - rc = lnet_send_ping(lp->lp_primary_nid, &lp->lp_ping_mdh, nnis, lp, + rc = lnet_send_ping(lnet_nid_to_nid4(&lp->lp_primary_nid), + &lp->lp_ping_mdh, nnis, lp, the_lnet.ln_dc_handler, false); /* @@ -3444,13 +3480,13 @@ __must_hold(&lp->lp_lock) goto fail_error; } - CDEBUG(D_NET, "peer %s\n", libcfs_nid2str(lp->lp_primary_nid)); + CDEBUG(D_NET, "peer %s\n", libcfs_nidstr(&lp->lp_primary_nid)); spin_lock(&lp->lp_lock); return 0; fail_error: - CDEBUG(D_NET, "peer %s: %d\n", libcfs_nid2str(lp->lp_primary_nid), rc); + CDEBUG(D_NET, "peer %s: %d\n", libcfs_nidstr(&lp->lp_primary_nid), rc); /* * The errors that get us here are considered hard errors and * cause Discovery to terminate. So we clear PING_SENT, but do @@ -3483,7 +3519,7 @@ __must_hold(&lp->lp_lock) if (!LNetMDHandleIsInvalid(mdh)) LNetMDUnlink(mdh); - CDEBUG(D_NET, "peer %s\n", libcfs_nid2str(lp->lp_primary_nid)); + CDEBUG(D_NET, "peer %s\n", libcfs_nidstr(&lp->lp_primary_nid)); spin_lock(&lp->lp_lock); return rc ? rc : LNET_REDISCOVER_PEER; } @@ -3500,7 +3536,7 @@ __must_hold(&lp->lp_lock) lp->lp_dc_error = 0; - CDEBUG(D_NET, "peer %s\n", libcfs_nid2str(lp->lp_primary_nid)); + CDEBUG(D_NET, "peer %s\n", libcfs_nidstr(&lp->lp_primary_nid)); return 0; } @@ -3559,7 +3595,7 @@ __must_hold(&lp->lp_lock) if (lp->lp_disc_dst_nid != LNET_NID_ANY) id.nid = lp->lp_disc_dst_nid; else - id.nid = lp->lp_primary_nid; + id.nid = lnet_nid_to_nid4(&lp->lp_primary_nid); lnet_net_unlock(cpt); rc = LNetPut(lp->lp_disc_src_nid, lp->lp_push_mdh, @@ -3578,7 +3614,7 @@ __must_hold(&lp->lp_lock) if (rc) goto fail_unlink; - CDEBUG(D_NET, "peer %s\n", libcfs_nid2str(lp->lp_primary_nid)); + CDEBUG(D_NET, "peer %s\n", libcfs_nidstr(&lp->lp_primary_nid)); spin_lock(&lp->lp_lock); return 0; @@ -3587,7 +3623,8 @@ fail_unlink: LNetMDUnlink(lp->lp_push_mdh); LNetInvalidateMDHandle(&lp->lp_push_mdh); fail_error: - CDEBUG(D_NET, "peer %s(%p): %d\n", libcfs_nid2str(lp->lp_primary_nid), lp, rc); + CDEBUG(D_NET, "peer %s(%p): %d\n", libcfs_nidstr(&lp->lp_primary_nid), + lp, rc); /* * The errors that get us here are considered hard errors and * cause Discovery to terminate. So we clear PUSH_SENT, but do @@ -3607,7 +3644,7 @@ fail_error: static void lnet_peer_discovery_error(struct lnet_peer *lp, int error) { CDEBUG(D_NET, "Discovery error %s: %d\n", - libcfs_nid2str(lp->lp_primary_nid), error); + libcfs_nidstr(&lp->lp_primary_nid), error); spin_lock(&lp->lp_lock); lp->lp_dc_error = error; @@ -3770,7 +3807,7 @@ static int lnet_peer_discovery(void *arg) */ spin_lock(&lp->lp_lock); CDEBUG(D_NET, "peer %s(%p) state %#x\n", - libcfs_nid2str(lp->lp_primary_nid), lp, + libcfs_nidstr(&lp->lp_primary_nid), lp, lp->lp_state); if (lp->lp_state & (LNET_PEER_MARK_DELETION | LNET_PEER_MARK_DELETED)) @@ -3792,7 +3829,7 @@ static int lnet_peer_discovery(void *arg) else rc = lnet_peer_discovered(lp); CDEBUG(D_NET, "peer %s(%p) state %#x rc %d\n", - libcfs_nid2str(lp->lp_primary_nid), lp, + libcfs_nidstr(&lp->lp_primary_nid), lp, lp->lp_state, rc); spin_unlock(&lp->lp_lock); @@ -4040,9 +4077,9 @@ int lnet_get_peer_info(struct lnet_ioctl_peer_cfg *cfg, void __user *bulk) goto out_lp_decref; } - cfg->prcfg_prim_nid = lp->lp_primary_nid; + cfg->prcfg_prim_nid = lnet_nid_to_nid4(&lp->lp_primary_nid); cfg->prcfg_mr = lnet_peer_is_multi_rail(lp); - cfg->prcfg_cfg_nid = lp->lp_primary_nid; + cfg->prcfg_cfg_nid = lnet_nid_to_nid4(&lp->lp_primary_nid); cfg->prcfg_count = lp->lp_nnis; cfg->prcfg_size = size; cfg->prcfg_state = lp->lp_state; diff --git a/lnet/lnet/router.c b/lnet/lnet/router.c index 4837d02..fc20a76 100644 --- a/lnet/lnet/router.c +++ b/lnet/lnet/router.c @@ -180,8 +180,9 @@ lnet_move_route(struct lnet_route *route, struct lnet_peer *lp, * use the gateway's lp_primary_nid to delete the route as the * lr_nid can be a constituent NID of the peer */ - lnet_del_route_from_rnet(route->lr_gateway->lp_primary_nid, - &rnet->lrn_routes, l); + lnet_del_route_from_rnet( + lnet_nid_to_nid4(&route->lr_gateway->lp_primary_nid), + &rnet->lrn_routes, l); if (lp) { route = list_first_entry(l, struct lnet_route, @@ -206,10 +207,11 @@ lnet_rtr_transfer_to_peer(struct lnet_peer *src, struct lnet_peer *target) lnet_net_lock(LNET_LOCK_EX); CDEBUG(D_NET, "transfering routes from %s -> %s\n", - libcfs_nid2str(src->lp_primary_nid), - libcfs_nid2str(target->lp_primary_nid)); + libcfs_nidstr(&src->lp_primary_nid), + libcfs_nidstr(&target->lp_primary_nid)); list_for_each_entry(route, &src->lp_routes, lr_gwlist) { - CDEBUG(D_NET, "%s: %s->%s\n", libcfs_nid2str(src->lp_primary_nid), + CDEBUG(D_NET, "%s: %s->%s\n", + libcfs_nidstr(&src->lp_primary_nid), libcfs_net2str(route->lr_net), libcfs_nid2str(route->lr_nid)); } @@ -340,7 +342,7 @@ bool lnet_is_route_alive(struct lnet_route *route) spin_unlock(&gw->lp_lock); if (gw->lp_rtr_refcount > 0) CERROR("peer %s is being used as a gateway but routing feature is not turned on\n", - libcfs_nid2str(gw->lp_primary_nid)); + libcfs_nidstr(&gw->lp_primary_nid)); return false; } spin_unlock(&gw->lp_lock); @@ -382,7 +384,7 @@ lnet_check_route_inconsistency(struct lnet_route *route) (route->lr_hops == 1 || route->lr_hops == LNET_UNDEFINED_HOPS)) { CWARN("route %s->%s is detected to be multi-hop but hop count is set to %d\n", libcfs_net2str(route->lr_net), - libcfs_nid2str(route->lr_gateway->lp_primary_nid), + libcfs_nidstr(&route->lr_gateway->lp_primary_nid), (int) route->lr_hops); } } @@ -431,7 +433,7 @@ lnet_router_discovery_ping_reply(struct lnet_peer *lp) if (lp_state & LNET_PEER_PING_FAILED || pbuf->pb_info.pi_features & LNET_PING_FEAT_RTE_DISABLED) { CDEBUG(D_NET, "Set routes down for gw %s because %s %d\n", - libcfs_nid2str(lp->lp_primary_nid), + libcfs_nidstr(&lp->lp_primary_nid), lp_state & LNET_PEER_PING_FAILED ? "ping failed" : "route feature is disabled", lp->lp_ping_error); /* If the ping failed or the peer has routing disabled then @@ -443,7 +445,7 @@ lnet_router_discovery_ping_reply(struct lnet_peer *lp) } CDEBUG(D_NET, "Discovery is disabled. Processing reply for gw: %s:%d\n", - libcfs_nid2str(lp->lp_primary_nid), pbuf->pb_info.pi_nnis); + libcfs_nidstr(&lp->lp_primary_nid), pbuf->pb_info.pi_nnis); /* * examine the ping response to determine if the routes on that @@ -535,7 +537,7 @@ lnet_router_discovery_complete(struct lnet_peer *lp) * determine otherwise. */ CDEBUG(D_NET, "%s: Router discovery failed %d\n", - libcfs_nid2str(lp->lp_primary_nid), lp->lp_dc_error); + libcfs_nidstr(&lp->lp_primary_nid), lp->lp_dc_error); while ((lpni = lnet_get_next_peer_ni_locked(lp, NULL, lpni)) != NULL) lpni->lpni_ns_status = LNET_NI_STATUS_DOWN; @@ -762,7 +764,8 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway, } /* our lookups must be true */ - LASSERT(route2->lr_gateway->lp_primary_nid != gateway); + LASSERT(lnet_nid_to_nid4(&route2->lr_gateway->lp_primary_nid) != + gateway); } /* @@ -814,7 +817,7 @@ lnet_del_route_from_rnet(lnet_nid_t gw_nid, struct list_head *route_list, list_for_each_entry_safe(route, tmp, route_list, lr_list) { gateway = route->lr_gateway; if (gw_nid != LNET_NID_ANY && - gw_nid != gateway->lp_primary_nid) + gw_nid != lnet_nid_to_nid4(&gateway->lp_primary_nid)) continue; /* @@ -858,7 +861,7 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid) if (lpni) { lp = lpni->lpni_peer_net->lpn_peer; LASSERT(lp); - gw_nid = lp->lp_primary_nid; + gw_nid = lnet_nid_to_nid4(&lp->lp_primary_nid); lnet_peer_ni_decref_locked(lpni); } @@ -1178,7 +1181,7 @@ rescan: lpn = lnet_get_next_peer_net_locked(rtr, net_id); if (!lpn) { CERROR("gateway %s has no networks\n", - libcfs_nid2str(rtr->lp_primary_nid)); + libcfs_nidstr(&rtr->lp_primary_nid)); break; } @@ -1195,7 +1198,7 @@ rescan: found_lpn = true; CDEBUG(D_NET, "rtr %s(%p) %s(%p) next ping %lld\n", - libcfs_nid2str(rtr->lp_primary_nid), rtr, + libcfs_nidstr(&rtr->lp_primary_nid), rtr, libcfs_net2str(net_id), lpn, lpn->lpn_next_ping); @@ -1205,7 +1208,7 @@ rescan: if (!found_lpn || !lpn) { CERROR("no local network found for gateway %s\n", - libcfs_nid2str(rtr->lp_primary_nid)); + libcfs_nidstr(&rtr->lp_primary_nid)); continue; } @@ -1220,10 +1223,11 @@ rescan: spin_unlock(&rtr->lp_lock); /* find the peer_ni associated with the primary NID */ - lpni = lnet_peer_get_ni_locked(rtr, rtr->lp_primary_nid); + lpni = lnet_peer_get_ni_locked( + rtr, lnet_nid_to_nid4(&rtr->lp_primary_nid)); if (!lpni) { CDEBUG(D_NET, "Expected to find an lpni for %s, but non found\n", - libcfs_nid2str(rtr->lp_primary_nid)); + libcfs_nidstr(&rtr->lp_primary_nid)); continue; } lnet_peer_ni_addref_locked(lpni); @@ -1243,7 +1247,7 @@ rescan: lpn->lpn_next_ping = now + alive_router_check_interval; else CERROR("Failed to discover router %s\n", - libcfs_nid2str(rtr->lp_primary_nid)); + libcfs_nidstr(&rtr->lp_primary_nid)); /* NB cpt lock was dropped in lnet_discover_peer_locked() */ if (version != the_lnet.ln_routers_version) { diff --git a/lnet/lnet/router_proc.c b/lnet/lnet/router_proc.c index 1627940..349d1dfc 100644 --- a/lnet/lnet/router_proc.c +++ b/lnet/lnet/router_proc.c @@ -319,7 +319,7 @@ proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer, } if (peer != NULL) { - lnet_nid_t nid = peer->lp_primary_nid; + struct lnet_nid *nid = &peer->lp_primary_nid; int nrefs = atomic_read(&peer->lp_refcount); int nrtrrefs = peer->lp_rtr_refcount; int alive = lnet_is_gateway_alive(peer); @@ -328,7 +328,7 @@ proc_lnet_routers(struct ctl_table *table, int write, void __user *buffer, "%-4d %7d %5s %s\n", nrefs, nrtrrefs, alive ? "up" : "down", - libcfs_nid2str(nid)); + libcfs_nidstr(nid)); } lnet_net_unlock(0); diff --git a/lnet/lnet/udsp.c b/lnet/lnet/udsp.c index 29cdbdd..ffb2cde 100644 --- a/lnet/lnet/udsp.c +++ b/lnet/lnet/udsp.c @@ -248,7 +248,8 @@ lnet_udsp_apply_rte_list_on_net(struct lnet_net *net, list_for_each_entry(rnet, rn_list, lrn_list) { list_for_each_entry(route, &rnet->lrn_routes, lr_list) { /* look if gw nid on the same net matches */ - gw_prim_nid = route->lr_gateway->lp_primary_nid; + gw_prim_nid = lnet_nid_to_nid4( + &route->lr_gateway->lp_primary_nid); lpni = NULL; while ((lpni = lnet_get_next_peer_ni_locked(route->lr_gateway, NULL, @@ -424,7 +425,8 @@ lnet_udsp_apply_rte_list_on_lpni(struct lnet_peer_ni *lpni, rn_list = &the_lnet.ln_remote_nets_hash[i]; list_for_each_entry(rnet, rn_list, lrn_list) { list_for_each_entry(route, &rnet->lrn_routes, lr_list) { - gw_nid = route->lr_gateway->lp_primary_nid; + gw_nid = lnet_nid_to_nid4( + &route->lr_gateway->lp_primary_nid); rc = cfs_match_nid_net(gw_nid, rte_action->ud_net_id.udn_net_type, &rte_action->ud_net_id.udn_net_num_range, @@ -605,7 +607,7 @@ lnet_udsp_apply_rule_on_lpnis(struct udsp_info *udi) ptable = the_lnet.ln_peer_tables[cpt]; list_for_each_entry(lp, &ptable->pt_peer_list, lp_peer_list) { CDEBUG(D_NET, "udsp examining lp %s\n", - libcfs_nid2str(lp->lp_primary_nid)); + libcfs_nidstr(&lp->lp_primary_nid)); list_for_each_entry(lpn, &lp->lp_peer_nets, lpn_peer_nets) { -- 1.8.3.1