@@ -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);
@@ -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 */
@@ -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);