@@ -163,6 +163,16 @@ static inline int nid_same(const struct lnet_nid *n1,
n1->nid_addr[3] == n2->nid_addr[3];
}
+/* This can be used when we need to hash a nid */
+static inline unsigned long nidhash(lnet_nid_t nid)
+{
+ unsigned long hash = 0;
+
+ hash ^= LNET_NIDNET(nid);
+ hash ^= LNET_NIDADDR(nid);
+ return hash;
+}
+
struct lnet_counters_health {
__u32 lch_rst_alloc;
__u32 lch_resend_count;
@@ -221,9 +221,10 @@ struct ksock_peer_ni *
ksocknal_find_peer_locked(struct lnet_ni *ni, struct lnet_process_id id)
{
struct ksock_peer_ni *peer_ni;
+ unsigned long hash = nidhash(id.nid);
hash_for_each_possible(ksocknal_data.ksnd_peers, peer_ni,
- ksnp_list, id.nid) {
+ ksnp_list, hash) {
LASSERT(!peer_ni->ksnp_closing);
if (peer_ni->ksnp_ni != ni)
@@ -602,7 +603,8 @@ struct ksock_peer_ni *
peer_ni = peer2;
} else {
/* peer_ni table takes my ref on peer_ni */
- hash_add(ksocknal_data.ksnd_peers, &peer_ni->ksnp_list, id.nid);
+ hash_add(ksocknal_data.ksnd_peers, &peer_ni->ksnp_list,
+ nidhash(id.nid));
}
ksocknal_add_conn_cb_locked(peer_ni, conn_cb);
@@ -656,7 +658,8 @@ struct ksock_peer_ni *
write_lock_bh(&ksocknal_data.ksnd_global_lock);
if (id.nid != LNET_NID_ANY) {
- lo = hash_min(id.nid, HASH_BITS(ksocknal_data.ksnd_peers));
+ lo = hash_min(nidhash(id.nid),
+ HASH_BITS(ksocknal_data.ksnd_peers));
hi = lo;
} else {
lo = 0;
@@ -935,7 +938,7 @@ struct ksock_peer_ni *
* table (which takes my ref)
*/
hash_add(ksocknal_data.ksnd_peers,
- &peer_ni->ksnp_list, peerid.nid);
+ &peer_ni->ksnp_list, nidhash(peerid.nid));
} else {
ksocknal_peer_decref(peer_ni);
peer_ni = peer2;
@@ -1567,7 +1570,8 @@ struct ksock_peer_ni *
write_lock_bh(&ksocknal_data.ksnd_global_lock);
if (id.nid != LNET_NID_ANY) {
- lo = hash_min(id.nid, HASH_BITS(ksocknal_data.ksnd_peers));
+ lo = hash_min(nidhash(id.nid),
+ HASH_BITS(ksocknal_data.ksnd_peers));
hi = lo;
} else {
lo = 0;
@@ -1662,7 +1666,8 @@ static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id)
int rc = -ENOENT;
if (id.nid != LNET_NID_ANY) {
- lo = hash_min(id.nid, HASH_BITS(ksocknal_data.ksnd_peers));
+ lo = hash_min(nidhash(id.nid),
+ HASH_BITS(ksocknal_data.ksnd_peers));
hi = lo;
} else {
lo = 0;