Whamcloud - gitweb
LU-1214 ptlrpc: splits server-side connection/bulkIO/recovery
authorLiu Xuezhao <xuezhao.liu@emc.com>
Sun, 18 Mar 2012 12:56:07 +0000 (20:56 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 30 Apr 2012 01:33:20 +0000 (21:33 -0400)
Splits/removes these server-side handling from client:
1. Server-side connection and disconnection
2. Splits obdecho client and server
3. Server-side bulk I/O
4. Server-side recovery handling

Uses "HAVE_SERVER_SUPPORT" to protect those server-side codes.

Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
Change-Id: I14422a36ffa6fa46604682c9eed6d27dd56a4888
Reviewed-on: http://review.whamcloud.com/2360
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
16 files changed:
lustre/include/lustre_lib.h
lustre/include/lustre_net.h
lustre/include/lustre_sec.h
lustre/ldlm/ldlm_lib.c
lustre/ldlm/ldlm_lockd.c
lustre/obdecho/Makefile.in
lustre/obdecho/autoMakefile.am
lustre/obdecho/echo.c
lustre/obdecho/echo_client.c
lustre/obdecho/echo_internal.h
lustre/ptlrpc/client.c
lustre/ptlrpc/events.c
lustre/ptlrpc/niobuf.c
lustre/ptlrpc/ptlrpc_internal.h
lustre/ptlrpc/ptlrpc_module.c
lustre/ptlrpc/sec.c

index 6f4cf15..276a24a 100644 (file)
 struct ptlrpc_request;
 struct obd_export;
 struct lu_target;
 struct ptlrpc_request;
 struct obd_export;
 struct lu_target;
+struct l_wait_info;
 #include <lustre_ha.h>
 #include <lustre_net.h>
 #include <lvfs.h>
 
 #include <lustre_ha.h>
 #include <lustre_net.h>
 #include <lvfs.h>
 
+#ifdef HAVE_SERVER_SUPPORT
 void target_client_add_cb(struct obd_device *obd, __u64 transno, void *cb_data,
                           int error);
 int target_handle_connect(struct ptlrpc_request *req);
 int target_handle_disconnect(struct ptlrpc_request *req);
 void target_destroy_export(struct obd_export *exp);
 void target_client_add_cb(struct obd_device *obd, __u64 transno, void *cb_data,
                           int error);
 int target_handle_connect(struct ptlrpc_request *req);
 int target_handle_disconnect(struct ptlrpc_request *req);
 void target_destroy_export(struct obd_export *exp);
-int target_pack_pool_reply(struct ptlrpc_request *req);
 int target_handle_ping(struct ptlrpc_request *req);
 void target_committed_to_req(struct ptlrpc_request *req);
 int target_handle_ping(struct ptlrpc_request *req);
 void target_committed_to_req(struct ptlrpc_request *req);
+void target_cancel_recovery_timer(struct obd_device *obd);
+void target_stop_recovery_thread(struct obd_device *obd);
+void target_cleanup_recovery(struct obd_device *obd);
+int target_queue_recovery_request(struct ptlrpc_request *req,
+                                  struct obd_device *obd);
+int target_bulk_io(struct obd_export *exp, struct ptlrpc_bulk_desc *desc,
+                   struct l_wait_info *lwi);
+#endif
+
+int target_pack_pool_reply(struct ptlrpc_request *req);
 int do_set_info_async(struct obd_import *imp,
                       int opcode, int version,
                       obd_count keylen, void *key,
 int do_set_info_async(struct obd_import *imp,
                       int opcode, int version,
                       obd_count keylen, void *key,
@@ -94,16 +105,7 @@ int target_handle_dqacq_callback(struct ptlrpc_request *req);
 
 #define OBD_RECOVERY_MAX_TIME (obd_timeout * 18) /* b13079 */
 
 
 #define OBD_RECOVERY_MAX_TIME (obd_timeout * 18) /* b13079 */
 
-struct l_wait_info;
-
-void target_cancel_recovery_timer(struct obd_device *obd);
-void target_stop_recovery_thread(struct obd_device *obd);
-void target_cleanup_recovery(struct obd_device *obd);
-int target_queue_recovery_request(struct ptlrpc_request *req,
-                                  struct obd_device *obd);
 void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id);
 void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id);
-int target_bulk_io(struct obd_export *exp, struct ptlrpc_bulk_desc *desc,
-                   struct l_wait_info *lwi);
 
 /* client.c */
 
 
 /* client.c */
 
index d22d556..682a977 100644 (file)
@@ -1373,12 +1373,14 @@ extern int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
  * underlying buffer
  * @{
  */
  * underlying buffer
  * @{
  */
-extern void request_out_callback (lnet_event_t *ev);
+extern void request_out_callback(lnet_event_t *ev);
 extern void reply_in_callback(lnet_event_t *ev);
 extern void reply_in_callback(lnet_event_t *ev);
-extern void client_bulk_callback (lnet_event_t *ev);
+extern void client_bulk_callback(lnet_event_t *ev);
 extern void request_in_callback(lnet_event_t *ev);
 extern void reply_out_callback(lnet_event_t *ev);
 extern void request_in_callback(lnet_event_t *ev);
 extern void reply_out_callback(lnet_event_t *ev);
-extern void server_bulk_callback (lnet_event_t *ev);
+#ifdef HAVE_SERVER_SUPPORT
+extern void server_bulk_callback(lnet_event_t *ev);
+#endif
 /** @} */
 
 /* ptlrpc/connection.c */
 /** @} */
 
 /* ptlrpc/connection.c */
@@ -1396,10 +1398,11 @@ extern lnet_pid_t ptl_get_pid(void);
  * Actual interfacing with LNet to put/get/register/unregister stuff
  * @{
  */
  * Actual interfacing with LNet to put/get/register/unregister stuff
  * @{
  */
+#ifdef HAVE_SERVER_SUPPORT
+struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
+                                              int npages, int type, int portal);
 int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc);
 void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc);
 int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc);
 void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc);
