Whamcloud - gitweb
Add some basic data integrity checking to obdecho.
[fs/lustre-release.git] / lustre / include / linux / lustre_net.h
index 56452cd..0c50c99 100644 (file)
 #ifndef _LUSTRE_NET_H
 #define _LUSTRE_NET_H
 
+#include <linux/tqueue.h>
 #include <linux/kp30.h>
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
+#include <linux/obd.h>
 #include <portals/p30.h>
 #include <linux/lustre_idl.h>
 
-/* FOO_REQUEST_PORTAL is for incoming requests on the FOO
- * FOO_REPLY_PORTAL   is for incoming replies on the FOO
- * FOO_BULK_PORTAL    is for incoming bulk on the FOO
- */
-
-#define CONNMGR_REQUEST_PORTAL    1
-#define CONNMGR_REPLY_PORTAL      2
-//#define OSC_REQUEST_PORTAL      3
-#define OSC_REPLY_PORTAL        4
-#define OSC_BULK_PORTAL         5
-#define OST_REQUEST_PORTAL      6
-//#define OST_REPLY_PORTAL        7
-#define OST_BULK_PORTAL         8
-#define MDC_REQUEST_PORTAL      9
-#define MDC_REPLY_PORTAL        10
-#define MDC_BULK_PORTAL         11
-#define MDS_REQUEST_PORTAL      12
-#define MDS_REPLY_PORTAL        13
-#define MDS_BULK_PORTAL         14
-#define LDLM_REQUEST_PORTAL     15
-#define LDLM_REPLY_PORTAL       16
-#define LDLM_CLI_REQUEST_PORTAL 17
-#define LDLM_CLI_REPLY_PORTAL   18
-
 /* default rpc ring length */
 #define RPC_RING_LENGTH    10
 
