#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_lock);
+ list_del(&req->rq_list);
+ list_add(&req->rq_list, &cl->cli_sent_head);
+ spin_unlock(&req->rq_client->cli_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;
} else {
// XXX make sure we understand all events, including ACK's
CERROR("Unknown event %d\n", ev->type);
- BUG();
+ 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 {
// XXX make sure we understand all events, including ACK's
CERROR("Unknown event %d\n", ev->type);
- BUG();
+ 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 rc;
+ int index;
if (ev->rlength != ev->mlength)
CERROR("Warning: Possibly truncated rpc (%d/%d)\n",
ev->mlength, ev->rlength);
- /* The ME is unlinked when there is less than 1024 bytes free
- * on its MD. This ensures we are always able to handle the rpc,
- * although the 1024 value is a guess as to the size of a
- * large rpc (the known safe margin should be determined).
- *
- * NOTE: The portals API by default unlinks all MD's associated
- * with an ME when it's unlinked. For now, this behavior
- * has been commented out of the portals library so the
- * MD can be unlinked when its ref count drops to zero.
- * A new MD and ME will then be created that use the same
- * kmalloc()'ed memory and inserted at the ring tail.
- */
-
- service->srv_ref_count[service->srv_md_active]++;
-
- if (ev->offset >= (service->srv_buf_size - 1024)) {
- CDEBUG(D_INODE, "Unlinking ME %d\n", service->srv_me_active);
-
- rc = PtlMEUnlink(service->srv_me_h[service->srv_me_active]);
- service->srv_me_h[service->srv_me_active] = 0;
-
- if (rc != PTL_OK) {
- CERROR("PtlMEUnlink failed - DROPPING soon: %d\n", rc);
- BUG();
- return rc;
- }
-
- service->srv_me_active = NEXT_INDEX(service->srv_me_active,
- service->srv_ring_length);
-
- if (service->srv_me_h[service->srv_me_active] == 0)
- CERROR("All %d ring ME's are unlinked!\n",
- service->srv_ring_length);
+ spin_lock(&service->srv_lock);
+ for (index = 0; index < service->srv_ring_length; index++)
+ if ( service->srv_buf[index] == ev->mem_desc.start)
+ break;
+
+ if (index == service->srv_ring_length)
+ LBUG();
+
+ service->srv_ref_count[index]++;
+
+ 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].handle_idx ==
+ ev->unlinked_me.handle_idx)
+ break;
+ if (idx == service->srv_ring_length)
+ LBUG();
+
+ 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);
}
- if (ev->type == PTL_EVENT_PUT) {
+ spin_unlock(&service->srv_lock);
+ if (ev->type == PTL_EVENT_PUT)
wake_up(&service->srv_waitq);
- } else {
+ else
CERROR("Unexpected event type: %d\n", ev->type);
- }
return 0;
}
-
static int bulk_source_callback(ptl_event_t *ev, void *data)
{
struct ptlrpc_bulk_desc *bulk = ev->mem_desc.user_ptr;
CDEBUG(D_NET, "got SENT event\n");
} else if (ev->type == PTL_EVENT_ACK) {
CDEBUG(D_NET, "got ACK event\n");
- bulk->b_flags = PTL_BULK_SENT;
+ bulk->b_flags |= PTL_BULK_FL_SENT;
wake_up_interruptible(&bulk->b_waitq);
} else {
CERROR("Unexpected event type!\n");
- BUG();
+ LBUG();
}
EXIT;
if (ev->type == PTL_EVENT_PUT) {
if (bulk->b_buf != ev->mem_desc.start + ev->offset)
CERROR("bulkbuf != mem_desc -- why?\n");
- bulk->b_flags = PTL_BULK_RCVD;
+ bulk->b_flags |= PTL_BULK_FL_RCVD;
if (bulk->b_cb != NULL)
bulk->b_cb(bulk, data);
wake_up_interruptible(&bulk->b_waitq);
} else {
CERROR("Unexpected event type!\n");
- BUG();
+ LBUG();
}
/* FIXME: This should happen unconditionally */
- if (bulk->b_cb != NULL) {
+ if (bulk->b_cb != NULL)
OBD_FREE(bulk, sizeof(*bulk));
- }
EXIT;
return 1;
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);
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);