Whamcloud - gitweb
- fixed some warnings in the DLM
[fs/lustre-release.git] / lustre / ptlrpc / events.c
index fc97e3a..16ddff1 100644 (file)
 
 #define EXPORT_SYMTAB
 
-#include <linux/config.h>
 #include <linux/module.h>
-#include <linux/kernel.h>
 
 #define DEBUG_SUBSYSTEM S_RPC
 
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
 #include <linux/lustre_net.h>
 
-ptl_handle_eq_t sent_pkt_eq, rcvd_rep_eq, bulk_source_eq, bulk_sink_eq;
+ptl_handle_eq_t request_out_eq, 
+                reply_in_eq, 
+                reply_out_eq,
+                bulk_source_eq, 
+                bulk_sink_eq;
 static const ptl_handle_ni_t *socknal_nip = NULL, *qswnal_nip = NULL;
 
 /*
  *  Free the packet when it has gone out
  */
-static int sent_packet_callback(ptl_event_t *ev, void *data)
+static int request_out_callback(ptl_event_t *ev, void *data)
+{
+        struct ptlrpc_request *req = ev->mem_desc.user_ptr;
+        struct ptlrpc_client *cl = req->rq_client; 
+        
+        ENTRY;
+
+        if (ev->type == PTL_EVENT_SENT) {
+                spin_lock(&req->rq_client->cli_ha_mgr->mgr_lock);
+                list_del(&req->rq_list);
+                list_add(&req->rq_list, &cl->cli_sent_head);
+                spin_unlock(&req->rq_client->cli_ha_mgr->mgr_lock);
+        } else { 
+                // XXX make sure we understand all events, including ACK's
+                CERROR("Unknown event %d\n", ev->type); 
+                LBUG();
+        }
+
+        RETURN(1);
+}
+
+
+/*
+ *  Free the packet when it has gone out
+ */
+static int reply_out_callback(ptl_event_t *ev, void *data)
 {
         ENTRY;
 
@@ -50,20 +75,19 @@ static int sent_packet_callback(ptl_event_t *ev, void *data)
                 LBUG();
         }
 
-        EXIT;
-        return 1;
+        RETURN(1);
 }
 
 /*
  * Wake up the thread waiting for the reply once it comes in.
  */
-static int rcvd_reply_callback(ptl_event_t *ev, void *data)
+static int reply_in_callback(ptl_event_t *ev, void *data)
 {
         struct ptlrpc_request *rpc = ev->mem_desc.user_ptr;
         ENTRY;
 
         if (ev->type == PTL_EVENT_PUT) {
-                rpc->rq_repbuf = ev->mem_desc.start + ev->offset;
+                rpc->rq_repmsg = ev->mem_desc.start + ev->offset;
                 barrier();
                 wake_up_interruptible(&rpc->rq_wait_for_rep);
         } else { 
@@ -72,11 +96,10 @@ static int rcvd_reply_callback(ptl_event_t *ev, void *data)
                 LBUG();
         }
 
-        EXIT;
-        return 1;
+        RETURN(1);
 }
 
-int server_request_callback(ptl_event_t *ev, void *data)
+int request_in_callback(ptl_event_t *ev, void *data)
 {
         struct ptlrpc_service *service = data;
         int index;
@@ -95,17 +118,18 @@ int server_request_callback(ptl_event_t *ev, void *data)
 
         service->srv_ref_count[index]++;
 
-        if (ev->unlinked_me != -1) {
+        if (ptl_is_valid_handle(&ev->unlinked_me)) {
                 int idx;
 
                 for (idx = 0; idx < service->srv_ring_length; idx++)
-                        if (service->srv_me_h[idx] == ev->unlinked_me)
+                        if (service->srv_me_h[idx].handle_idx ==
+                            ev->unlinked_me.handle_idx)
                                 break;
                 if (idx == service->srv_ring_length)
                         LBUG();
 
-                CDEBUG(D_NET, "unlinked %d\n", idx); 
-                service->srv_me_h[idx] = 0; 
+                CDEBUG(D_NET, "unlinked %d\n", idx);
+                ptl_set_inv_handle(&(service->srv_me_h[idx]));
 
                 if (service->srv_ref_count[idx] == 0)
                         ptlrpc_link_svc_me(service, idx); 
@@ -185,11 +209,15 @@ int ptlrpc_init_portals(void)
         else
                 ni = *socknal_nip;
 
-        rc = PtlEQAlloc(ni, 128, sent_packet_callback, NULL, &sent_pkt_eq);
+        rc = PtlEQAlloc(ni, 128, request_out_callback, NULL, &request_out_eq);
+        if (rc != PTL_OK)
+                CERROR("PtlEQAlloc failed: %d\n", rc);
+
+        rc = PtlEQAlloc(ni, 128, reply_out_callback, NULL, &reply_out_eq);
         if (rc != PTL_OK)
                 CERROR("PtlEQAlloc failed: %d\n", rc);
 
-        rc = PtlEQAlloc(ni, 128, rcvd_reply_callback, NULL, &rcvd_rep_eq);
+        rc = PtlEQAlloc(ni, 128, reply_in_callback, NULL, &reply_in_eq);
         if (rc != PTL_OK)
                 CERROR("PtlEQAlloc failed: %d\n", rc);
 
@@ -206,8 +234,9 @@ int ptlrpc_init_portals(void)
 
 void ptlrpc_exit_portals(void)
 {
-        PtlEQFree(sent_pkt_eq);
-        PtlEQFree(rcvd_rep_eq);
+        PtlEQFree(request_out_eq);
+        PtlEQFree(reply_out_eq);
+        PtlEQFree(reply_in_eq);
         PtlEQFree(bulk_source_eq);
         PtlEQFree(bulk_sink_eq);