Whamcloud - gitweb
LU-13004 ptlrpc: Allow BULK_BUF_KIOV to accept a kvec
[fs/lustre-release.git] / lustre / ptlrpc / connection.c
index d85fcf2..369eace 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
  */
 
 #define DEBUG_SUBSYSTEM S_RPC
-#ifdef __KERNEL__
 #include <obd_support.h>
 #include <obd_class.h>
 #include <lustre_net.h>
-#else
-#include <liblustre.h>
-#endif
 
 #include "ptlrpc_internal.h"
 
-static cfs_hash_t *conn_hash = NULL;
-static cfs_hash_ops_t conn_hash_ops;
+static struct cfs_hash *conn_hash;
+static struct cfs_hash_ops conn_hash_ops;
 
 struct ptlrpc_connection *
-ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
-                      struct obd_uuid *uuid)
+ptlrpc_connection_get(struct lnet_process_id peer, lnet_nid_t self,
+                     struct obd_uuid *uuid)
 {
-        struct ptlrpc_connection *conn, *conn2;
-        ENTRY;
+       struct ptlrpc_connection *conn, *conn2;
+       ENTRY;
 
-        conn = cfs_hash_lookup(conn_hash, &peer);
-        if (conn)
-                GOTO(out, conn);
+       peer.nid = LNetPrimaryNID(peer.nid);
+       conn = cfs_hash_lookup(conn_hash, &peer);
+       if (conn)
+               GOTO(out, conn);
 
-        OBD_ALLOC_PTR(conn);
-        if (!conn)
-                RETURN(NULL);
+       OBD_ALLOC_PTR(conn);
+       if (!conn)
+               RETURN(NULL);
 
-        conn->c_peer = peer;
-        conn->c_self = self;
+       conn->c_peer = peer;
+       conn->c_self = self;
        INIT_HLIST_NODE(&conn->c_hash);
        atomic_set(&conn->c_refcount, 1);
-        if (uuid)
-                obd_str2uuid(&conn->c_remote_uuid, uuid->uuid);
+       if (uuid)
+               obd_str2uuid(&conn->c_remote_uuid, uuid->uuid);
 
        /*
         * Add the newly created conn to the hash, on key collision we
         * lost a racing addition and must destroy our newly allocated
-        * connection.  The object which exists in the has will be
+        * connection.  The object which exists in the hash will be
         * returned and may be compared against out object.
         */
        /* In the function below, .hs_keycmp resolves to
@@ -91,7 +84,6 @@ out:
               libcfs_nid2str(conn->c_peer.nid));
        return conn;
 }
-EXPORT_SYMBOL(ptlrpc_connection_get);
 
 int ptlrpc_connection_put(struct ptlrpc_connection *conn)
 {
@@ -128,7 +120,6 @@ int ptlrpc_connection_put(struct ptlrpc_connection *conn)
 
        RETURN(rc);
 }
-EXPORT_SYMBOL(ptlrpc_connection_put);
 
 struct ptlrpc_connection *
 ptlrpc_connection_addref(struct ptlrpc_connection *conn)
@@ -142,7 +133,6 @@ ptlrpc_connection_addref(struct ptlrpc_connection *conn)
 
        RETURN(conn);
 }
-EXPORT_SYMBOL(ptlrpc_connection_addref);
 
 int ptlrpc_connection_init(void)
 {
@@ -160,32 +150,30 @@ int ptlrpc_connection_init(void)
 
         RETURN(0);
 }
-EXPORT_SYMBOL(ptlrpc_connection_init);
 
 void ptlrpc_connection_fini(void) {
         ENTRY;
         cfs_hash_putref(conn_hash);
         EXIT;
 }
-EXPORT_SYMBOL(ptlrpc_connection_fini);
 
 /*
  * Hash operations for net_peer<->connection
  */
 static unsigned
-conn_hashfn(cfs_hash_t *hs, const void *key, unsigned mask)
+conn_hashfn(struct cfs_hash *hs, const void *key, unsigned mask)
 {
-       return cfs_hash_djb2_hash(key, sizeof(lnet_process_id_t), mask);
+       return cfs_hash_djb2_hash(key, sizeof(struct lnet_process_id), mask);
 }
 
 static int
 conn_keycmp(const void *key, struct hlist_node *hnode)
 {
        struct ptlrpc_connection *conn;
-       const lnet_process_id_t *conn_key;
+       const struct lnet_process_id *conn_key;
 
        LASSERT(key != NULL);
-       conn_key = (lnet_process_id_t *)key;
+       conn_key = (struct lnet_process_id *)key;
        conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);
 
        return conn_key->nid == conn->c_peer.nid &&
@@ -207,7 +195,7 @@ conn_object(struct hlist_node *hnode)
 }
 
 static void
-conn_get(cfs_hash_t *hs, struct hlist_node *hnode)
+conn_get(struct cfs_hash *hs, struct hlist_node *hnode)
 {
        struct ptlrpc_connection *conn;
 
@@ -216,7 +204,7 @@ conn_get(cfs_hash_t *hs, struct hlist_node *hnode)
 }
 
 static void
-conn_put_locked(cfs_hash_t *hs, struct hlist_node *hnode)
+conn_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
 {
        struct ptlrpc_connection *conn;
 
@@ -225,7 +213,7 @@ conn_put_locked(cfs_hash_t *hs, struct hlist_node *hnode)
 }
 
 static void
-conn_exit(cfs_hash_t *hs, struct hlist_node *hnode)
+conn_exit(struct cfs_hash *hs, struct hlist_node *hnode)
 {
        struct ptlrpc_connection *conn;
 
@@ -241,7 +229,7 @@ conn_exit(cfs_hash_t *hs, struct hlist_node *hnode)
        OBD_FREE_PTR(conn);
 }
 
-static cfs_hash_ops_t conn_hash_ops = {
+static struct cfs_hash_ops conn_hash_ops = {
        .hs_hash        = conn_hashfn,
        .hs_keycmp      = conn_keycmp,
        .hs_key         = conn_key,