Whamcloud - gitweb
LU-969 debug: reduce stack usage
authorHongchao Zhang <hongchao.zhang@whamcloud.com>
Thu, 5 Jan 2012 21:28:51 +0000 (05:28 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 15 Feb 2012 23:16:06 +0000 (18:16 -0500)
in ptlrpc_main, move struct lu_env to heap to save stack
in mdt_open.c, declare functions non-static to prevent inlining

Change-Id: I73c703c79b0539dc40036a5f9b131507adaff662
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Signed-off-by: Hongchao Zhang <hongchao.zhang@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/2070
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/mdt/mdt_open.c
lustre/ptlrpc/service.c

index 6e886ad..3eab86c 100644 (file)
@@ -726,9 +726,9 @@ static int mdt_mfd_open(struct mdt_thread_info *info, struct mdt_object *p,
 }
 
 
-static int mdt_finish_open(struct mdt_thread_info *info,
-                           struct mdt_object *p, struct mdt_object *o,
-                           __u64 flags, int created, struct ldlm_reply *rep)
+int mdt_finish_open(struct mdt_thread_info *info,
+                    struct mdt_object *p, struct mdt_object *o,
+                    __u64 flags, int created, struct ldlm_reply *rep)
 {
         struct ptlrpc_request   *req = mdt_info_req(info);
         struct obd_export       *exp = req->rq_export;
@@ -998,8 +998,8 @@ out:
         LASSERT(ergo(rc < 0, lustre_msg_get_transno(req->rq_repmsg) == 0));
 }
 
-static int mdt_open_by_fid(struct mdt_thread_info* info,
-                           struct ldlm_reply *rep)
+int mdt_open_by_fid(struct mdt_thread_info* info,
+                    struct ldlm_reply *rep)
 {
         const struct lu_env     *env = info->mti_env;
         __u32                    flags = info->mti_spec.sp_cr_flags;
@@ -1036,9 +1036,9 @@ static int mdt_open_by_fid(struct mdt_thread_info* info,
         RETURN(rc);
 }
 
-static int mdt_open_anon_by_fid(struct mdt_thread_info *info,
-                                struct ldlm_reply *rep,
-                                struct mdt_lock_handle *lhc)
+int mdt_open_anon_by_fid(struct mdt_thread_info *info,
+                         struct ldlm_reply *rep,
+                         struct mdt_lock_handle *lhc)
 {
         const struct lu_env     *env   = info->mti_env;
         struct mdt_device       *mdt   = info->mti_mdt;
@@ -1138,9 +1138,9 @@ int mdt_pin(struct mdt_thread_info* info)
 }
 
 /* Cross-ref request. Currently it can only be a pure open (w/o create) */
-static int mdt_cross_open(struct mdt_thread_info* info,
-                          const struct lu_fid *fid,
-                          struct ldlm_reply *rep, __u32 flags)
+int mdt_cross_open(struct mdt_thread_info* info,
+                   const struct lu_fid *fid,
+                   struct ldlm_reply *rep, __u32 flags)
 {
         struct md_attr    *ma = &info->mti_attr;
         struct mdt_object *o;
index 66ff9fc..faa476b 100644 (file)
@@ -2085,7 +2085,7 @@ static int ptlrpc_main(void *arg)
 #ifdef WITH_GROUP_INFO
         cfs_group_info_t *ginfo = NULL;
 #endif
-        struct lu_env env;
+        struct lu_env *env;
         int counter = 0, rc = 0;
         ENTRY;
 
@@ -2128,14 +2128,20 @@ static int ptlrpc_main(void *arg)
                         goto out;
         }
 
-        rc = lu_context_init(&env.le_ctx,
+        OBD_ALLOC_PTR(env);
+        if (env == NULL) {
+                rc = -ENOMEM;
+                goto out_srv_fini;
+        }
+
+        rc = lu_context_init(&env->le_ctx,
                              svc->srv_ctx_tags|LCT_REMEMBER|LCT_NOREF);
         if (rc)
                 goto out_srv_fini;
 
-        thread->t_env = &env;
-        env.le_ctx.lc_thread = thread;
-        env.le_ctx.lc_cookie = 0x6;
+        thread->t_env = env;
+        env->le_ctx.lc_thread = thread;
+        env->le_ctx.lc_cookie = 0x6;
 
         /* Alloc reply state structure for this one */
         OBD_ALLOC_LARGE(rs, svc->srv_max_reply_size);
@@ -2199,9 +2205,9 @@ static int ptlrpc_main(void *arg)
                         ptlrpc_at_check_timed(svc);
 
                 if (ptlrpc_server_request_pending(svc, 0)) {
-                        lu_context_enter(&env.le_ctx);
+                        lu_context_enter(&env->le_ctx);
                         ptlrpc_server_handle_request(svc, thread);
-                        lu_context_exit(&env.le_ctx);
+                        lu_context_exit(&env->le_ctx);
                 }
 
                 if (ptlrpc_rqbd_pending(svc) &&
@@ -2225,7 +2231,10 @@ out_srv_fini:
         if (svc->srv_done != NULL)
                 svc->srv_done(thread);
 
-        lu_context_fini(&env.le_ctx);
+        if (env != NULL) {
+                lu_context_fini(&env->le_ctx);
+                OBD_FREE_PTR(env);
+        }
 out:
         CDEBUG(D_RPCTRACE, "service thread [ %p : %u ] %d exiting: rc %d\n",
                thread, thread->t_pid, thread->t_id, rc);