-int ptlrpc_register_bulk(struct ptlrpc_request *req);
-int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async);
 
 static inline int ptlrpc_server_bulk_active(struct ptlrpc_bulk_desc *desc)
 {
 
 static inline int ptlrpc_server_bulk_active(struct ptlrpc_bulk_desc *desc)
 {
@@ -1412,6 +1415,10 @@ static inline int ptlrpc_server_bulk_active(struct ptlrpc_bulk_desc *desc)
         cfs_spin_unlock(&desc->bd_lock);
         return rc;
 }
         cfs_spin_unlock(&desc->bd_lock);
         return rc;
 }
+#endif
+
+int ptlrpc_register_bulk(struct ptlrpc_request *req);
+int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async);
 
 static inline int ptlrpc_client_bulk_active(struct ptlrpc_request *req)
 {
 
 static inline int ptlrpc_client_bulk_active(struct ptlrpc_request *req)
 {
@@ -1442,7 +1449,7 @@ 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);
 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);
+int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd);
 /** @} */
 
 /* ptlrpc/client.c */
 /** @} */
 
 /* ptlrpc/client.c */
@@ -1515,9 +1522,7 @@ struct ptlrpc_request *ptlrpc_prep_req_pool(struct obd_import *imp,
 void ptlrpc_req_finished(struct ptlrpc_request *request);
 void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request);
 struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req);
 void ptlrpc_req_finished(struct ptlrpc_request *request);
 void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request);
 struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req);
-struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp (struct ptlrpc_request *req,
-                                               int npages, int type, int portal);
-struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
+struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req,
                                               int npages, int type, int portal);
 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
 void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
                                               int npages, int type, int portal);
 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
 void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
@@ -1556,11 +1561,11 @@ struct ptlrpc_service_conf {
  *
  * @{
  */
  *
  * @{
  */
-void ptlrpc_save_lock (struct ptlrpc_request *req,
-                       struct lustre_handle *lock, int mode, int no_ack);
+void ptlrpc_save_lock(struct ptlrpc_request *req,
+                      struct lustre_handle *lock, int mode, int no_ack);
 void ptlrpc_commit_replies(struct obd_export *exp);
 void ptlrpc_commit_replies(struct obd_export *exp);
-void ptlrpc_dispatch_difficult_reply (struct ptlrpc_reply_state *rs);
-void ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs);
+void ptlrpc_dispatch_difficult_reply(struct ptlrpc_reply_state *rs);
+void ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs);
 struct ptlrpc_service *ptlrpc_init_svc_conf(struct ptlrpc_service_conf *c,
                                             svc_handler_t h, char *name,
                                             struct proc_dir_entry *proc_entry,
 struct ptlrpc_service *ptlrpc_init_svc_conf(struct ptlrpc_service_conf *c,
                                             svc_handler_t h, char *name,
                                             struct proc_dir_entry *proc_entry,
@@ -1582,7 +1587,7 @@ void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
 int ptlrpc_start_threads(struct ptlrpc_service *svc);
 int ptlrpc_start_thread(struct ptlrpc_service *svc);
 int ptlrpc_unregister_service(struct ptlrpc_service *service);
 int ptlrpc_start_threads(struct ptlrpc_service *svc);
 int ptlrpc_start_thread(struct ptlrpc_service *svc);
 int ptlrpc_unregister_service(struct ptlrpc_service *service);
-int liblustre_check_services (void *arg);
+int liblustre_check_services(void *arg);
 void ptlrpc_daemonize(char *name);
 int ptlrpc_service_health_check(struct ptlrpc_service *);
 void ptlrpc_hpreq_reorder(struct ptlrpc_request *req);
 void ptlrpc_daemonize(char *name);
 int ptlrpc_service_health_check(struct ptlrpc_service *);
 void ptlrpc_hpreq_reorder(struct ptlrpc_request *req);
@@ -1657,7 +1662,7 @@ void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
 int lustre_msg_buflen(struct lustre_msg *m, int n);
 void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len);
 int lustre_msg_bufcount(struct lustre_msg *m);
 int lustre_msg_buflen(struct lustre_msg *m, int n);
 void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len);
 int lustre_msg_bufcount(struct lustre_msg *m);
-char *lustre_msg_string (struct lustre_msg *m, int n, int max_len);
+char *lustre_msg_string(struct lustre_msg *m, int n, int max_len);
 __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);
 __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);
