Whamcloud - gitweb
- More Peter's additions for the ha manager. This doesn't seem to break much -
[fs/lustre-release.git] / lustre / include / linux / lustre_net.h
index d6ab12a..78bd73b 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/obd_class.h>
 #include <portals/p30.h>
 #include <linux/lustre_idl.h>
+#include <linux/lustre_ha.h>
 
 /* FOO_REQUEST_PORTAL is for incoming requests on the FOO
  * FOO_REPLY_PORTAL   is for incoming replies on the FOO
 #define MDS_REPLY_PORTAL   11
 #define MDS_BULK_PORTAL    12
 
-#define LDLM_REQUEST_PORTAL 13
-#define LDLM_REPLY_PORTAL   14
+#define LDLM_REQUEST_PORTAL     13
+#define LDLM_REPLY_PORTAL       14
+#define LDLM_CLI_REQUEST_PORTAL 15
+#define LDLM_CLI_REPLY_PORTAL   16
 
 /* default rpc ring length */
 #define RPC_RING_LENGTH    2
 
 #define SVC_STOPPING 1
-#define SVC_RUNNING 2
-#define SVC_STOPPED 4
-#define SVC_KILLED  8
-#define SVC_EVENT  16
-#define SVC_LIST   32
-#define SVC_SIGNAL 64
-
-typedef int (*rep_unpack_t)(char *, int, struct ptlrep_hdr **, union ptl_rep *);
-typedef int (*req_pack_t)(char *, int, char *, int, struct ptlreq_hdr **,
-                          union ptl_req*, int *, char **); 
-
-typedef int (*req_unpack_t)(char *buf, int len, struct ptlreq_hdr **, 
-                            union ptl_req *);
-typedef int (*rep_pack_t)(char *buf1, int len1, char *buf2, int len2,
-                          struct ptlrep_hdr **, union ptl_rep*, 
-                          int *replen, char **repbuf); 
+#define SVC_RUNNING  2
+#define SVC_STOPPED  4
+#define SVC_KILLED   8
+#define SVC_EVENT   16
+#define SVC_LIST    32
+#define SVC_SIGNAL  64
 
 struct ptlrpc_client {
-        struct lustre_peer cli_server;
         struct obd_device *cli_obd;
+        struct list_head cli_sending_head;
+        struct list_head cli_sent_head;
         __u32 cli_request_portal;
         __u32 cli_reply_portal;
-        rep_unpack_t cli_rep_unpack;
-        req_pack_t cli_req_pack;
 
         spinlock_t cli_lock;
         __u32 cli_xid;
-        atomic_t cli_queue_length;
-        wait_queue_head_t cli_waitq;
+        __u32 cli_generation;  /* changes upon new connection */
+        __u32 cli_epoch;       /* changes when peer changes */
+        __u32 cli_bootcount;   /* peer's boot count */ 
+        struct semaphore cli_rpc_sem;
+        struct list_head cli_ha_item; 
+        struct lustre_ha_mgr *cli_ha_mgr;
 };
 
 /* These do double-duty in rq_type and rq_flags */
@@ -108,19 +104,18 @@ struct ptlrpc_request {
         __u32 rq_connid;
         __u32 rq_xid;
 
-        char *rq_reqbuf;
         int rq_reqlen;
-        struct ptlreq_hdr *rq_reqhdr;
-        union ptl_req rq_req;
+        char *rq_reqbuf;
+        struct lustre_msg *rq_reqmsg;
 
-        char *rq_repbuf;
         int rq_replen;
-        struct ptlrep_hdr *rq_rephdr;
-        union ptl_rep rq_rep;
+        char *rq_repbuf;
+        struct lustre_msg *rq_repmsg;
 
         char *rq_bulkbuf;
         int rq_bulklen;
 
+        time_t rq_time;
         void * rq_reply_handle;
         wait_queue_head_t rq_wait_for_rep;
 
@@ -137,6 +132,7 @@ struct ptlrpc_request {
         __u32 rq_req_portal;
 
         struct lustre_peer rq_peer;
+        struct ptlrpc_client *rq_client;
 };
 
 struct ptlrpc_bulk_desc {
@@ -184,8 +180,6 @@ struct ptlrpc_service {
         spinlock_t srv_lock;
         struct list_head srv_reqs;
         ptl_event_t  srv_ev;
-        req_unpack_t      srv_req_unpack;
-        rep_pack_t        srv_rep_pack;
         int (*srv_handler)(struct obd_device *obddev, 
                            struct ptlrpc_service *svc,
                            struct ptlrpc_request *req);
@@ -202,22 +196,22 @@ int ptlrpc_check_bulk_sent(struct ptlrpc_bulk_desc *);
 int ptlrpc_send_bulk(struct ptlrpc_bulk_desc *, int portal);
 int ptl_send_buf(struct ptlrpc_request *, struct lustre_peer *, int portal);
 int ptlrpc_register_bulk(struct ptlrpc_bulk_desc *);
-int ptlrpc_reply(struct obd_device *obddev, struct ptlrpc_service *svc,
-                 struct ptlrpc_request *req);
-int ptlrpc_error(struct obd_device *obddev, struct ptlrpc_service *svc,
-                 struct ptlrpc_request *req);
-int ptl_send_rpc(struct ptlrpc_request *request, struct lustre_peer *peer);
+int ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *bulk);
+int ptlrpc_reply(struct ptlrpc_service *svc, struct ptlrpc_request *req);
+int ptlrpc_error(struct ptlrpc_service *svc, struct ptlrpc_request *req);
+int ptl_send_rpc(struct ptlrpc_request *request, struct ptlrpc_client *cl);
 void ptlrpc_link_svc_me(struct ptlrpc_service *service, int i);
 
 /* rpc/client.c */
-int ptlrpc_connect_client(int dev, char *uuid, int req_portal, int rep_portal, 
-                          req_pack_t req_pack, rep_unpack_t rep_unpack,
-                          struct ptlrpc_client *cl);
+void ptlrpc_init_client(struct lustre_ha_mgr *mgr, int req_portal, int rep_portal,
+                       struct ptlrpc_client *cl);
+int ptlrpc_connect_client(char *uuid, struct ptlrpc_client *cl,
+                          struct lustre_peer *peer);
 int ptlrpc_queue_wait(struct ptlrpc_client *cl, struct ptlrpc_request *req);
 int ptlrpc_queue_req(struct ptlrpc_client *peer, struct ptlrpc_request *req);
-struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl, 
-                                       int opcode, int namelen, char *name,
-                                       int tgtlen, char *tgt);
+struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl,
+                                       struct lustre_peer *peer, int opcode,
+                                       int count, int *lengths, char **bufs);
 void ptlrpc_free_req(struct ptlrpc_request *request);
 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk(struct lustre_peer *);
 int ptlrpc_check_status(struct ptlrpc_request *req, int err);
@@ -237,4 +231,10 @@ struct ptlrpc_svc_data {
         struct obd_device *dev;
 }; 
 
+/* rpc/pack_generic.c */
+int lustre_pack_msg(int count, int *lens, char **bufs, int *len, char **buf);
+int lustre_msg_size(int count, int *lengths);
+int lustre_unpack_msg(char *buf, int len);
+void *lustre_msg_buf(struct lustre_msg *m, int n);
+
 #endif