atomic_set(&c->c_refcount, 1);
c->c_peer = peer;
c->c_self = self;
+ INIT_HLIST_NODE(&c->c_hash);
+ INIT_LIST_HEAD(&c->c_link);
if (uuid != NULL)
obd_str2uuid(&c->c_remote_uuid, uuid->uuid);
rc = lustre_hash_additem_unique(conn_hash_body, &peer,
&c->c_hash);
if (rc != 0) {
+ list_del(&c->c_link);
CERROR("Cannot add connection to conn_hash_body\n");
goto out_conn;
}
}
-
+
out_conn:
+
spin_unlock(&conn_lock);
if (c2 == NULL && rc == 0)
if (c != NULL)
OBD_FREE(c, sizeof(*c));
-
- c2 = rc != 0 ? NULL : c2;
RETURN (c2);
}
int ptlrpc_put_connection(struct ptlrpc_connection *c)
{
int rc = 0;
- lnet_process_id_t peer = c->c_peer;
ENTRY;
if (c == NULL) {
c, atomic_read(&c->c_refcount) - 1,
libcfs_nid2str(c->c_peer.nid));
+ spin_lock(&conn_lock);
LASSERT(!hlist_unhashed(&c->c_hash));
+ spin_unlock(&conn_lock);
if (atomic_dec_return(&c->c_refcount) == 1) {
spin_lock(&conn_lock);
- lustre_hash_delitem(conn_hash_body, &peer, &c->c_hash);
+ lustre_hash_delitem(conn_hash_body, &c->c_peer, &c->c_hash);
list_del(&c->c_link);
list_add(&c->c_link, &conn_unused_list);
- rc = lustre_hash_additem_unique(conn_unused_hash_body, &peer,
+ rc = lustre_hash_additem_unique(conn_unused_hash_body, &c->c_peer,
&c->c_hash);
if (rc != 0) {
spin_unlock(&conn_lock);
int ptlrpc_init_connection(void)
{
int rc = 0;
-
CFS_INIT_LIST_HEAD(&conn_list);
rc = lustre_hash_init(&conn_hash_body, "CONN_HASH",
128, &conn_hash_operations);
GOTO(ret, rc);
spin_lock_init(&conn_lock);
-ret :
+ret:
if (rc) {
lustre_hash_exit(&conn_hash_body);
lustre_hash_exit(&conn_unused_hash_body);