From 57443b8277fb2a0181be88f9e3f68ec0e5d0328e Mon Sep 17 00:00:00 2001
From: bobijam <bobijam>
Date: Thu, 13 Dec 2007 03:44:04 +0000
Subject: [PATCH] Branch b1_6 b=14215 i=johann, adilger

user pointer parameter (struct ldlm_res_id*) in ldlm_cli_enqueue_local()
to reduce the stack usage.
---
 lustre/include/lustre_dlm.h | 3 ++-
 lustre/ldlm/ldlm_request.c  | 7 ++++---
 lustre/mds/handler.c        | 2 +-
 lustre/mds/mds_open.c       | 4 ++--
 lustre/mds/mds_reint.c      | 8 ++++----
 lustre/mgs/mgs_handler.c    | 2 +-
 lustre/obdecho/echo.c       | 2 +-
 lustre/obdfilter/filter.c   | 4 ++--
 lustre/ost/ost_handler.c    | 4 ++--
 9 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h
index e1cf930df7..a3adc04b94 100644
--- a/lustre/include/lustre_dlm.h
+++ b/lustre/include/lustre_dlm.h
@@ -745,7 +745,8 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
                           int *flags, void *lvb, __u32 lvb_len,
                           void *lvb_swabber, struct lustre_handle *lockh,
                           int rc);
-int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, struct ldlm_res_id res_id,
+int ldlm_cli_enqueue_local(struct ldlm_namespace *ns,
+                           struct ldlm_res_id *res_id,
                            ldlm_type_t type, ldlm_policy_data_t *policy,
                            ldlm_mode_t mode, int *flags,
                            ldlm_blocking_callback blocking,
diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c
index 84871a82ac..b2c48d8994 100644
--- a/lustre/ldlm/ldlm_request.c
+++ b/lustre/ldlm/ldlm_request.c
@@ -259,7 +259,8 @@ int ldlm_glimpse_ast(struct ldlm_lock *lock, void *reqp)
         return -ELDLM_NO_LOCK_DATA;
 }
 
-int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, struct ldlm_res_id res_id,
+int ldlm_cli_enqueue_local(struct ldlm_namespace *ns,
+                           struct ldlm_res_id *res_id,
                            ldlm_type_t type, ldlm_policy_data_t *policy,
                            ldlm_mode_t mode, int *flags,
                            ldlm_blocking_callback blocking,
@@ -278,7 +279,7 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, struct ldlm_res_id res_id,
                 LBUG();
         }
 
-        lock = ldlm_lock_create(ns, res_id, type, mode, blocking,
+        lock = ldlm_lock_create(ns, *res_id, type, mode, blocking,
                                 completion, glimpse, data, lvb_len);
         if (!lock)
                 GOTO(out_nolock, err = -ENOMEM);
@@ -304,7 +305,7 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, struct ldlm_res_id res_id,
         if (policy != NULL)
                 *policy = lock->l_policy_data;
         if ((*flags) & LDLM_FL_LOCK_CHANGED)
-                res_id = lock->l_resource->lr_name;
+                *res_id = lock->l_resource->lr_name;
 
         LDLM_DEBUG_NOLOCK("client-side local enqueue handler END (lock %p)",
                           lock);
diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index e00d4131d8..de7f4eaf5f 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -188,7 +188,7 @@ struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid,
 
         res_id.name[0] = de->d_inode->i_ino;
         res_id.name[1] = de->d_inode->i_generation;
-        rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id, 
+        rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, 
                                     LDLM_IBITS, &policy, lock_mode, &flags, 
                                     ldlm_blocking_ast, ldlm_completion_ast,
                                     NULL, NULL, 0, NULL, lockh);
diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c
index b2aed1631c..7c50196f35 100644
--- a/lustre/mds/mds_open.c
+++ b/lustre/mds/mds_open.c
@@ -844,7 +844,7 @@ int mds_lock_new_child(struct obd_device *obd, struct inode *inode,
         if (child_lockh == NULL)
                 child_lockh = &lockh;
 
-        rc = ldlm_cli_enqueue_local(obd->obd_namespace, child_res_id,
+        rc = ldlm_cli_enqueue_local(obd->obd_namespace, &child_res_id,
                                     LDLM_PLAIN, NULL, LCK_EX, &lock_flags,
                                     ldlm_blocking_ast, ldlm_completion_ast,
                                     NULL, NULL, 0, NULL, child_lockh);
@@ -1165,7 +1165,7 @@ found_child:
                 child_res_id.name[0] = dchild->d_inode->i_ino;
                 child_res_id.name[1] = dchild->d_inode->i_generation;
 
-                rc = ldlm_cli_enqueue_local(obd->obd_namespace, child_res_id,
+                rc = ldlm_cli_enqueue_local(obd->obd_namespace, &child_res_id,
                                             LDLM_IBITS, &policy, child_mode, 
                                             &lock_flags, ldlm_blocking_ast, 
                                             ldlm_completion_ast, NULL, NULL,
diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c
index a7e4da4950..1200f132e1 100644
--- a/lustre/mds/mds_reint.c
+++ b/lustre/mds/mds_reint.c
@@ -1075,7 +1075,7 @@ int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id,
                res_id[0]->name[0], res_id[1]->name[0]);
 
         flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
-        rc = ldlm_cli_enqueue_local(obd->obd_namespace, *res_id[0],
+        rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id[0],
                                     LDLM_IBITS, policies[0], lock_modes[0],
                                     &flags, ldlm_blocking_ast, 
                                     ldlm_completion_ast, NULL, NULL, 0, 
@@ -1090,7 +1090,7 @@ int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id,
                 ldlm_lock_addref(handles[1], lock_modes[1]);
         } else if (res_id[1]->name[0] != 0) {
                 flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
-                rc = ldlm_cli_enqueue_local(obd->obd_namespace, *res_id[1],
+                rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id[1],
                                             LDLM_IBITS, policies[1],
                                             lock_modes[1], &flags, 
                                             ldlm_blocking_ast,
@@ -1201,7 +1201,7 @@ int enqueue_4ordered_locks(struct obd_device *obd,struct ldlm_res_id *p1_res_id,
                                 try_to_aggregate_locks(res_id[i], policies[i],
                                                        res_id[i+1], policies[i+1]);
                         rc = ldlm_cli_enqueue_local(obd->obd_namespace,
-                                                    *res_id[i], LDLM_IBITS,
+                                                    res_id[i], LDLM_IBITS,
                                                     policies[i], lock_modes[i],
                                                     &flags, ldlm_blocking_ast,
                                                     ldlm_completion_ast, NULL, 
@@ -1291,7 +1291,7 @@ static int mds_verify_child(struct obd_device *obd,
                         GOTO(cleanup, rc = 1);
                 }
 
-                rc = ldlm_cli_enqueue_local(obd->obd_namespace, *child_res_id, 
+                rc = ldlm_cli_enqueue_local(obd->obd_namespace, child_res_id, 
                                             LDLM_IBITS, child_policy, 
                                             child_mode, &flags, 
                                             ldlm_blocking_ast, 
diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c
index f47a658751..57ab5ec03e 100644
--- a/lustre/mgs/mgs_handler.c
+++ b/lustre/mgs/mgs_handler.c
@@ -290,7 +290,7 @@ static int mgs_get_cfg_lock(struct obd_device *obd, char *fsname,
 
         rc = mgc_fsname2resid(fsname, &res_id);
         if (!rc) 
-                rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id,
+                rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id,
                                             LDLM_PLAIN, NULL, LCK_EX,
                                             &flags, ldlm_blocking_ast,
                                             ldlm_completion_ast, NULL,
diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c
index d4c8fbc426..ad97528097 100644
--- a/lustre/obdecho/echo.c
+++ b/lustre/obdecho/echo.c
@@ -473,7 +473,7 @@ static int echo_setup(struct obd_device *obd, obd_count len, void *buf)
                 RETURN(-ENOMEM);
         }
 
-        rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id, LDLM_PLAIN, 
+        rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, LDLM_PLAIN, 
                                     NULL, LCK_NL, &lock_flags, NULL, 
                                     ldlm_completion_ast, NULL, NULL, 
                                     0, NULL, &obd->u.echo.eo_nl_lock);
diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c
index 927241cb6d..09b059f945 100644
--- a/lustre/obdfilter/filter.c
+++ b/lustre/obdfilter/filter.c
@@ -1270,7 +1270,7 @@ static int filter_prepare_destroy(struct obd_device *obd, obd_id objid)
         ENTRY;
         /* Tell the clients that the object is gone now and that they should
          * throw away any cached pages. */
-        rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id, LDLM_EXTENT,
+        rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, LDLM_EXTENT,
                                     &policy, LCK_PW, &flags, ldlm_blocking_ast,
                                     ldlm_completion_ast, NULL, NULL, 0, NULL,
                                     &lockh);
@@ -3126,7 +3126,7 @@ static int filter_create(struct obd_export *exp, struct obdo *oa,
             (oa->o_flags & OBD_FL_RECREATE_OBJS)) {
                 /* Cancel all conflicting extent locks on recreating object,
                  * thus object's metadata will be updated on the clients */
-                rc = ldlm_cli_enqueue_local(obd->obd_namespace, res_id,
+                rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id,
                                             LDLM_EXTENT, &policy, LCK_PW,
                                             &flags, ldlm_blocking_ast,
                                             ldlm_completion_ast,
diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c
index 3915d41477..db286a10af 100644
--- a/lustre/ost/ost_handler.c
+++ b/lustre/ost/ost_handler.c
@@ -233,7 +233,7 @@ static int ost_punch_lock_get(struct obd_export *exp, struct obdo *oa,
         else
                 policy.l_extent.end = finis | ~CFS_PAGE_MASK;
 
-        RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, res_id, 
+        RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, &res_id, 
                                       LDLM_EXTENT, &policy, LCK_PW, &flags,
                                       ldlm_blocking_ast, ldlm_completion_ast,
                                       ldlm_glimpse_ast, NULL, 0, NULL, lh));
@@ -556,7 +556,7 @@ static int ost_brw_lock_get(int mode, struct obd_export *exp,
         policy.l_extent.end   = (nb[nrbufs - 1].offset +
                                  nb[nrbufs - 1].len - 1) | ~CFS_PAGE_MASK;
 
-        RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, res_id, 
+        RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, &res_id, 
                                       LDLM_EXTENT, &policy, mode, &flags,
                                       ldlm_blocking_ast, ldlm_completion_ast,
                                       ldlm_glimpse_ast, NULL, 0, NULL, lh));
-- 
GitLab