@@ -1886,7 +1891,9 @@ int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid);
 void client_destroy_import(struct obd_import *imp);
 /** @} */
 
 void client_destroy_import(struct obd_import *imp);
 /** @} */
 
+#ifdef HAVE_SERVER_SUPPORT
 int server_disconnect_export(struct obd_export *exp);
 int server_disconnect_export(struct obd_export *exp);
+#endif
 
 /* ptlrpc/pinger.c */
 /**
 
 /* ptlrpc/pinger.c */
 /**
index 6a0da67..2d56780 100644 (file)
@@ -1119,12 +1119,14 @@ int sptlrpc_cli_unwrap_bulk_read(struct ptlrpc_request *req,
                                  int nob);
 int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req,
                                   struct ptlrpc_bulk_desc *desc);
                                  int nob);
 int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req,
                                   struct ptlrpc_bulk_desc *desc);
+#ifdef HAVE_SERVER_SUPPORT
 int sptlrpc_svc_prep_bulk(struct ptlrpc_request *req,
                           struct ptlrpc_bulk_desc *desc);
 int sptlrpc_svc_wrap_bulk(struct ptlrpc_request *req,
                           struct ptlrpc_bulk_desc *desc);
 int sptlrpc_svc_unwrap_bulk(struct ptlrpc_request *req,
                             struct ptlrpc_bulk_desc *desc);
 int sptlrpc_svc_prep_bulk(struct ptlrpc_request *req,
                           struct ptlrpc_bulk_desc *desc);
 int sptlrpc_svc_wrap_bulk(struct ptlrpc_request *req,
                           struct ptlrpc_bulk_desc *desc);
 int sptlrpc_svc_unwrap_bulk(struct ptlrpc_request *req,
                             struct ptlrpc_bulk_desc *desc);
+#endif
 
 /* bulk helpers (internal use only by policies) */
 int sptlrpc_get_bulk_checksum(struct ptlrpc_bulk_desc *desc, __u8 alg,
 
 /* bulk helpers (internal use only by policies) */
 int sptlrpc_get_bulk_checksum(struct ptlrpc_bulk_desc *desc, __u8 alg,
index ededfd0..3acbdd7 100644 (file)
@@ -577,6 +577,7 @@ int client_disconnect_export(struct obd_export *exp)
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
+#ifdef HAVE_SERVER_SUPPORT
 int server_disconnect_export(struct obd_export *exp)
 {
         int rc;
 int server_disconnect_export(struct obd_export *exp)
 {
         int rc;
@@ -2069,7 +2070,7 @@ void target_recovery_init(struct lu_target *lut, svc_handler_t handler)
 }
 EXPORT_SYMBOL(target_recovery_init);
 
 }
 EXPORT_SYMBOL(target_recovery_init);
 
-#endif
+#endif /* __KERNEL__ */
 
 static int target_process_req_flags(struct obd_device *obd,
                                     struct ptlrpc_request *req)
 
 static int target_process_req_flags(struct obd_device *obd,
                                     struct ptlrpc_request *req)
@@ -2238,6 +2239,31 @@ int target_queue_recovery_request(struct ptlrpc_request *req,
         RETURN(0);
 }
 
         RETURN(0);
 }
 
+int target_handle_ping(struct ptlrpc_request *req)
+{
+        obd_ping(req->rq_export);
+        return req_capsule_server_pack(&req->rq_pill);
+}
+
+void target_committed_to_req(struct ptlrpc_request *req)
+{
+        struct obd_export *exp = req->rq_export;
+
+        if (!exp->exp_obd->obd_no_transno && req->rq_repmsg != NULL)
+                lustre_msg_set_last_committed(req->rq_repmsg,
+                                              exp->exp_last_committed);
+        else
+                DEBUG_REQ(D_IOCTL, req, "not sending last_committed update (%d/"
+                          "%d)", exp->exp_obd->obd_no_transno,
+                          req->rq_repmsg == NULL);
+
+        CDEBUG(D_INFO, "last_committed "LPU64", transno "LPU64", xid "LPU64"\n",
+               exp->exp_last_committed, req->rq_transno, req->rq_xid);
+}
+EXPORT_SYMBOL(target_committed_to_req);
+
+#endif /* HAVE_SERVER_SUPPORT */
+
 /**
  * Packs current SLV and Limit into \a req.
  */
 /**
  * Packs current SLV and Limit into \a req.
  */
@@ -2380,29 +2406,6 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id)
         EXIT;
 }
 
         EXIT;
 }
 
