Whamcloud - gitweb
Branch: b1_6
[fs/lustre-release.git] / lustre / include / lustre_net.h
index dd11208..1bd2eab 100644 (file)
  * considered full when less than ?_MAXREQSIZE is left in them.
  */
 
-#define LDLM_THREADS_AUTO_MIN min((int)(smp_num_cpus * smp_num_cpus * 2), 8)
+#define LDLM_THREADS_AUTO_MIN                                                 \
+        min((int)(num_online_cpus() * num_online_cpus() * 2), 8)
 #define LDLM_THREADS_AUTO_MAX (LDLM_THREADS_AUTO_MIN * 16)
 #define LDLM_BL_THREADS  LDLM_THREADS_AUTO_MIN
-#define LDLM_NBUFS      (64 * smp_num_cpus)
+#define LDLM_NBUFS      (64 * num_online_cpus())
 #define LDLM_BUFSIZE    (8 * 1024)
 #define LDLM_MAXREQSIZE (5 * 1024)
 #define LDLM_MAXREPSIZE (1024)
 
 /* Absolute limits */
-#define MDS_THREADS_MIN 2UL
-#define MDS_THREADS_MAX 512UL
-/* Dynamic thread limits */
-#define MDS_THREADS_AUTO_MIN max(MDS_THREADS_MIN, min(32UL, \
-                             smp_num_cpus * num_physpages >> (27 - CFS_PAGE_SHIFT)))
-#define MDS_THREADS_AUTO_MAX min(MDS_THREADS_MAX, MDS_THREADS_AUTO_MIN * 4)
+#define MDS_THREADS_MIN 2
+#define MDS_THREADS_MAX 512
 #define MDS_THREADS_MIN_READPAGE 2
-#define MDS_NBUFS       (64 * smp_num_cpus)
+#define MDS_NBUFS       (64 * num_online_cpus())
 #define MDS_BUFSIZE     (8 * 1024)
 /* Assume file name length = FNAME_MAX = 256 (true for ext3).
  *        path name length = PATH_MAX = 4096
 #define MDS_MAXREQSIZE  (5 * 1024)
 #define MDS_MAXREPSIZE  max(9 * 1024, 280 + LOV_MAX_STRIPE_COUNT * 56)
 
-#define MGS_THREADS_AUTO_MAX 128UL
-#define MGS_THREADS_AUTO_MIN MDS_THREADS_AUTO_MIN
-#define MGS_NBUFS       (64 * smp_num_cpus)
+#define MGS_THREADS_AUTO_MIN 2
+#define MGS_THREADS_AUTO_MAX 32
+#define MGS_NBUFS       (64 * num_online_cpus())
 #define MGS_BUFSIZE     (8 * 1024)
 #define MGS_MAXREQSIZE  (8 * 1024)
 #define MGS_MAXREPSIZE  (9 * 1024)
 
 /* Absolute limits */