-#define SVC_KILLED 1
-#define SVC_EVENT  2
-#define SVC_SIGNAL 4
-#define SVC_RUNNING 8
-#define SVC_STOPPING 16
-#define SVC_STOPPED  32
-
-#define RECOVD_STOPPING      1     /* how cleanup tells recovd to quit */
-#define RECOVD_IDLE          2     /* normal state */
-#define RECOVD_STOPPED       4     /* after recovd has stopped */
-#define RECOVD_FAIL          8     /* RPC timeout: wakeup recovd, sets flag */
-#define RECOVD_TIMEOUT       16    /* set when recovd detects a timeout */
-#define RECOVD_UPCALL_WAIT   32    /* an upcall has been placed */
-#define RECOVD_UPCALL_ANSWER 64    /* an upcall has been answered */
-
-#define LUSTRE_CONN_NEW    1
-#define LUSTRE_CONN_CON    2
-#define LUSTRE_CONN_RECOVD 3
-#define LUSTRE_CONN_FULL   4
-
 struct ptlrpc_connection {
         struct list_head c_link;
         struct lustre_peer c_peer;
@@ -102,7 +58,7 @@ struct ptlrpc_client {
         __u32 cli_request_portal;
         __u32 cli_reply_portal;
 
-        __u64 cli_last_rcvd;
+        __u64 cli_last_xid;
         __u64 cli_last_committed;
         __u32 cli_target_devno;
 
@@ -120,10 +76,6 @@ struct ptlrpc_client {
         char *cli_name;
 };
 
-/* packet types */
-#define PTL_RPC_TYPE_REQUEST 2
-#define PTL_RPC_TYPE_REPLY   3
-
 /* state flags of requests */
 #define PTL_RPC_FL_INTR      (1 << 0)
 #define PTL_RPC_FL_REPLIED   (1 << 1)  /* reply was received */
@@ -175,6 +127,8 @@ struct ptlrpc_request {
         ptl_md_t rq_req_md;
         ptl_handle_md_t rq_req_md_h;
 
+        struct lustre_peer rq_peer; /* XXX see service.c can this be factored away? */
+        struct obd_export *rq_export;
         struct ptlrpc_connection *rq_connection;
         struct ptlrpc_client *rq_client;
         struct ptlrpc_service *rq_svc;
@@ -190,10 +144,6 @@ struct ptlrpc_bulk_page {
         __u32 b_flags;
         struct dentry *b_dentry;
         int (*b_cb)(struct ptlrpc_bulk_page *);
-
-        ptl_md_t b_md;
-        ptl_handle_md_t b_md_h;
-        ptl_handle_me_t b_me_h;
 };
 
 struct ptlrpc_bulk_desc {
@@ -201,15 +151,22 @@ struct ptlrpc_bulk_desc {
         struct ptlrpc_connection *b_connection;
         struct ptlrpc_client *b_client;
         __u32 b_portal;
-        struct obd_conn b_conn;
+        struct lustre_handle b_conn;
         void (*b_cb)(struct ptlrpc_bulk_desc *, void *);
         void *b_cb_data;
 
         wait_queue_head_t b_waitq;
         struct list_head b_page_list;
         __u32 b_page_count;
-        atomic_t b_pages_remaining;
+        atomic_t b_refcount;
         void *b_desc_private;
+        struct tq_struct b_queue;
+
+        ptl_md_t b_md;
+        ptl_handle_md_t b_md_h;
+        ptl_handle_me_t b_me_h;
+
+        struct iovec b_iov[16];                 /* self-sized pre-allocated iov */
 };
 
 struct ptlrpc_thread {
@@ -248,6 +205,15 @@ struct ptlrpc_service {
         int (*srv_handler)(struct ptlrpc_request *req);
 };
 
+static inline void ptlrpc_hdl2req(struct ptlrpc_request *req, struct lustre_handle *h)
+{
+        req->rq_reqmsg->addr = h->addr;
+        req->rq_reqmsg->cookie = h->cookie;
+}
+struct ptlrpc_request *ptlrpc_prep_req2(struct lustre_handle *conn, 
+                                        int opcode, int count, int *lengths,
+                                        char **bufs);
+
 typedef void (*bulk_callback_t)(struct ptlrpc_bulk_desc *, void *);
 
 typedef int (*svc_handler_t)(struct ptlrpc_request *req);
@@ -262,6 +228,7 @@ void ptlrpc_cleanup_connection(void);
 
 /* rpc/niobuf.c */
 int ptlrpc_check_bulk_sent(struct ptlrpc_bulk_desc *bulk);
+int ptlrpc_check_bulk_received(struct ptlrpc_bulk_desc *bulk);
 int ptlrpc_send_bulk(struct ptlrpc_bulk_desc *);
 int ptlrpc_register_bulk(struct ptlrpc_bulk_desc *);
 int ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *bulk);
@@ -318,4 +285,23 @@ int lustre_pack_msg(int count, int *lens, char **bufs, int *len,
 int lustre_msg_size(int count, int *lengths);
 int lustre_unpack_msg(struct lustre_msg *m, int len);
 void *lustre_msg_buf(struct lustre_msg *m, int n);
+
+static inline void ptlrpc_bulk_decref(struct ptlrpc_bulk_desc *desc)
+{
+        if (atomic_dec_and_test(&desc->b_refcount)) {
+                CDEBUG(D_PAGE, "Released last ref on %p, freeing\n", desc);
+                ptlrpc_free_bulk(desc);
+        } else {
+                CDEBUG(D_PAGE, "%p -> %d\n", desc,
+                       atomic_read(&desc->b_refcount));
+        }
+}
+
+static inline void ptlrpc_bulk_addref(struct ptlrpc_bulk_desc *desc)
+{
+        atomic_inc(&desc->b_refcount);
+        CDEBUG(D_PAGE, "Set refcount of %p to %d\n", desc,
+               atomic_read(&desc->b_refcount));
+}
+
 #endif