From a0bdb01ad05b24d2469e715ec2ce7f774d31d2e1 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Thu, 8 Jul 2021 10:34:36 +1000 Subject: [PATCH] LU-10391 ptlrpc: pass net num to ptlrpc_uuid_to_connection Rather than passing a nid to indicate which net to choose, pass just the net number. This will make it easier to convert to 'struct lnet_nid'. Also change ptlrpc_uuid_to_peer() to take the refnet as an explicit argument, rather than embedding in in the peer pid. This makes the refnet test more obvious, and removes the (strange) need to test the address part against zero. Signed-off-by: Mr NeilBrown Change-Id: I0650760a59342f5ac245cc14011452e436ef8e4c Reviewed-on: https://review.whamcloud.com/44637 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: Frank Sehr Reviewed-by: James Simmons Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin --- lustre/include/lustre_net.h | 5 +++-- lustre/ldlm/ldlm_lib.c | 10 +++++----- lustre/ptlrpc/client.c | 5 ++--- lustre/ptlrpc/events.c | 7 ++++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 56f2419..d28aa52 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -1895,7 +1895,8 @@ static inline bool nrs_policy_compat_one(const struct ptlrpc_service *svc, /* ptlrpc/events.c */ extern int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, struct lnet_process_id *peer, - struct lnet_nid *self); + struct lnet_nid *self, + u32 refnet); /** * These callbacks are invoked by LNet when something happened to * underlying buffer @@ -2050,7 +2051,7 @@ void ptlrpc_init_client(int req_portal, int rep_portal, const char *name, struct ptlrpc_client *); void ptlrpc_cleanup_client(struct obd_import *imp); struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid, - lnet_nid_t nid4refnet); + u32 refnet); int ptlrpc_queue_wait(struct ptlrpc_request *req); int ptlrpc_replay_req(struct ptlrpc_request *req); diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 1f5689a..f26e042 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -60,7 +60,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, { struct ptlrpc_connection *ptlrpc_conn; struct obd_import_conn *imp_conn = NULL, *item; - lnet_nid_t nid4refnet = LNET_NID_ANY; + u32 refnet = LNET_NET_ANY; int rc = 0; ENTRY; @@ -72,9 +72,9 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, if (imp->imp_connection && imp->imp_connection->c_remote_uuid.uuid[0] == 0) - /* nid4refnet is used to restrict network connections */ - nid4refnet = lnet_nid_to_nid4(&imp->imp_connection->c_self); - ptlrpc_conn = ptlrpc_uuid_to_connection(uuid, nid4refnet); + /* refnet is used to restrict network connections */ + refnet = LNET_NID_NET(&imp->imp_connection->c_self); + ptlrpc_conn = ptlrpc_uuid_to_connection(uuid, refnet); if (!ptlrpc_conn) { CDEBUG(D_HA, "can't find connection %s\n", uuid->uuid); RETURN(-ENOENT); @@ -147,7 +147,7 @@ int client_import_dyn_add_conn(struct obd_import *imp, struct obd_uuid *uuid, struct ptlrpc_connection *ptlrpc_conn; int rc; - ptlrpc_conn = ptlrpc_uuid_to_connection(uuid, prim_nid); + ptlrpc_conn = ptlrpc_uuid_to_connection(uuid, LNET_NIDNET(prim_nid)); if (!ptlrpc_conn) { const char *str_uuid = obd_uuid2str(uuid); diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index f9f99dc..085db74 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -123,7 +123,7 @@ EXPORT_SYMBOL(ptlrpc_init_client); * Return PortalRPC connection for remore uud \a uuid */ struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid, - lnet_nid_t nid4refnet) + u32 refnet) { struct ptlrpc_connection *c; struct lnet_nid self; @@ -135,8 +135,7 @@ struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid, * before accessing its values. */ /* coverity[uninit_use_in_call] */ - peer.nid = nid4refnet; - err = ptlrpc_uuid_to_peer(uuid, &peer, &self); + err = ptlrpc_uuid_to_peer(uuid, &peer, &self, refnet); if (err != 0) { CNETERR("cannot find peer %s!\n", uuid->uuid); return NULL; diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c index 5e9550c..479375a 100644 --- a/lustre/ptlrpc/events.c +++ b/lustre/ptlrpc/events.c @@ -528,7 +528,8 @@ static void ptlrpc_master_callback(struct lnet_event *ev) int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, struct lnet_process_id *peer, - struct lnet_nid *self) + struct lnet_nid *self, + u32 refnet) { int best_dist = 0; __u32 best_order = 0; @@ -543,8 +544,8 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, /* Choose the matching UUID that's closest */ while (lustre_uuid_to_peer(uuid->uuid, &dst_nid, count++) == 0) { - if (peer->nid != LNET_NID_ANY && LNET_NIDADDR(peer->nid) == 0 && - LNET_NID_NET(&dst_nid) != LNET_NIDNET(peer->nid)) + if (refnet != LNET_NET_ANY && + LNET_NID_NET(&dst_nid) != refnet) continue; dist = LNetDist(&dst_nid, &src_nid, &order); -- 1.8.3.1