From ac439ce87b0acbff35deaf52c283e3fa93e52510 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Sat, 11 Sep 2021 10:20:51 -0400 Subject: [PATCH] LU-10391 lnet: convert nids in lnet_parse to lnet_nid src_nid and dest_nid in lnet_parse() are changed to struct lnet_nid, and this change propagates out to affect a few support function. 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: Ic6922d3f643e493f92f8f64974ad30f66457e842 Reviewed-on: https://review.whamcloud.com/43613 Reviewed-by: James Simmons Reviewed-by: Serguei Smirnov Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lnet/include/lnet/lib-lnet.h | 4 +-- lnet/lnet/api-ni.c | 13 -------- lnet/lnet/lib-move.c | 79 +++++++++++++++++++++----------------------- lnet/lnet/peer.c | 7 ++-- 4 files changed, 43 insertions(+), 60 deletions(-) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 577bfae..e0f604d 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -668,7 +668,6 @@ struct lnet_net *lnet_get_net_locked(__u32 net_id); void lnet_net_clr_pref_rtrs(struct lnet_net *net); int lnet_net_add_pref_rtr(struct lnet_net *net, struct lnet_nid *gw_nid); -int lnet_islocalnid4(lnet_nid_t nid); int lnet_islocalnid(struct lnet_nid *nid); int lnet_islocalnet(__u32 net); int lnet_islocalnet_locked(__u32 net); @@ -981,7 +980,8 @@ struct lnet_peer_ni *lnet_peer_ni_find_locked(struct lnet_nid *nid); struct lnet_peer *lnet_find_peer4(lnet_nid_t nid); struct lnet_peer *lnet_find_peer(struct lnet_nid *nid); void lnet_peer_net_added(struct lnet_net *net); -void lnet_peer_primary_nid_locked(lnet_nid_t nid, struct lnet_nid *result); +void lnet_peer_primary_nid_locked(struct lnet_nid *nid, + struct lnet_nid *result); int lnet_discover_peer_locked(struct lnet_peer_ni *lpni, int cpt, bool block); void lnet_peer_queue_message(struct lnet_peer *lp, struct lnet_msg *msg); int lnet_peer_discovery_start(void); diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 1cd27eb..a3567c8 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -1714,19 +1714,6 @@ lnet_nid_to_ni_addref(struct lnet_nid *nid) EXPORT_SYMBOL(lnet_nid_to_ni_addref); int -lnet_islocalnid4(lnet_nid_t nid) -{ - struct lnet_ni *ni; - int cpt; - - cpt = lnet_net_lock_current(); - ni = lnet_nid2ni_locked(nid, cpt); - lnet_net_unlock(cpt); - - return ni != NULL; -} - -int lnet_islocalnid(struct lnet_nid *nid) { struct lnet_ni *ni; diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index e0c2d8e..09b4ec6 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -239,16 +239,14 @@ lnet_fail_nid(lnet_nid_t nid4, unsigned int threshold) } 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); @@ -267,7 +265,7 @@ fail_peer(lnet_nid_t nid4, int outgoing) } 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) { @@ -4501,8 +4499,8 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, 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 dest_nid; + struct lnet_nid src_nid; struct lnet_nid from_nid; bool push = false; int for_me; @@ -4515,19 +4513,18 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, lnet_nid4_to_nid(from_nid4, &from_nid); type = hdr->type; - src_nid = lnet_nid_to_nid4(&hdr->src_nid); - dest_nid = lnet_nid_to_nid4(&hdr->dest_nid); + src_nid = hdr->src_nid; + dest_nid = hdr->dest_nid; dest_pid = hdr->dest_pid; payload_length = 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"); @@ -4537,7 +4534,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, 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(&src_nid), lnet_msgtyp2str(type), payload_length); return -EPROTO; } @@ -4550,7 +4547,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, CERROR("%s, src %s: bad %s payload %d " "(%d max expected)\n", libcfs_nid2str(from_nid4), - libcfs_nid2str(src_nid), + libcfs_nidstr(&src_nid), lnet_msgtyp2str(type), payload_length, for_me ? LNET_MAX_PAYLOAD : LNET_MTU); @@ -4561,7 +4558,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, default: CERROR("%s, src %s: Bad message type 0x%x\n", libcfs_nid2str(from_nid4), - libcfs_nid2str(src_nid), type); + libcfs_nidstr(&src_nid), type); return -EPROTO; } @@ -4583,24 +4580,24 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, * 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(&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(&src_nid), + libcfs_nidstr(&dest_nid)); return -EPROTO; } @@ -4608,8 +4605,8 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, 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(&src_nid), + libcfs_nidstr(&dest_nid)); return -EPROTO; } @@ -4617,8 +4614,8 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, 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(&src_nid), + libcfs_nidstr(&dest_nid)); goto drop; } } @@ -4627,9 +4624,9 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, * 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_nid2str(from_nid4), libcfs_nidstr(&src_nid), lnet_msgtyp2str(type)); goto drop; } @@ -4639,15 +4636,15 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, lnet_drop_rule_match(hdr, lnet_nid_to_nid4(&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_nid2str(from_nid4), 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_nid2str(from_nid4), libcfs_nidstr(&src_nid), lnet_msgtyp2str(type)); goto drop; } @@ -4665,9 +4662,9 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, /* for building message event */ 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; + msg->msg_target.pid = dest_pid; + msg->msg_target.nid = dest_nid; + msg->msg_routing = 1; } lnet_net_lock(cpt); @@ -4676,7 +4673,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, 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_nid2str(from_nid4), libcfs_nidstr(&src_nid), lnet_msgtyp2str(type), rc); lnet_msg_free(msg); if (rc == -ESHUTDOWN) @@ -4691,8 +4688,8 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, */ 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_NIDNET(from_nid4)) { + __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; @@ -4727,7 +4724,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, */ CERROR("%s, src %s: Dropping asymmetrical route %s\n", libcfs_nid2str(from_nid4), - libcfs_nid2str(src_nid), lnet_msgtyp2str(type)); + libcfs_nidstr(&src_nid), lnet_msgtyp2str(type)); lnet_msg_free(msg); goto drop; } @@ -4751,7 +4748,7 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4, 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 @@ -4986,7 +4983,7 @@ LNetPut(lnet_nid_t self4, struct lnet_handle_md mdh, enum lnet_ack_req ack, target.pid = target4.pid; if (!list_empty(&the_lnet.ln_test_peers) && /* normally we don't */ - fail_peer(target4.nid, 1)) { /* shall we now? */ + fail_peer(&target.nid, 1)) { /* shall we now? */ CERROR("Dropping PUT to %s: simulated failure\n", libcfs_id2str(target4)); return -EIO; @@ -5223,7 +5220,7 @@ LNetGet(lnet_nid_t self4, struct lnet_handle_md mdh, target.pid = target4.pid; if (!list_empty(&the_lnet.ln_test_peers) && /* normally we don't */ - fail_peer(target4.nid, 1)) /* shall we now? */ + fail_peer(&target.nid, 1)) /* shall we now? */ { CERROR("Dropping GET to %s: simulated failure\n", libcfs_id2str(target4)); diff --git a/lnet/lnet/peer.c b/lnet/lnet/peer.c index 3e280b7..620d406 100644 --- a/lnet/lnet/peer.c +++ b/lnet/lnet/peer.c @@ -1354,13 +1354,12 @@ lnet_peer_clr_pref_nids(struct lnet_peer_ni *lpni) } void -lnet_peer_primary_nid_locked(lnet_nid_t nid, struct lnet_nid *result) +lnet_peer_primary_nid_locked(struct lnet_nid *nid, struct lnet_nid *result) { - /* FIXME handle large-addr nid */ struct lnet_peer_ni *lpni; - lnet_nid4_to_nid(nid, result); - lpni = lnet_find_peer_ni_locked(nid); + *result = *nid; + lpni = lnet_peer_ni_find_locked(nid); if (lpni) { *result = lpni->lpni_peer_net->lpn_peer->lp_primary_nid; lnet_peer_ni_decref_locked(lpni); -- 1.8.3.1