[lustre-devel] [PATCH 28/50] lnet: change lnet_del_route() to take lnet_nid

James Simmons jsimmons at infradead.org
Sun Mar 20 06:30:42 PDT 2022


From: Mr NeilBrown <neilb at suse.de>

The gateway NID passed to lnet_del_route is now a struct lnet_nid.
Instead of passing LNET_NID_ANY as a wildcard, we pass
a NULL pointer.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 58993799f29d12c1a ("U-10391 lnet: change lnet_del_route() to take lnet_nid")
Signed-off-by: Mr NeilBrown <neilb at suse.de>
Reviewed-on: https://review.whamcloud.com/43615
Reviewed-by: James Simmons <jsimmons at infradead.org>
Reviewed-by: Cyril Bordage <cbordage at whamcloud.com>
Reviewed-by: Chris Horn <chris.horn at hpe.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 include/linux/lnet/lib-lnet.h |  2 +-
 net/lnet/lnet/api-ni.c        |  3 ++-
 net/lnet/lnet/peer.c          |  7 +++----
 net/lnet/lnet/router.c        | 29 +++++++++++++++++------------
 4 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h
index 33fee17..b6a7a54 100644
--- a/include/linux/lnet/lib-lnet.h
+++ b/include/linux/lnet/lib-lnet.h
@@ -576,7 +576,7 @@ void lnet_notify_locked(struct lnet_peer_ni *lp, int notifylnd, int alive,
 			time64_t when);
 int lnet_add_route(u32 net, u32 hops, struct lnet_nid *gateway,
 		   u32 priority, u32 sensitivity);
-int lnet_del_route(u32 net, lnet_nid_t gw_nid);
+int lnet_del_route(u32 net, struct lnet_nid *gw_nid);
 void lnet_move_route(struct lnet_route *route, struct lnet_peer *lp,
 		     struct list_head *rt_list);
 void lnet_destroy_routes(void);
diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c
index 0389a89..7a05752 100644
--- a/net/lnet/lnet/api-ni.c
+++ b/net/lnet/lnet/api-ni.c
@@ -3901,8 +3901,9 @@ u32 lnet_get_dlc_seq_locked(void)
 		if (config->cfg_hdr.ioc_len < sizeof(*config))
 			return -EINVAL;
 
+		lnet_nid4_to_nid(config->cfg_nid, &nid);
 		mutex_lock(&the_lnet.ln_api_mutex);
-		rc = lnet_del_route(config->cfg_net, config->cfg_nid);
+		rc = lnet_del_route(config->cfg_net, &nid);
 		mutex_unlock(&the_lnet.ln_api_mutex);
 		return rc;
 
diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c
index 8e7f44c..f70ceb5 100644
--- a/net/lnet/lnet/peer.c
+++ b/net/lnet/lnet/peer.c
@@ -627,7 +627,7 @@ static void lnet_peer_cancel_discovery(struct lnet_peer *lp)
 {
 	struct lnet_peer_ni *lp;
 	struct lnet_peer_ni *tmp;
-	lnet_nid_t gw_nid;
+	struct lnet_nid gw_nid;
 	int i;
 
 	for (i = 0; i < LNET_PEER_HASH_SIZE; i++) {
@@ -639,10 +639,9 @@ static void lnet_peer_cancel_discovery(struct lnet_peer *lp)
 			if (!lnet_isrouter(lp))
 				continue;
 
-			/* FIXME handle large-addr nid */
-			gw_nid = lnet_nid_to_nid4(&lp->lpni_peer_net->lpn_peer->lp_primary_nid);
+			gw_nid = lp->lpni_peer_net->lpn_peer->lp_primary_nid;
 			lnet_net_unlock(LNET_LOCK_EX);
-			lnet_del_route(LNET_NET_ANY, gw_nid);
+			lnet_del_route(LNET_NET_ANY, &gw_nid);
 			lnet_net_lock(LNET_LOCK_EX);
 		}
 	}