-int target_handle_ping(struct ptlrpc_request *req)
-{
-        obd_ping(req->rq_export);
-        return req_capsule_server_pack(&req->rq_pill);
-}
-
-void target_committed_to_req(struct ptlrpc_request *req)
-{
-        struct obd_export *exp = req->rq_export;
-
-        if (!exp->exp_obd->obd_no_transno && req->rq_repmsg != NULL)
-                lustre_msg_set_last_committed(req->rq_repmsg,
-                                              exp->exp_last_committed);
-        else
-                DEBUG_REQ(D_IOCTL, req, "not sending last_committed update (%d/"
-                          "%d)", exp->exp_obd->obd_no_transno,
-                          req->rq_repmsg == NULL);
-
-        CDEBUG(D_INFO, "last_committed "LPU64", transno "LPU64", xid "LPU64"\n",
-               exp->exp_last_committed, req->rq_transno, req->rq_xid);
-}
-EXPORT_SYMBOL(target_committed_to_req);
-
 int target_handle_qc_callback(struct ptlrpc_request *req)
 {
         struct obd_quotactl *oqctl;
 int target_handle_qc_callback(struct ptlrpc_request *req)
 {
         struct obd_quotactl *oqctl;
@@ -2621,6 +2624,7 @@ void ldlm_dump_export_locks(struct obd_export *exp)
 }
 #endif
 
 }
 #endif
 
+#ifdef HAVE_SERVER_SUPPORT
 static int target_bulk_timeout(void *data)
 {
         ENTRY;
 static int target_bulk_timeout(void *data)
 {
         ENTRY;
@@ -2724,3 +2728,5 @@ int target_bulk_io(struct obd_export *exp, struct ptlrpc_bulk_desc *desc,
         RETURN(rc);
 }
 EXPORT_SYMBOL(target_bulk_io);
         RETURN(rc);
 }
 EXPORT_SYMBOL(target_bulk_io);
+
+#endif /* HAVE_SERVER_SUPPORT */
index 34cbf16..f32054b 100644 (file)
@@ -2859,17 +2859,20 @@ EXPORT_SYMBOL(client_obd_setup);
 EXPORT_SYMBOL(client_obd_cleanup);
 EXPORT_SYMBOL(client_connect_import);
 EXPORT_SYMBOL(client_disconnect_export);
 EXPORT_SYMBOL(client_obd_cleanup);
 EXPORT_SYMBOL(client_connect_import);
 EXPORT_SYMBOL(client_disconnect_export);
+EXPORT_SYMBOL(target_send_reply);
+EXPORT_SYMBOL(target_pack_pool_reply);
+
+#ifdef HAVE_SERVER_SUPPORT
 EXPORT_SYMBOL(server_disconnect_export);
 EXPORT_SYMBOL(target_stop_recovery_thread);
 EXPORT_SYMBOL(target_handle_connect);
 EXPORT_SYMBOL(target_cleanup_recovery);
 EXPORT_SYMBOL(target_destroy_export);
 EXPORT_SYMBOL(target_cancel_recovery_timer);
 EXPORT_SYMBOL(server_disconnect_export);
 EXPORT_SYMBOL(target_stop_recovery_thread);
 EXPORT_SYMBOL(target_handle_connect);
 EXPORT_SYMBOL(target_cleanup_recovery);
 EXPORT_SYMBOL(target_destroy_export);
 EXPORT_SYMBOL(target_cancel_recovery_timer);
-EXPORT_SYMBOL(target_send_reply);
 EXPORT_SYMBOL(target_queue_recovery_request);
 EXPORT_SYMBOL(target_handle_ping);
 EXPORT_SYMBOL(target_queue_recovery_request);
 EXPORT_SYMBOL(target_handle_ping);
-EXPORT_SYMBOL(target_pack_pool_reply);
 EXPORT_SYMBOL(target_handle_disconnect);
 EXPORT_SYMBOL(target_handle_disconnect);
+#endif
 
 /* l_lock.c */
 EXPORT_SYMBOL(lock_res_and_lock);
 
 /* l_lock.c */
 EXPORT_SYMBOL(lock_res_and_lock);
index c9069e5..0cea034 100644 (file)
@@ -1,5 +1,6 @@
 MODULES := obdecho
 MODULES := obdecho
-obdecho-objs := echo.o echo_client.o lproc_echo.o
+obdecho-objs := echo_client.o lproc_echo.o
+@SERVER_TRUE@obdecho-objs += echo.o
 
 EXTRA_DIST = $(obdecho-objs:%.o=%.c) echo_internal.h
 
 
 EXTRA_DIST = $(obdecho-objs:%.o=%.c) echo_internal.h
 
index 1b6409f..34d4244 100644 (file)
@@ -50,9 +50,12 @@ if DARWIN
 macos_PROGRAMS := obdecho
 obdecho_SOURCES := \
         lproc_echo.c \
 macos_PROGRAMS := obdecho
 obdecho_SOURCES := \
         lproc_echo.c \
-        echo.c \
         echo_client.c
 
         echo_client.c
 
+if SERVER
+obdecho_SOURCES += echo.c
+endif
+
 obdecho_CFLAGS := $(EXTRA_KCFLAGS)
 obdecho_LDFLAGS := $(EXTRA_KLDFLAGS)
 obdecho_LDADD := $(EXTRA_KLIBS)
 obdecho_CFLAGS := $(EXTRA_KCFLAGS)
 obdecho_LDFLAGS := $(EXTRA_KLDFLAGS)
 obdecho_LDADD := $(EXTRA_KLIBS)
index 839b936..add59d4 100644 (file)
@@ -121,8 +121,8 @@ static int echo_destroy_export(struct obd_export *exp)
         return id;
 }
 
         return id;
 }
 
-int echo_create(struct obd_export *exp, struct obdo *oa,
-                struct lov_stripe_md **ea, struct obd_trans_info *oti)
+static int echo_create(struct obd_export *exp, struct obdo *oa,
+                       struct lov_stripe_md **ea, struct obd_trans_info *oti)
 {
         struct obd_device *obd = class_exp2obd(exp);
 
 {
         struct obd_device *obd = class_exp2obd(exp);
 
@@ -148,9 +148,9 @@ int echo_create(struct obd_export *exp, struct obdo *oa,
         return 0;
 }
 
         return 0;
 }
 
-int echo_destroy(struct obd_export *exp, struct obdo *oa,
-                 struct lov_stripe_md *ea, struct obd_trans_info *oti,
-                 struct obd_export *md_exp, void *capa)
+static int echo_destroy(struct obd_export *exp, struct obdo *oa,
+                        struct lov_stripe_md *ea, struct obd_trans_info *oti,
+                        struct obd_export *md_exp, void *capa)
 {
         struct obd_device *obd = class_exp2obd(exp);
 
 {
         struct obd_device *obd = class_exp2obd(exp);
 
@@ -392,10 +392,11 @@ static int echo_finalize_lb(struct obdo *oa, struct obd_ioobj *obj,
         return rc;
 }
 
         return rc;
 }
 
-int echo_preprw(int cmd, struct obd_export *export, struct obdo *oa,
-                int objcount, struct obd_ioobj *obj, struct niobuf_remote *nb,
-                int *pages, struct niobuf_local *res,
-                struct obd_trans_info *oti, struct lustre_capa *unused)
+static int echo_preprw(int cmd, struct obd_export *export, struct obdo *oa,
+                       int objcount, struct obd_ioobj *obj,
+                       struct niobuf_remote *nb, int *pages,
+                       struct niobuf_local *res, struct obd_trans_info *oti,
+                       struct lustre_capa *unused)
 {
         struct obd_device *obd;
         int tot_bytes = 0;
 {
         struct obd_device *obd;
         int tot_bytes = 0;
@@ -468,10 +469,11 @@ preprw_cleanup:
         return rc;
 }
 
         return rc;
 }
 
-int echo_commitrw(int cmd, struct obd_export *export, struct obdo *oa,
-                  int objcount, struct obd_ioobj *obj,
-                  struct niobuf_remote *rb, int niocount,
-                  struct niobuf_local *res, struct obd_trans_info *oti, int rc)
+static int echo_commitrw(int cmd, struct obd_export *export, struct obdo *oa,
+                         int objcount, struct obd_ioobj *obj,
+                         struct niobuf_remote *rb, int niocount,
+                         struct niobuf_local *res, struct obd_trans_info *oti,
+                         int rc)
 {
         struct obd_device *obd;
         int pgs = 0;
 {
         struct obd_device *obd;
         int pgs = 0;
@@ -616,7 +618,7 @@ static int echo_cleanup(struct obd_device *obd)
         RETURN(0);
 }
 
         RETURN(0);
 }
 
-static struct obd_ops echo_obd_ops = {
+struct obd_ops echo_obd_ops = {
         .o_owner           = THIS_MODULE,
         .o_connect         = echo_connect,
         .o_disconnect      = echo_disconnect,
         .o_owner           = THIS_MODULE,
         .o_connect         = echo_connect,
         .o_disconnect      = echo_disconnect,
@@ -632,11 +634,7 @@ static struct obd_ops echo_obd_ops = {
         .o_cleanup         = echo_cleanup
 };
 
         .o_cleanup         = echo_cleanup
 };
 
-extern int echo_client_init(void);
-extern void echo_client_exit(void);
-
-static void
-echo_persistent_pages_fini (void)
+void echo_persistent_pages_fini(void)
 {
         int     i;
 
 {
         int     i;
 
@@ -647,8 +645,7 @@ echo_persistent_pages_fini (void)
                 }
 }
 
                 }
 }
 
-static int
-echo_persistent_pages_init (void)
+int echo_persistent_pages_init(void)
 {
         cfs_page_t *pg;
         int          i;
 {
         cfs_page_t *pg;
         int          i;
@@ -671,48 +668,3 @@ echo_persistent_pages_init (void)
 
         return (0);
 }
 
         return (0);
 }
-
-static int __init obdecho_init(void)
-{
-        struct lprocfs_static_vars lvars;
-        int rc;
-
-        ENTRY;
-        LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n");
-
-        LASSERT(CFS_PAGE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
-
-        lprocfs_echo_init_vars(&lvars);
-
-        rc = echo_persistent_pages_init ();
-        if (rc != 0)
-                goto failed_0;
-
-        rc = class_register_type(&echo_obd_ops, NULL, lvars.module_vars,
-                                 LUSTRE_ECHO_NAME, NULL);
-        if (rc != 0)
-                goto failed_1;
-
-        rc = echo_client_init();
-        if (rc == 0)
-                RETURN (0);
-
-        class_unregister_type(LUSTRE_ECHO_NAME);
- failed_1:
-        echo_persistent_pages_fini ();
- failed_0:
-        RETURN(rc);
-}
-
-static void /*__exit*/ obdecho_exit(void)
-{
-        echo_client_exit();
-        class_unregister_type(LUSTRE_ECHO_NAME);
-        echo_persistent_pages_fini ();
-}
-
-MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
-MODULE_DESCRIPTION("Lustre Testing Echo OBD driver");
-MODULE_LICENSE("GPL");
-
-cfs_module(obdecho, "1.0.0", obdecho_init, obdecho_exit);
index cef8317..93abba4 100644 (file)
@@ -270,8 +270,8 @@ static struct lu_kmem_descr echo_caches[] = {
  *
  * @{
  */
  *
  * @{
  */
-cfs_page_t *echo_page_vmpage(const struct lu_env *env,
-                             const struct cl_page_slice *slice)
+static cfs_page_t *echo_page_vmpage(const struct lu_env *env,
+                                    const struct cl_page_slice *slice)
 {
         return cl2echo_page(slice)->ep_vmpage;
 }
 {
         return cl2echo_page(slice)->ep_vmpage;
 }
@@ -1884,9 +1884,9 @@ out_free:
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-struct lu_object *echo_resolve_path(const struct lu_env *env,
-                                    struct echo_device *ed, char *path,
-                                    int path_len)
+static struct lu_object *echo_resolve_path(const struct lu_env *env,
+                                           struct echo_device *ed, char *path,
+                                           int path_len)
 {
         struct lu_device        *ld = ed->ed_next;
         struct md_device        *md = lu2md_dev(ld);
 {
         struct lu_device        *ld = ed->ed_next;
         struct md_device        *md = lu2md_dev(ld);
@@ -2954,7 +2954,7 @@ static int echo_client_disconnect(struct obd_export *exp)
         return rc;
 }
 
         return rc;
 }
 
-static struct obd_ops echo_obd_ops = {
+static struct obd_ops echo_client_obd_ops = {
         .o_owner       = THIS_MODULE,
 
 #if 0
         .o_owner       = THIS_MODULE,
 
 #if 0
@@ -2976,7 +2976,7 @@ int echo_client_init(void)
 
         rc = lu_kmem_init(echo_caches);
         if (rc == 0) {
 
         rc = lu_kmem_init(echo_caches);
         if (rc == 0) {
-                rc = class_register_type(&echo_obd_ops, NULL,
+                rc = class_register_type(&echo_client_obd_ops, NULL,
                                          lvars.module_vars,
                                          LUSTRE_ECHO_CLIENT_NAME,
                                          &echo_device_type);
                                          lvars.module_vars,
                                          LUSTRE_ECHO_CLIENT_NAME,
                                          &echo_device_type);
@@ -2992,4 +2992,59 @@ void echo_client_exit(void)
         lu_kmem_fini(echo_caches);
 }
 
         lu_kmem_fini(echo_caches);
 }
 
+#ifdef __KERNEL__
+static int __init obdecho_init(void)
+{
+        struct lprocfs_static_vars lvars;
+        int rc;
+
+        ENTRY;
+        LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n");
+
+        LASSERT(CFS_PAGE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
+
+        lprocfs_echo_init_vars(&lvars);
+
+# ifdef HAVE_SERVER_SUPPORT
+        rc = echo_persistent_pages_init();
+        if (rc != 0)
+                goto failed_0;
+
+        rc = class_register_type(&echo_obd_ops, NULL, lvars.module_vars,
+                                 LUSTRE_ECHO_NAME, NULL);
+        if (rc != 0)
+                goto failed_1;
+# endif
+
+        rc = echo_client_init();
+
+# ifdef HAVE_SERVER_SUPPORT
+        if (rc == 0)
+                RETURN(0);
+
+        class_unregister_type(LUSTRE_ECHO_NAME);
+failed_1:
+        echo_persistent_pages_fini();
+failed_0:
+# endif
+        RETURN(rc);
+}
+
+static void /*__exit*/ obdecho_exit(void)
+{
+        echo_client_exit();
+
+# ifdef HAVE_SERVER_SUPPORT
+        class_unregister_type(LUSTRE_ECHO_NAME);
+        echo_persistent_pages_fini();
+# endif
+}
+
+MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
+MODULE_DESCRIPTION("Lustre Testing Echo OBD driver");
+MODULE_LICENSE("GPL");
+
+cfs_module(obdecho, LUSTRE_VERSION_STRING, obdecho_init, obdecho_exit);
+#endif /* __KERNEL__ */
+
 /** @} echo_client */
 /** @} echo_client */
index c45f0c6..df365a2 100644 (file)
 /* block size to use for data verification */
 #define OBD_ECHO_BLOCK_SIZE    (4<<10)
 
 /* block size to use for data verification */
 #define OBD_ECHO_BLOCK_SIZE    (4<<10)
 
-#ifndef __KERNEL__
+#ifdef __KERNEL__
+# ifdef HAVE_SERVER_SUPPORT
+extern struct obd_ops echo_obd_ops;
+int echo_persistent_pages_init(void);
+void echo_persistent_pages_fini(void);
+# endif
+#else /* ! __KERNEL__ */
 /* Kludge here, define some functions and macros needed by liblustre -jay */
 static inline void page_cache_get(struct page *page)
 {
 /* Kludge here, define some functions and macros needed by liblustre -jay */
 static inline void page_cache_get(struct page *page)
 {
@@ -25,6 +31,6 @@ static inline void page_cache_release(struct page *page)
 #define READ    0
 #define WRITE   1
 
 #define READ    0
 #define WRITE   1
 
-#endif /* ifndef __KERNEL__ */
+#endif /* ifdef __KERNEL__ */
 
 #endif
 
 #endif
index 85db559..2e1d161 100644 (file)
@@ -96,7 +96,7 @@ struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid)
  * Allocate and initialize new bulk descriptor
  * Returns pointer to the descriptor or NULL on error.
  */
  * Allocate and initialize new bulk descriptor
  * Returns pointer to the descriptor or NULL on error.
  */
-static inline struct ptlrpc_bulk_desc *new_bulk(int npages, int type, int portal)
+struct ptlrpc_bulk_desc *new_bulk(int npages, int type, int portal)
 {
         struct ptlrpc_bulk_desc *desc;
 
 {
         struct ptlrpc_bulk_desc *desc;
 
@@ -148,39 +148,6 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req,
 }
 
 /**
 }
 
 /**
- * Prepare bulk descriptor for specified incoming request \a req that
- * can fit \a npages * pages. \a type is bulk type. \a portal is where
- * the bulk to be sent. Used on server-side after request was already
- * received.
- * Returns pointer to newly allocatrd initialized bulk descriptor or NULL on
- * error.
- */
-struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
-                                              int npages, int type, int portal)
-{
-        struct obd_export *exp = req->rq_export;
-        struct ptlrpc_bulk_desc *desc;
-
-        ENTRY;
-        LASSERT(type == BULK_PUT_SOURCE || type == BULK_GET_SINK);
-
-        desc = new_bulk(npages, type, portal);
-        if (desc == NULL)
-                RETURN(NULL);
-
-        desc->bd_export = class_export_get(exp);
-        desc->bd_req = req;
-
-        desc->bd_cbid.cbid_fn  = server_bulk_callback;
-        desc->bd_cbid.cbid_arg = desc;
-
-        /* NB we don't assign rq_bulk here; server-side requests are
-         * re-used, and the handler frees the bulk desc explicitly. */
-
-        return desc;
-}
-
-/**
  * Add a page \a page to the bulk descriptor \a desc.
  * Data to transfer in the page starts at offset \a pageoffset and
  * amount of data to transfer from the page is \a len
  * Add a page \a page to the bulk descriptor \a desc.
  * Data to transfer in the page starts at offset \a pageoffset and
  * amount of data to transfer from the page is \a len
index 6cb8e8e..234bf3f 100644 (file)
@@ -367,6 +367,7 @@ void reply_out_callback(lnet_event_t *ev)
         EXIT;
 }
 
         EXIT;
 }
 
+#ifdef HAVE_SERVER_SUPPORT
 /*
  * Server's bulk completion callback
  */
 /*
  * Server's bulk completion callback
  */
@@ -409,6 +410,7 @@ void server_bulk_callback (lnet_event_t *ev)
         cfs_spin_unlock(&desc->bd_lock);
         EXIT;
 }
         cfs_spin_unlock(&desc->bd_lock);
         EXIT;
 }
+#endif
 
 static void ptlrpc_master_callback(lnet_event_t *ev)
 {
 
 static void ptlrpc_master_callback(lnet_event_t *ev)
 {
@@ -421,8 +423,11 @@ static void ptlrpc_master_callback(lnet_event_t *ev)
                  callback == reply_in_callback ||
                  callback == client_bulk_callback ||
                  callback == request_in_callback ||
                  callback == reply_in_callback ||
                  callback == client_bulk_callback ||
                  callback == request_in_callback ||
-                 callback == reply_out_callback ||
-                 callback == server_bulk_callback);
+                 callback == reply_out_callback
+#ifdef HAVE_SERVER_SUPPORT
+                 || callback == server_bulk_callback
+#endif
+                 );
 
         callback (ev);
 }
 
         callback (ev);
 }
index 240b226..65bc9bd 100644 (file)
@@ -42,6 +42,7 @@
 #include <lustre_net.h>
 #include <lustre_lib.h>
 #include <obd.h>
 #include <lustre_net.h>
 #include <lustre_lib.h>
 #include <obd.h>
+#include <obd_class.h>
 #include "ptlrpc_internal.h"
 
 /**
 #include "ptlrpc_internal.h"
 
 /**
@@ -100,6 +101,40 @@ static int ptl_send_buf (lnet_handle_md_t *mdh, void *base, int len,
         RETURN (0);
 }
 
         RETURN (0);
 }
 
+#ifdef HAVE_SERVER_SUPPORT
+/**
+ * Prepare bulk descriptor for specified incoming request \a req that
+ * can fit \a npages * pages. \a type is bulk type. \a portal is where
+ * the bulk to be sent. Used on server-side after request was already
+ * received.
+ * Returns pointer to newly allocatrd initialized bulk descriptor or NULL on
+ * error.
+ */
+struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp(struct ptlrpc_request *req,
+                                              int npages, int type, int portal)
+{
+        struct obd_export *exp = req->rq_export;
+        struct ptlrpc_bulk_desc *desc;
+
+        ENTRY;
+        LASSERT(type == BULK_PUT_SOURCE || type == BULK_GET_SINK);
+
+        desc = new_bulk(npages, type, portal);
+        if (desc == NULL)
+                RETURN(NULL);
+
+        desc->bd_export = class_export_get(exp);
+        desc->bd_req = req;
+
+        desc->bd_cbid.cbid_fn  = server_bulk_callback;
+        desc->bd_cbid.cbid_arg = desc;
+
+        /* NB we don't assign rq_bulk here; server-side requests are
+         * re-used, and the handler frees the bulk desc explicitly. */
+
+        return desc;
+}
+
 /**
  * Starts bulk transfer for descriptor \a desc
  * Returns 0 on success or error code.
 /**
  * Starts bulk transfer for descriptor \a desc
  * Returns 0 on success or error code.
@@ -211,6 +246,7 @@ void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc)
                 CWARN("Unexpectedly long timeout: desc %p\n", desc);
         }
 }
                 CWARN("Unexpectedly long timeout: desc %p\n", desc);
         }
 }
+#endif /* HAVE_SERVER_SUPPORT */
 
 /**
  * Register bulk for later transfer
 
 /**
  * Register bulk for later transfer
index bbd7077..8ba66b7 100644 (file)
@@ -53,6 +53,7 @@ extern int test_req_buffer_pressure;
 int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc);
 
 /* client.c */
 int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc);
 
 /* client.c */
+struct ptlrpc_bulk_desc *new_bulk(int npages, int type, int portal);
 void ptlrpc_init_xid(void);
 
 /* events.c */
 void ptlrpc_init_xid(void);
 
 /* events.c */
index 25953f8..5a726e5 100644 (file)
@@ -158,8 +158,11 @@ EXPORT_SYMBOL(ptlrpc_connection_init);
 EXPORT_SYMBOL(ptlrpc_connection_fini);
 
 /* niobuf.c */
 EXPORT_SYMBOL(ptlrpc_connection_fini);
 
 /* niobuf.c */
+#ifdef HAVE_SERVER_SUPPORT
+EXPORT_SYMBOL(ptlrpc_prep_bulk_exp);
 EXPORT_SYMBOL(ptlrpc_start_bulk_transfer);
 EXPORT_SYMBOL(ptlrpc_abort_bulk);
 EXPORT_SYMBOL(ptlrpc_start_bulk_transfer);
 EXPORT_SYMBOL(ptlrpc_abort_bulk);
+#endif
 EXPORT_SYMBOL(ptlrpc_register_bulk);
 EXPORT_SYMBOL(ptlrpc_unregister_bulk);
 EXPORT_SYMBOL(ptlrpc_send_reply);
 EXPORT_SYMBOL(ptlrpc_register_bulk);
 EXPORT_SYMBOL(ptlrpc_unregister_bulk);
 EXPORT_SYMBOL(ptlrpc_send_reply);
@@ -194,7 +197,6 @@ EXPORT_SYMBOL(ptlrpc_req_finished);
 EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock);
 EXPORT_SYMBOL(ptlrpc_request_addref);
 EXPORT_SYMBOL(ptlrpc_prep_bulk_imp);
 EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock);
 EXPORT_SYMBOL(ptlrpc_request_addref);
 EXPORT_SYMBOL(ptlrpc_prep_bulk_imp);
-EXPORT_SYMBOL(ptlrpc_prep_bulk_exp);
 EXPORT_SYMBOL(ptlrpc_free_bulk);
 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
 EXPORT_SYMBOL(ptlrpc_abort_inflight);
 EXPORT_SYMBOL(ptlrpc_free_bulk);
 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
 EXPORT_SYMBOL(ptlrpc_abort_inflight);
index 4367f53..bfcd1ec 100644 (file)
@@ -2301,6 +2301,7 @@ int sptlrpc_cli_unwrap_bulk_write(struct ptlrpc_request *req,
 }
 EXPORT_SYMBOL(sptlrpc_cli_unwrap_bulk_write);
 
 }
 EXPORT_SYMBOL(sptlrpc_cli_unwrap_bulk_write);
 
+#ifdef HAVE_SERVER_SUPPORT
 /**
  * Performe transformation upon outgoing bulk read.
  */
 /**
  * Performe transformation upon outgoing bulk read.
  */
@@ -2382,6 +2383,8 @@ int sptlrpc_svc_prep_bulk(struct ptlrpc_request *req,
 }
 EXPORT_SYMBOL(sptlrpc_svc_prep_bulk);
 
 }
 EXPORT_SYMBOL(sptlrpc_svc_prep_bulk);
 
+#endif /* HAVE_SERVER_SUPPORT */
+
 /****************************************
  * user descriptor helpers              *
  ****************************************/
 /****************************************
  * user descriptor helpers              *
  ****************************************/