Whamcloud - gitweb
- documentation update for MDS recovery
[fs/lustre-release.git] / lustre / include / linux / lustre_net.h
index b6cf21e..5914728 100644 (file)
 #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
  * FOO_BULK_PORTAL    is for incoming bulk on the FOO
  */
 
-#define OSC_REQUEST_PORTAL 1
-#define OSC_REPLY_PORTAL   2
-#define OSC_BULK_PORTAL    3
-
-#define OST_REQUEST_PORTAL 4
-#define OST_REPLY_PORTAL   5
-#define OST_BULK_PORTAL    6
-
-#define MDC_REQUEST_PORTAL 7
-#define MDC_REPLY_PORTAL   8
-#define MDC_BULK_PORTAL    9
-
-#define MDS_REQUEST_PORTAL 10
-#define MDS_REPLY_PORTAL   11
-#define MDS_BULK_PORTAL    12
-
-#define LDLM_REQUEST_PORTAL     13
-#define LDLM_REPLY_PORTAL       14
+#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    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
+#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;
+        __u8 c_local_uuid[37];
+        __u8 c_remote_uuid[37];
 
+        int c_level;
         __u32 c_generation;  /* changes upon new connection */
         __u32 c_epoch;       /* changes when peer changes */
         __u32 c_bootcount;   /* peer's boot count */ 
@@ -79,32 +93,46 @@ struct ptlrpc_connection {
 
         atomic_t c_refcount;
         __u64 c_token;
-
         __u64 c_remote_conn;
         __u64 c_remote_token;
 };
 
 struct ptlrpc_client {
         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;
+        __u64 cli_last_rcvd;
+        __u64 cli_last_committed;
+
+        struct semaphore cli_rpc_sem; /* limits outstanding requests */
 
-        struct semaphore cli_rpc_sem;
+        spinlock_t cli_lock; /* protects lists */
+        struct list_head cli_sending_head;
+        struct list_head cli_sent_head;
+        struct list_head cli_replied_head;
+        struct list_head cli_replay_head;
         struct list_head cli_ha_item; 
-        struct lustre_ha_mgr *cli_ha_mgr;
+        void (*cli_recover)(struct ptlrpc_client *); 
+
+        struct recovd_obd *cli_recovd;
 };
 
-/* These do double-duty in rq_type and rq_flags */
-#define PTL_RPC_INTR    1
-#define PTL_RPC_REQUEST 2
-#define PTL_RPC_REPLY   3
-#define PTL_RPC_BULK    4
-#define PTL_RPC_SENT    5
-#define PTL_BULK_SENT   6
-#define PTL_BULK_RCVD   7
-#define PTL_RPC_ERR     8
+/* 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_REPLY     (1 << 1)
+#define PTL_RPC_FL_SENT      (1 << 2)
+#define PTL_BULK_FL_SENT     (1 << 3)
+#define PTL_BULK_FL_RCVD     (1 << 4)
+#define PTL_RPC_FL_ERR       (1 << 5)
+#define PTL_RPC_FL_TIMEOUT   (1 << 6)
+#define PTL_RPC_FL_RESEND    (1 << 7)
+#define PTL_RPC_FL_COMMITTED (1 << 8)
+#define PTL_RPC_FL_FINISHED  (1 << 9)
+#define PTL_RPC_FL_RETAIN    (1 << 10)
 
 struct ptlrpc_request { 
         int rq_type; /* one of PTL_RPC_REQUEST, PTL_RPC_REPLY, PTL_RPC_BULK */
@@ -114,18 +142,21 @@ struct ptlrpc_request {
         int rq_status;
         int rq_flags; 
         __u32 rq_connid;
+        atomic_t rq_refcount;
 
         int rq_reqlen;
         struct lustre_msg *rq_reqmsg;
 
         int rq_replen;
         struct lustre_msg *rq_repmsg;
+        __u64 rq_transno;
 
         char *rq_bulkbuf;
         int rq_bulklen;
 
         time_t rq_time;
-        void * rq_reply_handle;
+        time_t rq_timeout;
+        //        void * rq_reply_handle;
         wait_queue_head_t rq_wait_for_rep;
 
         /* incoming reply */
@@ -160,6 +191,9 @@ struct ptlrpc_bulk_desc {
 };
 
 struct ptlrpc_service {
+        time_t srv_time;
+        time_t srv_timeout;
+
         /* incoming request buffers */
         /* FIXME: perhaps a list of EQs, if multiple NIs are used? */
         char *srv_buf[RPC_RING_LENGTH];
@@ -205,24 +239,29 @@ void ptlrpc_cleanup_connection(void);
 /* rpc/niobuf.c */
 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 ptlrpc_connection *,
-                 int portal);
 int ptlrpc_register_bulk(struct ptlrpc_bulk_desc *);
 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);
+void ptlrpc_resend_req(struct ptlrpc_request *request);
 int ptl_send_rpc(struct ptlrpc_request *request);
 void ptlrpc_link_svc_me(struct ptlrpc_service *service, int i);
 
 /* rpc/client.c */
-void ptlrpc_init_client(struct lustre_ha_mgr *, int req_portal, int rep_portal,
+void ptlrpc_init_client(struct recovd_obd *, 
+                        void (*recover)(struct ptlrpc_client *),
+                        int req_portal, int rep_portal,
                         struct ptlrpc_client *);
-struct ptlrpc_connection *ptlrpc_connect_client(char *uuid);
+void ptlrpc_cleanup_client(struct ptlrpc_client *cli);
+__u8 *ptlrpc_req_to_uuid(struct ptlrpc_request *req);
+struct ptlrpc_connection *ptlrpc_uuid_to_connection(char *uuid);
 int ptlrpc_queue_wait(struct ptlrpc_request *req);
 struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl,
                                        struct ptlrpc_connection *u, int opcode,
                                        int count, int *lengths, char **bufs);
+void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
 void ptlrpc_free_req(struct ptlrpc_request *request);
+void ptlrpc_req_finished(struct ptlrpc_request *request);
 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk(struct ptlrpc_connection *);
 int ptlrpc_check_status(struct ptlrpc_request *req, int err);