diff mbox series

[05/18] lnet: change LNetPrimaryNID to use struct lnet_nid

Message ID 1654777994-29806-6-git-send-email-jsimmons@infradead.org (mailing list archive)
State Not Applicable
Headers show
Series lustre: sync with OpenSFS tree June 8, 2022 | expand

Commit Message

James Simmons June 9, 2022, 12:33 p.m. UTC
From: Mr NeilBrown <neilb@suse.de>

Rather than taking and returning a 4-byte-addr nid, LNetPrimaryNID now
takes a pointer to a struct lnet_nid, and updates it in-place.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: ac881498fa19e6b04 ("LU-10391 lnet: change LNetPrimaryNID to use struct lnet_nid")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/43616
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/ptlrpc/connection.c |  2 +-
 include/linux/lnet/api.h      |  2 +-
 net/lnet/lnet/peer.c          | 21 +++++++++++----------
 3 files changed, 13 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/ptlrpc/connection.c b/fs/lustre/ptlrpc/connection.c
index d1f53c6..58161fe 100644
--- a/fs/lustre/ptlrpc/connection.c
+++ b/fs/lustre/ptlrpc/connection.c
@@ -82,8 +82,8 @@  struct ptlrpc_connection *
 	struct ptlrpc_connection *conn, *conn2;
 	struct lnet_processid peer;
 
-	peer4.nid = LNetPrimaryNID(peer4.nid);
 	lnet_pid4_to_pid(peer4, &peer);
+	LNetPrimaryNID(&peer.nid);
 	conn = rhashtable_lookup_fast(&conn_hash, &peer, conn_hash_params);
 	if (conn) {
 		ptlrpc_connection_addref(conn);
diff --git a/include/linux/lnet/api.h b/include/linux/lnet/api.h
index 6d8e915..447b41d 100644
--- a/include/linux/lnet/api.h
+++ b/include/linux/lnet/api.h
@@ -77,7 +77,7 @@ 
  */
 int LNetGetId(unsigned int index, struct lnet_processid *id);
 int LNetDist(lnet_nid_t nid, lnet_nid_t *srcnid, u32 *order);
-lnet_nid_t LNetPrimaryNID(lnet_nid_t nid);
+void LNetPrimaryNID(struct lnet_nid *nid);
 
 /** @} lnet_addr */
 
diff --git a/net/lnet/lnet/peer.c b/net/lnet/lnet/peer.c
index 714326a..2055f31 100644
--- a/net/lnet/lnet/peer.c
+++ b/net/lnet/lnet/peer.c
@@ -1430,18 +1430,20 @@  struct lnet_peer_ni *
 }
 EXPORT_SYMBOL(LNetAddPeer);
 
-/* FIXME support large-addr nid */
-lnet_nid_t
-LNetPrimaryNID(lnet_nid_t nid)
+void LNetPrimaryNID(struct lnet_nid *nid)
 {
 	struct lnet_peer *lp;
 	struct lnet_peer_ni *lpni;
-	lnet_nid_t primary_nid = nid;
+	struct lnet_nid orig;
 	int rc = 0;
 	int cpt;
 
+	if (!nid || nid_is_lo0(nid))
+		return;
+	orig = *nid;
+
 	cpt = lnet_net_lock_current();
-	lpni = lnet_nid2peerni_locked(nid, LNET_NID_ANY, cpt);
+	lpni = lnet_peerni_by_nid_locked(nid, NULL, cpt);
 	if (IS_ERR(lpni)) {
 		rc = PTR_ERR(lpni);
 		goto out_unlock;
@@ -1468,7 +1470,7 @@  struct lnet_peer_ni *
 		 * and lookup the lpni again
 		 */
 		lnet_peer_ni_decref_locked(lpni);
-		lpni = lnet_find_peer_ni_locked(nid);
+		lpni = lnet_peer_ni_find_locked(nid);
 		if (!lpni) {
 			rc = -ENOENT;
 			goto out_unlock;
@@ -1483,15 +1485,14 @@  struct lnet_peer_ni *
 		if (lnet_is_discovery_disabled(lp))
 			break;
 	}
-	primary_nid = lnet_nid_to_nid4(&lp->lp_primary_nid);
+	*nid = lp->lp_primary_nid;
 out_decref:
 	lnet_peer_ni_decref_locked(lpni);
 out_unlock:
 	lnet_net_unlock(cpt);
 
-	CDEBUG(D_NET, "NID %s primary NID %s rc %d\n", libcfs_nid2str(nid),
-	       libcfs_nid2str(primary_nid), rc);
-	return primary_nid;
+	CDEBUG(D_NET, "NID %s primary NID %s rc %d\n", libcfs_nidstr(&orig),
+	       libcfs_nidstr(nid), rc);
 }
 EXPORT_SYMBOL(LNetPrimaryNID);