@@ -77,6 +77,7 @@ int LNetNIFini(void);
*/
int LNetGetId(unsigned int index, struct lnet_process_id *id);
int LNetDist(lnet_nid_t nid, lnet_nid_t *srcnid, __u32 *order);
+lnet_nid_t LNetPrimaryNID(lnet_nid_t nid);
/** @} lnet_addr */
@@ -610,6 +610,31 @@ lnet_peer_primary_nid(lnet_nid_t nid)
return primary_nid;
}
+lnet_nid_t
+LNetPrimaryNID(lnet_nid_t nid)
+{
+ struct lnet_peer_ni *lpni;
+ lnet_nid_t primary_nid = nid;
+ int rc = 0;
+ int cpt;
+
+ cpt = lnet_net_lock_current();
+ lpni = lnet_nid2peerni_locked(nid, cpt);
+ if (IS_ERR(lpni)) {
+ rc = PTR_ERR(lpni);
+ goto out_unlock;
+ }
+ primary_nid = lpni->lpni_peer_net->lpn_peer->lp_primary_nid;
+ 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;
+}
+EXPORT_SYMBOL(LNetPrimaryNID);
+
struct lnet_peer_net *
lnet_peer_get_net_locked(struct lnet_peer *peer, u32 net_id)
{
@@ -80,6 +80,7 @@ ptlrpc_connection_get(struct lnet_process_id peer, lnet_nid_t self,
{
struct ptlrpc_connection *conn, *conn2;
+ peer.nid = LNetPrimaryNID(peer.nid);
conn = rhashtable_lookup_fast(&conn_hash, &peer, conn_hash_params);
if (conn) {
ptlrpc_connection_addref(conn);