Whamcloud - gitweb
- fixed some warnings in the DLM
[fs/lustre-release.git] / lustre / ptlrpc / client.c
index e104155..2daebfa 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_RPC
 
-#include <linux/lustre_net.h>
+#include <linux/lustre_ha.h>
 
-void llite_ha_conn_manage(struct lustre_ha_mgr *mgr, struct ptlrpc_client *cli)
-{
-        ENTRY;
-        cli->cli_ha_mgr = mgr;
-        spin_lock(&mgr->mgr_lock);
-        list_add(&cli->cli_ha_item, &mgr->mgr_connections_lh); 
-        spin_unlock(&mgr->mgr_lock); 
-        EXIT;
-}
-
-void llite_ha_conn_fail(struct ptlrpc_client *cli)
-{
-        ENTRY;
-        spin_lock(&cli->cli_ha_mgr->mgr_lock);
-        list_del(&cli->cli_ha_item);
-        list_add(&cli->cli_ha_item, &cli->cli_ha_mgr->mgr_troubled_lh); 
-        spin_unlock(&cli->cli_ha_mgr->mgr_lock); 
-        wake_up(&cli->cli_ha_mgr->mgr_waitq);
-        EXIT;
-}
-
-void ptlrpc_init_client(struct lustre_ha_mgr *mgr, int req_portal,
+void ptlrpc_init_client(struct connmgr_obd *mgr, int req_portal,
                         int rep_portal, struct ptlrpc_client *cl)
 {
         memset(cl, 0, sizeof(*cl));
         cl->cli_ha_mgr = mgr;
         if (mgr)
-                llite_ha_conn_manage(mgr, cl);
+                connmgr_cli_manage(mgr, cl);
         cl->cli_obd = NULL;
         cl->cli_request_portal = req_portal;
         cl->cli_reply_portal = rep_portal;
@@ -62,7 +41,7 @@ void ptlrpc_init_client(struct lustre_ha_mgr *mgr, int req_portal,
         sema_init(&cl->cli_rpc_sem, 32);
 }
 
-struct ptlrpc_connection *ptlrpc_connect_client(char *uuid)
+struct ptlrpc_connection *ptlrpc_uuid_to_connection(char *uuid)
 {
         struct ptlrpc_connection *c;
         struct lustre_peer peer;
@@ -94,6 +73,16 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk(struct ptlrpc_connection *conn)
         return bulk;
 }
 
+void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk)
+{
+        if (bulk == NULL)
+                return;
+
+        ptlrpc_put_connection(bulk->b_connection);
+
+        OBD_FREE(bulk, sizeof(*bulk));
+}
+
 struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl,
                                        struct ptlrpc_connection *conn,
                                        int opcode, int count, int *lengths,
@@ -124,6 +113,7 @@ struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl,
         request->rq_reqmsg->token = conn->c_remote_token;
         request->rq_reqmsg->opc = HTON__u32(opcode);
         request->rq_reqmsg->type = HTON__u32(request->rq_type);
+        INIT_LIST_HEAD(&request->rq_list);
 
         spin_lock(&conn->c_lock);
         request->rq_reqmsg->xid = HTON__u32(++conn->c_xid_out);
@@ -142,6 +132,10 @@ void ptlrpc_free_req(struct ptlrpc_request *request)
         if (request->rq_repmsg != NULL)
                 OBD_FREE(request->rq_repmsg, request->rq_replen);
 
+        spin_lock(&request->rq_client->cli_ha_mgr->mgr_lock);
+        list_del(&request->rq_list);
+        spin_unlock(&request->rq_client->cli_ha_mgr->mgr_lock);
+
         ptlrpc_put_connection(request->rq_connection);
 
         OBD_FREE(request, sizeof(*request));
@@ -157,10 +151,10 @@ static int ptlrpc_check_reply(struct ptlrpc_request *req)
                 GOTO(out, rc = 1);
         }
 
-        if (CURRENT_TIME - req->rq_time >= 3) { 
-                CERROR("-- REQ TIMEOUT --\n"); 
+        if (CURRENT_TIME - req->rq_time >= 3) {
+                CERROR("-- REQ TIMEOUT --\n");
                 if (req->rq_client && req->rq_client->cli_ha_mgr)
-                        llite_ha_conn_fail(req->rq_client); 
+                        connmgr_cli_fail(req->rq_client);
                 return 0;
         }