-#define OSS_THREADS_MIN 2UL
-#define OSS_THREADS_MAX 512UL
-/* Dynamic thread limits */
-#define OSS_THREADS_AUTO_MIN max(OSS_THREADS_MIN, \
-                             smp_num_cpus * num_physpages >> (27 - CFS_PAGE_SHIFT))
-#define OSS_THREADS_AUTO_MAX min(OSS_THREADS_MAX, OSS_THREADS_AUTO_MIN * 4)
-#define OST_NBUFS       (64 * smp_num_cpus)
+#define OSS_THREADS_MIN 2
+#define OSS_THREADS_MAX 512
+#define OST_NBUFS       (64 * num_online_cpus())
 #define OST_BUFSIZE     (8 * 1024)
 /* OST_MAXREQSIZE ~= 4768 bytes =
  * lustre_msg + obdo + 16 * obd_ioobj + 256 * niobuf_remote
 
 struct ptlrpc_connection {
         struct list_head        c_link;
+        struct hlist_node       c_hash;
         lnet_nid_t              c_self;
         lnet_process_id_t       c_peer;
         struct obd_uuid         c_remote_uuid;
@@ -187,6 +181,7 @@ struct ptlrpc_request_set {
         cfs_waitq_t       set_waitq;
         cfs_waitq_t      *set_wakeup_ptr;
         struct list_head  set_requests;
+        struct list_head  set_cblist; /* list of completion callbacks */
         set_interpreter_func    set_interpret; /* completion callback */
         void              *set_arg; /* completion context */
         /* locked so that any old caller can communicate requests to
@@ -195,6 +190,12 @@ struct ptlrpc_request_set {
         struct list_head  set_new_requests;
 };
 
+struct ptlrpc_set_cbdata {
+        struct list_head        psc_item;
+        set_interpreter_func    psc_interpret;
+        void                   *psc_data;
+};
+
 struct ptlrpc_bulk_desc;
 
 /*
@@ -217,12 +218,12 @@ struct ptlrpc_reply_state {
         struct list_head       rs_debug_list;
 #endif
         /* updates to following flag serialised by srv_request_lock */
-        unsigned int           rs_difficult:1;     /* ACK/commit stuff */
-        unsigned int           rs_scheduled:1;     /* being handled? */
-        unsigned int           rs_scheduled_ever:1;/* any schedule attempts? */
-        unsigned int           rs_handled:1;  /* been handled yet? */
-        unsigned int           rs_on_net:1;   /* reply_out_callback pending? */
-        unsigned int           rs_prealloc:1; /* rs from prealloc list */
+        unsigned long          rs_difficult:1;     /* ACK/commit stuff */
+        unsigned long          rs_scheduled:1;     /* being handled? */
+        unsigned long          rs_scheduled_ever:1;/* any schedule attempts? */
+        unsigned long          rs_handled:1;  /* been handled yet? */
+        unsigned long          rs_on_net:1;   /* reply_out_callback pending? */
+        unsigned long          rs_prealloc:1; /* rs from prealloc list */
 
         int                    rs_size;
         __u64                  rs_transno;
