+
+static void *
+conn_key(cfs_hlist_node_t *hnode)
+{
+ struct ptlrpc_connection *conn;
+ conn = cfs_hlist_entry(hnode, struct ptlrpc_connection, c_hash);
+ return &conn->c_peer;
+}
+
+static void *
+conn_get(cfs_hlist_node_t *hnode)
+{
+ struct ptlrpc_connection *conn;
+
+ conn = cfs_hlist_entry(hnode, struct ptlrpc_connection, c_hash);
+ cfs_atomic_inc(&conn->c_refcount);
+
+ return conn;
+}
+
+static void *
+conn_put(cfs_hlist_node_t *hnode)
+{
+ struct ptlrpc_connection *conn;
+
+ conn = cfs_hlist_entry(hnode, struct ptlrpc_connection, c_hash);
+ cfs_atomic_dec(&conn->c_refcount);
+
+ return conn;
+}
+
+static void
+conn_exit(cfs_hlist_node_t *hnode)
+{
+ struct ptlrpc_connection *conn;
+
+ conn = cfs_hlist_entry(hnode, struct ptlrpc_connection, c_hash);
+ /*
+ * Nothing should be left. Connection user put it and
+ * connection also was deleted from table by this time
+ * so we should have 0 refs.
+ */
+ LASSERTF(cfs_atomic_read(&conn->c_refcount) == 0,
+ "Busy connection with %d refs\n",
+ cfs_atomic_read(&conn->c_refcount));
+ OBD_FREE_PTR(conn);
+}
+
+static cfs_hash_ops_t conn_hash_ops = {
+ .hs_hash = conn_hashfn,
+ .hs_compare = conn_compare,
+ .hs_key = conn_key,
+ .hs_get = conn_get,
+ .hs_put = conn_put,
+ .hs_exit = conn_exit,
+};