diff --git a/net/lnet/lnet/router.c b/net/lnet/lnet/router.c
index 87ae1f9..beded3e 100644
--- a/net/lnet/lnet/router.c
+++ b/net/lnet/lnet/router.c
@@ -116,7 +116,7 @@ static int rtr_sensitivity_set(const char *val,
 
 static void lnet_add_route_to_rnet(struct lnet_remotenet *rnet,
 				   struct lnet_route *route);
-static void lnet_del_route_from_rnet(lnet_nid_t gw_nid,
+static void lnet_del_route_from_rnet(struct lnet_nid *gw_nid,
 				     struct list_head *route_list,
 				     struct list_head *zombies);
 
@@ -175,7 +175,7 @@ static void lnet_del_route_from_rnet(lnet_nid_t gw_nid,
 	/* 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(lnet_nid_to_nid4(&route->lr_gateway->lp_primary_nid),
+	lnet_del_route_from_rnet(&route->lr_gateway->lp_primary_nid,
 				 &rnet->lrn_routes, l);
 
 	if (lp) {
@@ -788,7 +788,8 @@ static void lnet_shuffle_seed(void)
 }
 
 void
-lnet_del_route_from_rnet(lnet_nid_t gw_nid, struct list_head *route_list,
+lnet_del_route_from_rnet(struct lnet_nid *gw_nid,
+			 struct list_head *route_list,
 			 struct list_head *zombies)
 {
 	struct lnet_peer *gateway;
@@ -797,8 +798,7 @@ static void lnet_shuffle_seed(void)
 
 	list_for_each_entry_safe(route, tmp, route_list, lr_list) {
 		gateway = route->lr_gateway;
-		if (gw_nid != LNET_NID_ANY &&
-		    gw_nid != lnet_nid_to_nid4(&gateway->lp_primary_nid))
+		if (gw_nid && !nid_same(gw_nid, &gateway->lp_primary_nid))
 			continue;
 
 		/* move to zombie to delete outside the lock
@@ -817,7 +817,7 @@ static void lnet_shuffle_seed(void)
 }
 
 int
-lnet_del_route(u32 net, lnet_nid_t gw_nid)
+lnet_del_route(u32 net, struct lnet_nid *gw)
 {
 	LIST_HEAD(rnet_zombies);
 	struct lnet_remotenet *rnet;
@@ -825,12 +825,13 @@ static void lnet_shuffle_seed(void)
 	struct list_head *rn_list;
 	struct lnet_peer_ni *lpni;
 	struct lnet_route *route;
+	struct lnet_nid gw_nid;
 	LIST_HEAD(zombies);
 	struct lnet_peer *lp = NULL;
 	int i = 0;
 
 	CDEBUG(D_NET, "Del route: net %s : gw %s\n",
-	       libcfs_net2str(net), libcfs_nid2str(gw_nid));
+	       libcfs_net2str(net), libcfs_nidstr(gw));
 
 	/* NB Caller may specify either all routes via the given gateway
 	 * or a specific route entry actual NIDs)
@@ -838,11 +839,15 @@ static void lnet_shuffle_seed(void)
 
 	lnet_net_lock(LNET_LOCK_EX);
 
-	lpni = lnet_find_peer_ni_locked(gw_nid);
+	if (gw)
+		lpni = lnet_peer_ni_find_locked(gw);
+	else
+		lpni = NULL;
 	if (lpni) {
 		lp = lpni->lpni_peer_net->lpn_peer;
 		LASSERT(lp);
-		gw_nid = lnet_nid_to_nid4(&lp->lp_primary_nid);
+		gw_nid = lp->lp_primary_nid;
+		gw = &gw_nid;
 		lnet_peer_ni_decref_locked(lpni);
 	}
 
@@ -852,7 +857,7 @@ static void lnet_shuffle_seed(void)
 			lnet_net_unlock(LNET_LOCK_EX);
 			return -ENOENT;
 		}
-		lnet_del_route_from_rnet(gw_nid, &rnet->lrn_routes,
+		lnet_del_route_from_rnet(gw, &rnet->lrn_routes,
 					 &zombies);
 		if (list_empty(&rnet->lrn_routes))
 			list_move(&rnet->lrn_list, &rnet_zombies);
@@ -863,7 +868,7 @@ static void lnet_shuffle_seed(void)
 		rn_list = &the_lnet.ln_remote_nets_hash[i];
 
 		list_for_each_entry_safe(rnet, tmp, rn_list, lrn_list) {
-			lnet_del_route_from_rnet(gw_nid, &rnet->lrn_routes,
+			lnet_del_route_from_rnet(gw, &rnet->lrn_routes,
 						 &zombies);
 			if (list_empty(&rnet->lrn_routes))
 				list_move(&rnet->lrn_list, &rnet_zombies);
@@ -903,7 +908,7 @@ static void lnet_shuffle_seed(void)
 void
 lnet_destroy_routes(void)
 {
-	lnet_del_route(LNET_NET_ANY, LNET_NID_ANY);
+	lnet_del_route(LNET_NET_ANY, NULL);
 }
 
 int lnet_get_rtr_pool_cfg(int cpt, struct lnet_ioctl_pool_cfg *pool_cfg)
-- 
1.8.3.1



More information about the lustre-devel mailing list