@@ -260,12 +261,13 @@ struct ptlrpc_request_pool {
 struct ptlrpc_request {
         int rq_type; /* one of PTL_RPC_MSG_* */
         struct list_head rq_list;
+        struct list_head rq_timed_list;         /* server-side early replies */
         struct list_head rq_history_list;       /* server-side history */
         __u64            rq_history_seq;        /* history sequence # */
         int rq_status;
         spinlock_t rq_lock;
-        /* client-side flags */
-        unsigned int rq_intr:1, rq_replied:1, rq_err:1,
+        /* client-side flags are serialized by rq_lock */
+        unsigned long rq_intr:1, rq_replied:1, rq_err:1,
                 rq_timedout:1, rq_resend:1, rq_restart:1,
                 /*
                  * when ->rq_replay is set, request is kept by the client even
@@ -278,9 +280,13 @@ struct ptlrpc_request {
                  */
                 rq_replay:1,
                 rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1,
-                rq_no_delay:1, rq_net_err:1;
+                rq_no_delay:1, rq_net_err:1, rq_early:1, rq_must_unlink:1,
+                /* server-side flags */
+                rq_packed_final:1,  /* packed final reply */
+                rq_sent_final:1;    /* stop sending early replies */
         enum rq_phase rq_phase; /* one of RQ_PHASE_* */
-        atomic_t rq_refcount;   /* client-side refcount for SENT race */
+        atomic_t rq_refcount;   /* client-side refcount for SENT race,
+                                   server-side refcounf for multiple replies */
 
         struct ptlrpc_thread *rq_svc_thread; /* initial thread servicing req */
 
@@ -292,8 +298,8 @@ struct ptlrpc_request {
         int rq_reqlen;
         struct lustre_msg *rq_reqmsg;
 
-        int rq_timeout;         /* time to wait for reply (seconds) */
         int rq_replen;
+        struct lustre_msg *rq_repbuf; /* client only, buf may be bigger than msg */
         struct lustre_msg *rq_repmsg;
         __u64 rq_transno;
         __u64 rq_xid;
@@ -305,6 +311,8 @@ struct ptlrpc_request {
         int rq_import_generation;
         enum lustre_imp_state rq_send_state;
 
+        int rq_early_count;           /* how many early replies (for stats) */
+
         /* client+server request */
         lnet_handle_md_t     rq_req_md_h;
         struct ptlrpc_cb_id  rq_req_cbid;
@@ -332,14 +340,20 @@ struct ptlrpc_request {
         void  *rq_cb_data;
 
         struct ptlrpc_bulk_desc *rq_bulk;       /* client side bulk */
-        time_t rq_sent;                         /* when request sent, seconds */
+        /* client outgoing req */
+        time_t rq_sent;                         /* when request sent, seconds, 
+                                                 * or time when request should
+                                                 * be sent */
+        volatile time_t rq_deadline;     /* when request must finish. volatile
+               so that servers' early reply updates to the deadline aren't 
+               kept in per-cpu cache */
+        int    rq_timeout;               /* service time estimate (secs) */
 
         /* Multi-rpc bits */
         struct list_head rq_set_chain;
         struct ptlrpc_request_set *rq_set;
         void *rq_interpret_reply;               /* Async completion handler */
         union ptlrpc_async_args rq_async_args;  /* Async completion context */
-        void *rq_ptlrpcd_data;
         struct ptlrpc_request_pool *rq_pool;    /* Pool if request from
                                                    preallocated list */
 };
@@ -370,24 +384,6 @@ static inline int lustre_rep_swabbed(struct ptlrpc_request *req, int index)
         return req->rq_rep_swab_mask & (1 << index);
 }
 
-#define SWAB_PARANOIA 1
-
-#if SWAB_PARANOIA
-/* unpacking: assert idx not unpacked already */
-#define LASSERT_REQSWAB(rq, idx) lustre_set_req_swabbed(rq, idx)
-#define LASSERT_REPSWAB(rq, idx) lustre_set_rep_swabbed(rq, idx)
-
-/* just looking: assert idx already unpacked */
-#define LASSERT_REQSWABBED(rq, idx) LASSERT(lustre_req_swabbed(rq, idx))
-#define LASSERT_REPSWABBED(rq, idx) LASSERT(lustre_rep_swabbed(rq, idx))
-
-#else
-#define LASSERT_REQSWAB(rq, idx)
-#define LASSERT_REPSWAB(rq, idx)
-#define LASSERT_REQSWABBED(rq, idx)
-#define LASSERT_REPSWABBED(rq, idx)
-#endif
-
 static inline const char *
 ptlrpc_rqphase2str(struct ptlrpc_request *req)
 {
@@ -410,43 +406,44 @@ ptlrpc_rqphase2str(struct ptlrpc_request *req)
 /* Spare the preprocessor, spoil the bugs. */
 #define FLAG(field, str) (field ? str : "")
 
-#define DEBUG_REQ_FLAGS(req)                                                    \
-        ptlrpc_rqphase2str(req),                                                \
-        FLAG(req->rq_intr, "I"), FLAG(req->rq_replied, "R"),                    \
-        FLAG(req->rq_err, "E"),                                                 \
-        FLAG(req->rq_timedout, "X") /* eXpired */, FLAG(req->rq_resend, "S"),   \
-        FLAG(req->rq_restart, "T"), FLAG(req->rq_replay, "P"),                  \
-        FLAG(req->rq_no_resend, "N"),                                           \
+#define DEBUG_REQ_FLAGS(req)                                                  \
+        ptlrpc_rqphase2str(req),                                              \
+        FLAG(req->rq_intr, "I"), FLAG(req->rq_replied, "R"),                  \
+        FLAG(req->rq_err, "E"),                                               \
+        FLAG(req->rq_timedout, "X") /* eXpired */, FLAG(req->rq_resend, "S"), \
+        FLAG(req->rq_restart, "T"), FLAG(req->rq_replay, "P"),                \
+        FLAG(req->rq_no_resend, "N"),                                         \
         FLAG(req->rq_waiting, "W")
 
 #define REQ_FLAGS_FMT "%s:%s%s%s%s%s%s%s%s%s"
 
 void _debug_req(struct ptlrpc_request *req, __u32 mask,
-               struct libcfs_debug_msg_data *data, const char *fmt, ...);
-
-#define debug_req(cdls, level, req, file, func, line, fmt, a...)                \
-do {                                                                            \
-        CHECK_STACK();                                                          \
-                                                                                \
-        if (((level) & D_CANTMASK) != 0 ||                                      \
-            ((libcfs_debug & (level)) != 0 &&                                   \
-             (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) {                \
-                static struct libcfs_debug_msg_data _req_dbg_data =             \
-                DEBUG_MSG_DATA_INIT(cdls, DEBUG_SUBSYSTEM, file, func, line);   \
-                _debug_req((req), (level), &_req_dbg_data, fmt, ##a);           \
-        }                                                                       \
+                struct libcfs_debug_msg_data *data, const char *fmt, ...)
+        __attribute__ ((format (printf, 4, 5)));
+
+#define debug_req(cdls, level, req, file, func, line, fmt, a...)              \
+do {                                                                          \
+        CHECK_STACK();                                                        \
+                                                                              \
+        if (((level) & D_CANTMASK) != 0 ||                                    \
+            ((libcfs_debug & (level)) != 0 &&                                 \
+             (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) {              \
+                static struct libcfs_debug_msg_data _req_dbg_data =           \
+                DEBUG_MSG_DATA_INIT(cdls, DEBUG_SUBSYSTEM, file, func, line); \
+                _debug_req((req), (level), &_req_dbg_data, fmt, ##a);         \
+        }                                                                     \
 } while(0)
 
 /* for most callers (level is a constant) this is resolved at compile time */
-#define DEBUG_REQ(level, req, fmt, args...)                                    \
-do {                                                                           \
-        if ((level) & (D_ERROR | D_WARNING)) {                                 \
-                static cfs_debug_limit_state_t cdls;                           \
-                debug_req(&cdls, level, req, __FILE__, __func__, __LINE__,     \
-                          "@@@ "fmt, ## args);                                 \
-        } else                                                                 \
-                debug_req(NULL, level, req, __FILE__, __func__, __LINE__,      \
-                          "@@@ "fmt, ## args);                                 \
+#define DEBUG_REQ(level, req, fmt, args...)                                   \
+do {                                                                          \
+        if ((level) & (D_ERROR | D_WARNING)) {                                \
+            static cfs_debug_limit_state_t cdls;                              \
+            debug_req(&cdls, level, req, __FILE__, __func__, __LINE__,        \
+                      "@@@ "fmt" ", ## args);                                 \
+        } else                                                                \
+            debug_req(NULL, level, req, __FILE__, __func__, __LINE__,         \
+                      "@@@ "fmt" ", ## args);                                 \
 } while (0)
 
 struct ptlrpc_bulk_page {
@@ -462,10 +459,10 @@ struct ptlrpc_bulk_page {
 #define BULK_PUT_SOURCE   3
 
 struct ptlrpc_bulk_desc {
-        unsigned int bd_success:1;              /* completed successfully */
-        unsigned int bd_network_rw:1;           /* accessible to the network */
-        unsigned int bd_type:2;                 /* {put,get}{source,sink} */
-        unsigned int bd_registered:1;           /* client side */
+        unsigned long bd_success:1;              /* completed successfully */
+        unsigned long bd_network_rw:1;           /* accessible to the network */
+        unsigned long bd_type:2;                 /* {put,get}{source,sink} */
+        unsigned long bd_registered:1;           /* client side */
         spinlock_t   bd_lock;                   /* serialise with callback */
         int bd_import_generation;
         struct obd_export *bd_export;
@@ -481,7 +478,8 @@ struct ptlrpc_bulk_desc {
         __u64                  bd_last_xid;
 
         struct ptlrpc_cb_id    bd_cbid;         /* network callback info */
-        lnet_handle_md_t        bd_md_h;         /* associated MD */
+        lnet_handle_md_t       bd_md_h;         /* associated MD */
+        lnet_nid_t             bd_sender;       /* stash event::sender */
 
 #if defined(__KERNEL__)
         lnet_kiov_t             bd_iov[0];
@@ -529,13 +527,21 @@ struct ptlrpc_service {
         int              srv_n_difficult_replies; /* # 'difficult' replies */
         int              srv_n_active_reqs;     /* # reqs being served */
         cfs_duration_t   srv_rqbd_timeout;      /* timeout before re-posting reqs, in tick */
-        int              srv_watchdog_timeout;  /* soft watchdog timeout, in ms */
+        int              srv_watchdog_factor;   /* soft watchdog timeout mutiplier */
         unsigned         srv_cpu_affinity:1;    /* bind threads to CPUs */
+        unsigned         srv_at_check:1;        /* check early replies */
 
         __u32            srv_req_portal;
         __u32            srv_rep_portal;
-
-        int               srv_n_queued_reqs;    /* # reqs waiting to be served */
+        
+        /* AT stuff */
+        struct adaptive_timeout srv_at_estimate;/* estimated rpc service time */
+        spinlock_t        srv_at_lock;
+        struct list_head  srv_at_list;          /* reqs waiting for replies */
+        cfs_timer_t       srv_at_timer;         /* early reply timer */
+
+        int               srv_n_queued_reqs;    /* # reqs in either of the queues below */
+        struct list_head  srv_req_in_queue;     /* incoming reqs */
         struct list_head  srv_request_queue;    /* reqs waiting for service */
 
         struct list_head  srv_request_history;  /* request history */
@@ -607,7 +613,7 @@ struct ptlrpc_connection *ptlrpc_get_connection(lnet_process_id_t peer,
                                                 lnet_nid_t self, struct obd_uuid *uuid);
 int ptlrpc_put_connection(struct ptlrpc_connection *c);
 struct ptlrpc_connection *ptlrpc_connection_addref(struct ptlrpc_connection *);
-void ptlrpc_init_connection(void);
+int ptlrpc_init_connection(void);
 void ptlrpc_cleanup_connection(void);
 extern lnet_pid_t ptl_get_pid(void);
 
@@ -627,10 +633,13 @@ static inline int ptlrpc_bulk_active (struct ptlrpc_bulk_desc *desc)
         return (rc);
 }
 
-int ptlrpc_send_reply(struct ptlrpc_request *req, int);
+#define PTLRPC_REPLY_MAYBE_DIFFICULT 0x01
+#define PTLRPC_REPLY_EARLY           0x02
+int ptlrpc_send_reply(struct ptlrpc_request *req, int flags);
 int ptlrpc_reply(struct ptlrpc_request *req);
 int ptlrpc_error(struct ptlrpc_request *req);
 void ptlrpc_resend_req(struct ptlrpc_request *request);
+int ptlrpc_at_get_net_latency(struct ptlrpc_request *req);
 int ptl_send_rpc(struct ptlrpc_request *request, int noreply);
 int ptlrpc_register_rqbd (struct ptlrpc_request_buffer_desc *rqbd);
 
@@ -641,23 +650,12 @@ void ptlrpc_cleanup_client(struct obd_import *imp);
 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid);
 
 static inline int
-ptlrpc_client_receiving_reply (struct ptlrpc_request *req)
-{
-        int           rc;
-
-        spin_lock(&req->rq_lock);
-        rc = req->rq_receiving_reply;
-        spin_unlock(&req->rq_lock);
-        return (rc);
-}
-
-static inline int
-ptlrpc_client_replied (struct ptlrpc_request *req)
+ptlrpc_client_recv_or_unlink (struct ptlrpc_request *req)
 {
         int           rc;
 
         spin_lock(&req->rq_lock);
-        rc = req->rq_replied;
+        rc = req->rq_receiving_reply || req->rq_must_unlink;
         spin_unlock(&req->rq_lock);
         return (rc);
 }
@@ -678,6 +676,8 @@ void ptlrpc_restart_req(struct ptlrpc_request *req);
 void ptlrpc_abort_inflight(struct obd_import *imp);
 
 struct ptlrpc_request_set *ptlrpc_prep_set(void);
+int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
+                      set_interpreter_func fn, void *data);
 int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
 int ptlrpc_check_set(struct ptlrpc_request_set *set);
 int ptlrpc_set_wait(struct ptlrpc_request_set *);
@@ -693,6 +693,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool);
 void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq);
 struct ptlrpc_request_pool *ptlrpc_init_rq_pool(int, int,
                                                 void (*populate_pool)(struct ptlrpc_request_pool *, int));
+void ptlrpc_at_set_req_timeout(struct ptlrpc_request *req);
 struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, __u32 version,
                                        int opcode, int count, int *lengths,
                                        char **bufs);
@@ -725,7 +726,7 @@ void ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs);
 struct ptlrpc_service *ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size,
                                        int max_reply_size,
                                        int req_portal, int rep_portal,
-                                       int watchdog_timeout, /* in ms */
+                                       int watchdog_factor,
                                        svc_handler_t, char *name,
                                        cfs_proc_dir_entry_t *proc_entry,
                                        svcreq_printfn_t, 
@@ -753,6 +754,8 @@ int ptlrpc_connect_import(struct obd_import *imp, char * new_uuid);
 int ptlrpc_init_import(struct obd_import *imp);
 int ptlrpc_disconnect_import(struct obd_import *imp, int noclose);
 int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
+void ptlrpc_import_setasync(struct obd_import *imp, int count);
+int ptlrpc_reconnect_import(struct obd_import *imp);
 
 /* ptlrpc/pack_generic.c */
 int lustre_msg_swabbed(struct lustre_msg *msg);
@@ -761,10 +764,15 @@ int lustre_pack_request(struct ptlrpc_request *, __u32 magic, int count,
                         int *lens, char **bufs);
 int lustre_pack_reply(struct ptlrpc_request *, int count, int *lens,
                       char **bufs);
+#define LPRFL_EARLY_REPLY 1
+int lustre_pack_reply_flags(struct ptlrpc_request *, int count, int *lens,
+                            char **bufs, int flags);
 void lustre_shrink_reply(struct ptlrpc_request *req, int segment,
                          unsigned int newlen, int move_data);
 void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
 int lustre_msg_size(__u32 magic, int count, int *lengths);
+int lustre_packed_msg_size(struct lustre_msg *msg);
+int lustre_msg_early_size(void);
 int lustre_unpack_msg(struct lustre_msg *m, int len);
 void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
 int lustre_msg_buflen(struct lustre_msg *m, int n);
@@ -776,6 +784,8 @@ void *lustre_swab_reqbuf(struct ptlrpc_request *req, int n, int minlen,
                          void *swabber);
 void *lustre_swab_repbuf(struct ptlrpc_request *req, int n, int minlen,
                          void *swabber);
+__u32 lustre_msghdr_get_flags(struct lustre_msg *msg);
+void lustre_msghdr_set_flags(struct lustre_msg *msg, __u32 flags);
 __u32 lustre_msg_get_flags(struct lustre_msg *msg);
 void lustre_msg_add_flags(struct lustre_msg *msg, int flags);
 void lustre_msg_set_flags(struct lustre_msg *msg, int flags);
@@ -791,9 +801,18 @@ __u32 lustre_msg_get_opc(struct lustre_msg *msg);
 __u64 lustre_msg_get_last_xid(struct lustre_msg *msg);
 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg);
 __u64 lustre_msg_get_transno(struct lustre_msg *msg);
-__u32 lustre_msg_get_status(struct lustre_msg *msg);
+__u64 lustre_msg_get_slv(struct lustre_msg *msg);
+__u32 lustre_msg_get_limit(struct lustre_msg *msg);
+void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv);
+void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit);
+int   lustre_msg_get_status(struct lustre_msg *msg);
 __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg);
+int lustre_msg_is_v1(struct lustre_msg *msg);
 __u32 lustre_msg_get_magic(struct lustre_msg *msg);
+__u32 lustre_msg_get_timeout(struct lustre_msg *msg);
+__u32 lustre_msg_get_service_time(struct lustre_msg *msg);
+__u32 lustre_msg_get_cksum(struct lustre_msg *msg);
+__u32 lustre_msg_calc_cksum(struct lustre_msg *msg);
 void lustre_msg_set_handle(struct lustre_msg *msg,struct lustre_handle *handle);
 void lustre_msg_set_type(struct lustre_msg *msg, __u32 type);
 void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc);
@@ -802,6 +821,9 @@ void lustre_msg_set_last_committed(struct lustre_msg *msg,__u64 last_committed);
 void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno);
 void lustre_msg_set_status(struct lustre_msg *msg, __u32 status);
 void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt);
+void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout);
+void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time);
+void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum);
 
 static inline void
 ptlrpc_rs_addref(struct ptlrpc_reply_state *rs)
@@ -818,6 +840,16 @@ ptlrpc_rs_decref(struct ptlrpc_reply_state *rs)
                 lustre_free_reply_state(rs);
 }
 
+/* Should only be called once per req */
+static inline void ptlrpc_req_drop_rs(struct ptlrpc_request *req)
+{
+        if (req->rq_reply_state == NULL) 
+                return; /* shouldn't occur */
+        ptlrpc_rs_decref(req->rq_reply_state);
+        req->rq_reply_state = NULL;
+        req->rq_repmsg = NULL;
+}
+
 static inline __u32 lustre_request_magic(struct ptlrpc_request *req)
 {
         return lustre_msg_get_magic(req->rq_reqmsg);
@@ -841,16 +873,19 @@ static inline int ptlrpc_req_get_repsize(struct ptlrpc_request *req)
 static inline void
 ptlrpc_req_set_repsize(struct ptlrpc_request *req, int count, int *lens)
 {
-        req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens);
+        int size = lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens);
+        
+        req->rq_replen = size + lustre_msg_early_size();
         if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
-                req->rq_reqmsg->lm_repsize = req->rq_replen;
+                req->rq_reqmsg->lm_repsize = size;
 }
 
 /* ldlm/ldlm_lib.c */
 int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf);
 int client_obd_cleanup(struct obd_device * obddev);
 int client_connect_import(struct lustre_handle *conn, struct obd_device *obd,
-                          struct obd_uuid *cluuid, struct obd_connect_data *);
+                          struct obd_uuid *cluuid, struct obd_connect_data *,
+                          void *localdata);
 int client_disconnect_export(struct obd_export *exp);
 int client_import_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
                            int priority);
@@ -875,6 +910,7 @@ int ptlrpcd_addref(void);
 void ptlrpcd_decref(void);
 
 /* ptlrpc/lproc_ptlrpc.c */
+const char* ll_opcode2str(__u32 opcode);
 #ifdef LPROCFS
 void ptlrpc_lprocfs_register_obd(struct obd_device *obd);
 void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd);