Whamcloud - gitweb
LU-12678 o2iblnd: convert peers hash table to hashtable.h
[fs/lustre-release.git] / lnet / klnds / o2iblnd / o2iblnd.h
index 60d1590..3e4013f 100644 (file)
@@ -93,7 +93,7 @@
 #include <lnet/lib-lnet.h>
 #include "o2iblnd-idl.h"
 
-#define IBLND_PEER_HASH_SIZE           101     /* # peer_ni lists */
+#define IBLND_PEER_HASH_BITS           7       /* log2 of # peer_ni lists */
 
 #define IBLND_N_SCHED                  2
 #define IBLND_N_SCHED_HIGH             4
@@ -439,9 +439,7 @@ struct kib_data {
        /* stabilize net/dev/peer_ni/conn ops */
        rwlock_t                kib_global_lock;
        /* hash table of all my known peers */
-       struct list_head        *kib_peers;
-       /* size of kib_peers */
-       int                     kib_peer_hash_size;
+       DECLARE_HASHTABLE(kib_peers, IBLND_PEER_HASH_BITS);
        /* the connd task (serialisation assertions) */
        void                    *kib_connd;
        /* connections to setup/teardown */
@@ -642,8 +640,8 @@ struct kib_conn {
 #define IBLND_CONN_DISCONNECTED       5         /* disconnected */
 
 struct kib_peer_ni {
-       /* stash on global peer_ni list */
-       struct list_head        ibp_list;
+       /* on peer_ni hash chain */
+       struct hlist_node       ibp_list;
        /* who's on the other end(s) */
        lnet_nid_t              ibp_nid;
        /* LNet interface */
@@ -814,20 +812,11 @@ kiblnd_peer_idle(struct kib_peer_ni *peer_ni)
        return !kiblnd_peer_connecting(peer_ni) && list_empty(&peer_ni->ibp_conns);
 }
 
-static inline struct list_head *
-kiblnd_nid2peerlist (lnet_nid_t nid)
-{
-       unsigned int hash =
-               ((unsigned int)nid) % kiblnd_data.kib_peer_hash_size;
-
-       return &kiblnd_data.kib_peers[hash];
-}
-
 static inline int
 kiblnd_peer_active(struct kib_peer_ni *peer_ni)
 {
        /* Am I in the peer_ni hash table? */
-       return !list_empty(&peer_ni->ibp_list);
+       return !hlist_unhashed(&peer_ni->ibp_list);
 }
 
 static inline struct kib_conn *