From 3b8f253c10759027d37d45cf6e961f77fc9c0f81 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Fri, 10 Jul 2020 15:58:29 +1000 Subject: [PATCH] LU-10391 lnet: switch LNetIsPeerLocal() to take 16-byte addr LNetIsPeerLocal() now takes a '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: Id72a92cda510de6864c82d88912c582745cc9727 Reviewed-on: https://review.whamcloud.com/43621 Reviewed-by: James Simmons Reviewed-by: Chris Horn Reviewed-by: Amir Shehata Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lnet/include/lnet/api.h | 2 +- lnet/lnet/api-ni.c | 4 ++-- lustre/include/lustre_net.h | 2 +- lustre/mgc/mgc_request.c | 2 +- lustre/target/tgt_handler.c | 2 +- lustre/target/tgt_lastrcvd.c | 4 +++- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lnet/include/lnet/api.h b/lnet/include/lnet/api.h index 63b19b2..ca04543 100644 --- a/lnet/include/lnet/api.h +++ b/lnet/include/lnet/api.h @@ -77,7 +77,7 @@ int LNetNIFini(void); int LNetGetId(unsigned int index, struct lnet_processid *id); int LNetDist(struct lnet_nid *nid, struct lnet_nid *srcnid, __u32 *order); void LNetPrimaryNID(struct lnet_nid *nid); -bool LNetIsPeerLocal(lnet_nid_t nid); +bool LNetIsPeerLocal(struct lnet_nid *nid); /** @} lnet_addr */ diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 4a43942..a4a1c78 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -4566,7 +4566,7 @@ EXPORT_SYMBOL(LNetDebugPeer); * \retval true If peer NID is on the local node. * \retval false If peer NID is not on the local node. */ -bool LNetIsPeerLocal(lnet_nid_t nid) +bool LNetIsPeerLocal(struct lnet_nid *nid) { struct lnet_net *net; struct lnet_ni *ni; @@ -4575,7 +4575,7 @@ bool LNetIsPeerLocal(lnet_nid_t nid) cpt = lnet_net_lock_current(); list_for_each_entry(net, &the_lnet.ln_nets, net_list) { list_for_each_entry(ni, &net->net_ni_list, ni_netlist) { - if (lnet_nid_to_nid4(&ni->ni_nid) == nid) { + if (nid_same(&ni->ni_nid, nid)) { lnet_net_unlock(cpt); return true; } diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 287eec2..a11825c 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -1971,7 +1971,7 @@ static inline bool ptlrpc_connection_is_local(struct ptlrpc_connection *conn) if (nid_same(&conn->c_peer.nid, &conn->c_self)) return true; - RETURN(LNetIsPeerLocal(lnet_nid_to_nid4(&conn->c_peer.nid))); + RETURN(LNetIsPeerLocal(&conn->c_peer.nid)); } /* ptlrpc/niobuf.c */ diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index b5bddd0..e396ad5 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -1634,7 +1634,7 @@ static int mgc_process_recover_nodemap_log(struct obd_device *obd, /* don't need to get local config */ if (cld_is_nodemap(cld) && - LNetIsPeerLocal(lnet_nid_to_nid4(&mgc_conn->c_peer.nid))) + LNetIsPeerLocal(&mgc_conn->c_peer.nid)) GOTO(out, rc = 0); /* allocate buffer for bulk transfer. diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index 3198cc8..681f3d4 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -946,7 +946,7 @@ int tgt_connect_check_sptlrpc(struct ptlrpc_request *req, struct obd_export *exp if ((strcmp(exp->exp_obd->obd_type->typ_name, LUSTRE_MGS_NAME) == 0) && (exp->exp_flvr.sf_rpc == SPTLRPC_FLVR_NULL || - LNetIsPeerLocal(lnet_nid_to_nid4(&exp->exp_connection->c_peer.nid)))) + LNetIsPeerLocal(&exp->exp_connection->c_peer.nid))) exp->exp_flvr.sf_rpc = SPTLRPC_FLVR_ANY; if (exp->exp_flvr.sf_rpc != SPTLRPC_FLVR_ANY && diff --git a/lustre/target/tgt_lastrcvd.c b/lustre/target/tgt_lastrcvd.c index 7022ceb..b0f200c 100644 --- a/lustre/target/tgt_lastrcvd.c +++ b/lustre/target/tgt_lastrcvd.c @@ -973,6 +973,7 @@ static int tgt_is_local_client(const struct lu_env *env, struct lu_target *tgt = class_exp2tgt(exp); struct tgt_session_info *tsi = tgt_ses_info(env); struct ptlrpc_request *req = tgt_ses_req(tsi); + struct lnet_nid nid; if (exp_connect_flags(exp) & OBD_CONNECT_MDS || exp_connect_flags(exp) & OBD_CONNECT_MDS_MDS) @@ -981,7 +982,8 @@ static int tgt_is_local_client(const struct lu_env *env, return 0; if (!req) return 0; - if (!LNetIsPeerLocal(req->rq_peer.nid)) + lnet_nid4_to_nid(req->rq_peer.nid, &nid); + if (!LNetIsPeerLocal(&nid)) return 0; return 1; -- 1.8.3.1