Whamcloud - gitweb
LU-2675 obd: decruft md_enqueue() and md_intent_lock() 05/10205/3
authorJohn L. Hammond <john.hammond@intel.com>
Fri, 28 Mar 2014 23:38:37 +0000 (18:38 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 14 May 2014 05:34:15 +0000 (05:34 +0000)
Remove the lmm and lmmsize parameters from both functions, storing
that data in md_op_data when needed. Remove the unused lookup_flags
parameter from md_intent_lock(), and the unused reqp parameter from
md_enqueue(). Add a union ldlm_policy_data * parameter to
md_enqueue(). Remove the unused function lmv_enqueue_remote().

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: Ia914318a7c7cbeb59fe86d4a169559cd86f3ad57
Reviewed-on: http://review.whamcloud.com/10205
Tested-by: Jenkins
Reviewed-by: wangdi <di.wang@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
14 files changed:
lustre/include/obd.h
lustre/include/obd_class.h
lustre/liblustre/dir.c
lustre/liblustre/namei.c
lustre/liblustre/super.c
lustre/llite/file.c
lustre/llite/namei.c
lustre/llite/xattr_cache.c
lustre/lmv/lmv_intent.c
lustre/lmv/lmv_internal.h
lustre/lmv/lmv_obd.c
lustre/mdc/mdc_internal.h
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_request.c

index 18bd041..b161c11 100644 (file)
@@ -960,6 +960,7 @@ struct md_op_data {
         __u32                   op_fsgid;
         cfs_cap_t               op_cap;
         void                   *op_data;
+       size_t                  op_data_size;
 
         /* iattr fields and blocks. */
         struct iattr            op_attr;
@@ -1205,15 +1206,15 @@ struct md_ops {
                        __u64, struct ptlrpc_request **);
 
        int (*m_enqueue)(struct obd_export *, struct ldlm_enqueue_info *,
+                        const union ldlm_policy_data *,
                         struct lookup_intent *, struct md_op_data *,
-                        struct lustre_handle *, void *, int,
-                        struct ptlrpc_request **, __u64);
+                        struct lustre_handle *, __u64);
 
        int (*m_getattr)(struct obd_export *, struct md_op_data *,
                         struct ptlrpc_request **);
 
        int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
-                            void *, int, struct lookup_intent *, int,
+                            struct lookup_intent *,
                             struct ptlrpc_request **,
                             ldlm_blocking_callback, __u64);
 
index b5e2ab5..2692599 100644 (file)
@@ -1681,19 +1681,18 @@ static inline int md_done_writing(struct obd_export *exp,
 
 static inline int md_enqueue(struct obd_export *exp,
                             struct ldlm_enqueue_info *einfo,
+                            const union ldlm_policy_data *policy,
                             struct lookup_intent *it,
                             struct md_op_data *op_data,
                             struct lustre_handle *lockh,
-                            void *lmm, int lmmsize,
-                            struct ptlrpc_request **req,
                             __u64 extra_lock_flags)
 {
-        int rc;
-        ENTRY;
-        EXP_CHECK_MD_OP(exp, enqueue);
-        EXP_MD_COUNTER_INCREMENT(exp, enqueue);
-        rc = MDP(exp->exp_obd, enqueue)(exp, einfo, it, op_data, lockh,
-                                        lmm, lmmsize, req, extra_lock_flags);
+       int rc;
+       ENTRY;
+       EXP_CHECK_MD_OP(exp, enqueue);
+       EXP_MD_COUNTER_INCREMENT(exp, enqueue);
+       rc = MDP(exp->exp_obd, enqueue)(exp, einfo, policy, it, op_data, lockh,
+                                       extra_lock_flags);
         RETURN(rc);
 }
 
@@ -1710,20 +1709,19 @@ static inline int md_getattr_name(struct obd_export *exp,
 }
 
 static inline int md_intent_lock(struct obd_export *exp,
-                                struct md_op_data *op_data, void *lmm,
-                                int lmmsize, struct lookup_intent *it,
-                                int lookup_flags, struct ptlrpc_request **reqp,
+                                struct md_op_data *op_data,
+                                struct lookup_intent *it,
+                                struct ptlrpc_request **reqp,
                                 ldlm_blocking_callback cb_blocking,
                                 __u64 extra_lock_flags)
 {
-        int rc;
-        ENTRY;
-        EXP_CHECK_MD_OP(exp, intent_lock);
-        EXP_MD_COUNTER_INCREMENT(exp, intent_lock);
-        rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, lmm, lmmsize,
-                                            it, lookup_flags, reqp, cb_blocking,
-                                            extra_lock_flags);
-        RETURN(rc);
+       int rc;
+       ENTRY;
+       EXP_CHECK_MD_OP(exp, intent_lock);
+       EXP_MD_COUNTER_INCREMENT(exp, intent_lock);
+       rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp, cb_blocking,
+                                           extra_lock_flags);
+       RETURN(rc);
 }
 
 static inline int md_link(struct obd_export *exp, struct md_op_data *op_data,
index 706cc74..b14e1a2 100644 (file)
@@ -86,9 +86,8 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page)
                        .ei_cbdata      = inode,
                };
 
-                rc = md_enqueue(sbi->ll_md_exp, &einfo, &it,
-                                &op_data, &lockh, NULL, 0, NULL,
-                                LDLM_FL_CANCEL_ON_BLOCK);
+               rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, &it, &op_data,
+                               &lockh, LDLM_FL_CANCEL_ON_BLOCK);
                 request = (struct ptlrpc_request *)it.d.lustre.it_data;
                 if (request)
                         ptlrpc_req_finished(request);
index 23d6843..c129f0b 100644 (file)
@@ -263,9 +263,8 @@ static int llu_pb_revalidate(struct pnode *pnode, int flags,
                             pb->pb_ino, pb->pb_name.name, pb->pb_name.len,
                             0, LUSTRE_OPC_ANY);
 
-        rc = md_intent_lock(exp, &op_data, NULL, 0, it, flags,
-                            &req, llu_md_blocking_ast,
-                            LDLM_FL_CANCEL_ON_BLOCK);
+       rc = md_intent_lock(exp, &op_data, it, &req, &llu_md_blocking_ast,
+                           LDLM_FL_CANCEL_ON_BLOCK);
         /* If req is NULL, then md_intent_lock only tried to do a lock match;
          * if all was well, it will return 1 if it found locks, 0 otherwise. */
         if (req == NULL && rc >= 0)
@@ -429,9 +428,8 @@ static int llu_lookup_it(struct inode *parent, struct pnode *pnode,
                             pnode->p_base->pb_name.name,
                             pnode->p_base->pb_name.len, flags, opc);
 
-        rc = md_intent_lock(llu_i2mdexp(parent), &op_data, NULL, 0, it,
-                            flags, &req, llu_md_blocking_ast,
-                            LDLM_FL_CANCEL_ON_BLOCK);
+       rc = md_intent_lock(llu_i2mdexp(parent), &op_data, it, &req,
+                           &llu_md_blocking_ast, LDLM_FL_CANCEL_ON_BLOCK);
         if (rc < 0)
                 GOTO(out, rc);
 
index 35fbb57..9980b95 100644 (file)
@@ -1631,8 +1631,8 @@ static int llu_lov_setstripe_ea_info(struct inode *ino, int flags,
 
         llu_prep_md_op_data(&data, NULL, ino, NULL, 0, O_RDWR,
                             LUSTRE_OPC_ANY);
-        rc = md_enqueue(sbi->ll_md_exp, &einfo, &oit, &data,
-                        &lockh, lum, lum_size, NULL, LDLM_FL_INTENT_ONLY);
+       rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, &oit, &data, &lockh,
+                       LDLM_FL_INTENT_ONLY);
         if (rc)
                 GOTO(out, rc);
 
index 8b4e3a3..2450897 100644 (file)
@@ -417,7 +417,7 @@ static int ll_intent_file_open(struct file *file, void *lmm,
         const char *name = file->f_dentry->d_name.name;
         const int len = file->f_dentry->d_name.len;
         struct md_op_data *op_data;
-        struct ptlrpc_request *req;
+       struct ptlrpc_request *req = NULL;
         __u32 opc = LUSTRE_OPC_ANY;
         int rc;
         ENTRY;
@@ -446,9 +446,12 @@ static int ll_intent_file_open(struct file *file, void *lmm,
         if (IS_ERR(op_data))
                 RETURN(PTR_ERR(op_data));
 
+       op_data->op_data = lmm;
+       op_data->op_data_size = lmmsize;
+
        itp->it_flags |= MDS_OPEN_BY_FID;
-        rc = md_intent_lock(sbi->ll_md_exp, op_data, lmm, lmmsize, itp,
-                            0 /*unused */, &req, ll_md_blocking_ast, 0);
+       rc = md_intent_lock(sbi->ll_md_exp, op_data, itp, &req,
+                           &ll_md_blocking_ast, 0);
         ll_finish_md_op_data(op_data);
         if (rc == -ESTALE) {
                 /* reason for keep own exit path - don`t flood log
@@ -776,7 +779,7 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode,
        struct lookup_intent it = { .it_op = IT_OPEN };
        struct ll_sb_info *sbi = ll_i2sbi(inode);
        struct md_op_data *op_data;
-       struct ptlrpc_request *req;
+       struct ptlrpc_request *req = NULL;
        struct lustre_handle old_handle = { 0 };
        struct obd_client_handle *och = NULL;
        int rc;
@@ -842,15 +845,15 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode,
 
        it.it_flags = fmode | open_flags;
        it.it_flags |= MDS_OPEN_LOCK | MDS_OPEN_BY_FID | MDS_OPEN_LEASE;
-       rc = md_intent_lock(sbi->ll_md_exp, op_data, NULL, 0, &it, 0, &req,
-                               ll_md_blocking_lease_ast,
+       rc = md_intent_lock(sbi->ll_md_exp, op_data, &it, &req,
+                           &ll_md_blocking_lease_ast,
        /* LDLM_FL_NO_LRU: To not put the lease lock into LRU list, otherwise
         * it can be cancelled which may mislead applications that the lease is
         * broken;
         * LDLM_FL_EXCL: Set this flag so that it won't be matched by normal
         * open in ll_md_blocking_ast(). Otherwise as ll_md_blocking_lease_ast
         * doesn't deal with openhandle, so normal openhandle will be leaked. */
-                               LDLM_FL_NO_LRU | LDLM_FL_EXCL);
+                           LDLM_FL_NO_LRU | LDLM_FL_EXCL);
        ll_finish_md_op_data(op_data);
        ptlrpc_req_finished(req);
        if (rc < 0)
@@ -2991,8 +2994,8 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
               flock.l_flock.pid, flags, einfo.ei_mode,
               flock.l_flock.start, flock.l_flock.end);
 
-        rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL,
-                        op_data, &lockh, &flock, 0, NULL /* req */, flags);
+       rc = md_enqueue(sbi->ll_md_exp, &einfo, &flock, NULL, op_data, &lockh,
+                       flags);
 
        /* Restore the file lock type if not TEST lock. */
        if (!(flags & LDLM_FL_TEST_LOCK))
@@ -3008,8 +3011,8 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
 
        if (rc2 && file_lock->fl_type != F_UNLCK) {
                einfo.ei_mode = LCK_NL;
-               md_enqueue(sbi->ll_md_exp, &einfo, NULL,
-                       op_data, &lockh, &flock, 0, NULL /* req */, flags);
+               md_enqueue(sbi->ll_md_exp, &einfo, &flock, NULL, op_data,
+                          &lockh, flags);
                rc = rc2;
        }
 
@@ -3254,11 +3257,8 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
                         RETURN(PTR_ERR(op_data));
 
                 oit.it_create_mode |= M_CHECK_STALE;
-                rc = md_intent_lock(exp, op_data, NULL, 0,
-                                    /* we are not interested in name
-                                       based lookup */
-                                    &oit, 0, &req,
-                                    ll_md_blocking_ast, 0);
+               rc = md_intent_lock(exp, op_data, &oit, &req,
+                                   &ll_md_blocking_ast, 0);
                 ll_finish_md_op_data(op_data);
                 oit.it_create_mode &= ~M_CHECK_STALE;
                 if (rc < 0) {
@@ -3998,8 +3998,8 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen)
        struct ldlm_enqueue_info einfo = {
                .ei_type = LDLM_IBITS,
                .ei_mode = LCK_CR,
-               .ei_cb_bl = ll_md_blocking_ast,
-               .ei_cb_cp = ldlm_completion_ast,
+               .ei_cb_bl = &ll_md_blocking_ast,
+               .ei_cb_cp = &ldlm_completion_ast,
        };
        int rc;
        ENTRY;
@@ -4045,8 +4045,7 @@ again:
                          ll_get_fsname(inode->i_sb, NULL, 0),
                          PFID(&lli->lli_fid), inode);
 
-       rc = md_enqueue(sbi->ll_md_exp, &einfo, &it, op_data, &lockh,
-                       NULL, 0, NULL, 0);
+       rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, &it, op_data, &lockh, 0);
        if (it.d.lustre.it_data != NULL)
                ptlrpc_req_finished(it.d.lustre.it_data);
        it.d.lustre.it_data = NULL;
index 98fea57..69da17e 100644 (file)
@@ -571,8 +571,8 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
         if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent)))
                it->it_create_mode &= ~current_umask();
 
-        rc = md_intent_lock(ll_i2mdexp(parent), op_data, NULL, 0, it,
-                            lookup_flags, &req, ll_md_blocking_ast, 0);
+       rc = md_intent_lock(ll_i2mdexp(parent), op_data, it, &req,
+                           &ll_md_blocking_ast, 0);
         ll_finish_md_op_data(op_data);
         if (rc < 0)
                 GOTO(out, retval = ERR_PTR(rc));
index c0bc334..b96a973 100644 (file)
@@ -314,10 +314,12 @@ static int ll_xattr_find_get_lock(struct inode *inode,
        struct lustre_handle lockh = { 0 };
        struct md_op_data *op_data;
        struct ll_inode_info *lli = ll_i2info(inode);
-       struct ldlm_enqueue_info einfo = { .ei_type = LDLM_IBITS,
-                                          .ei_mode = it_to_lock_mode(oit),
-                                          .ei_cb_bl = ll_md_blocking_ast,
-                                          .ei_cb_cp = ldlm_completion_ast };
+       struct ldlm_enqueue_info einfo = {
+               .ei_type = LDLM_IBITS,
+               .ei_mode = it_to_lock_mode(oit),
+               .ei_cb_bl = &ll_md_blocking_ast,
+               .ei_cb_cp = &ldlm_completion_ast,
+       };
        struct ll_sb_info *sbi = ll_i2sbi(inode);
        struct obd_export *exp = sbi->ll_md_exp;
        int rc;
@@ -344,7 +346,7 @@ static int ll_xattr_find_get_lock(struct inode *inode,
 
        op_data->op_valid = OBD_MD_FLXATTR | OBD_MD_FLXATTRLS;
 
-       rc = md_enqueue(exp, &einfo, oit, op_data, &lockh, NULL, 0, NULL, 0);
+       rc = md_enqueue(exp, &einfo, NULL, oit, op_data, &lockh, 0);
        ll_finish_md_op_data(op_data);
 
        if (rc < 0) {
index 08e0297..da76f8f 100644 (file)
@@ -59,9 +59,8 @@
 #include <lprocfs_status.h>
 #include "lmv_internal.h"
 
-static int lmv_intent_remote(struct obd_export *exp, void *lmm,
-                            int lmmsize, struct lookup_intent *it,
-                            const struct lu_fid *parent_fid, int flags,
+static int lmv_intent_remote(struct obd_export *exp, struct lookup_intent *it,
+                            const struct lu_fid *parent_fid,
                             struct ptlrpc_request **reqp,
                             ldlm_blocking_callback cb_blocking,
                             __u64 extra_lock_flags)
@@ -127,8 +126,8 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm,
        CDEBUG(D_INODE, "REMOTE_INTENT with fid="DFID" -> mds #%d\n",
               PFID(&body->fid1), tgt->ltd_idx);
 
-        rc = md_intent_lock(tgt->ltd_exp, op_data, lmm, lmmsize, it,
-                            flags, &req, cb_blocking, extra_lock_flags);
+       rc = md_intent_lock(tgt->ltd_exp, op_data, it, &req, cb_blocking,
+                           extra_lock_flags);
         if (rc)
                 GOTO(out_free_op_data, rc);
 
@@ -219,8 +218,8 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct mdt_body *mbody,
                CDEBUG(D_INODE, "Revalidate slave "DFID" -> mds #%d\n",
                       PFID(&fid), tgt->ltd_idx);
 
-               rc = md_intent_lock(tgt->ltd_exp, op_data, NULL, 0, &it, 0,
-                                   &req, cb_blocking, extra_lock_flags);
+               rc = md_intent_lock(tgt->ltd_exp, op_data, &it, &req,
+                                   cb_blocking, extra_lock_flags);
                if (rc < 0)
                        GOTO(cleanup, rc);
 
@@ -326,10 +325,8 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct mdt_body *mbody,
  * may be split dir.
  */
 int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
-                    void *lmm, int lmmsize, struct lookup_intent *it,
-                    int flags, struct ptlrpc_request **reqp,
-                    ldlm_blocking_callback cb_blocking,
-                   __u64 extra_lock_flags)
+                   struct lookup_intent *it, struct ptlrpc_request **reqp,
+                   ldlm_blocking_callback cb_blocking, __u64 extra_lock_flags)
 {
        struct obd_device       *obd = exp->exp_obd;
        struct lmv_obd          *lmv = &obd->u.lmv;
@@ -381,8 +378,8 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
               " name='%s' -> mds #%d\n", PFID(&op_data->op_fid1),
               PFID(&op_data->op_fid2), op_data->op_name, tgt->ltd_idx);
 
-       rc = md_intent_lock(tgt->ltd_exp, op_data, lmm, lmmsize, it, flags,
-                           reqp, cb_blocking, extra_lock_flags);
+       rc = md_intent_lock(tgt->ltd_exp, op_data, it, reqp, cb_blocking,
+                           extra_lock_flags);
        if (rc != 0)
                RETURN(rc);
        /*
@@ -400,9 +397,8 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
 
        /* Not cross-ref case, just get out of here. */
        if (unlikely((body->valid & OBD_MD_MDS))) {
-               rc = lmv_intent_remote(exp, lmm, lmmsize, it, &op_data->op_fid1,
-                                      flags, reqp, cb_blocking,
-                                      extra_lock_flags);
+               rc = lmv_intent_remote(exp, it, &op_data->op_fid1, reqp,
+                                      cb_blocking, extra_lock_flags);
                if (rc != 0)
                        RETURN(rc);
 
@@ -417,11 +413,11 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
 /*
  * Handler for: getattr, lookup and revalidate cases.
  */
-int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
-                      void *lmm, int lmmsize, struct lookup_intent *it,
-                      int flags, struct ptlrpc_request **reqp,
-                      ldlm_blocking_callback cb_blocking,
-                     __u64 extra_lock_flags)
+static int
+lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
+                 struct lookup_intent *it, struct ptlrpc_request **reqp,
+                 ldlm_blocking_callback cb_blocking,
+                 __u64 extra_lock_flags)
 {
        struct obd_device       *obd = exp->exp_obd;
        struct lmv_obd          *lmv = &obd->u.lmv;
@@ -446,8 +442,8 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
 
        op_data->op_bias &= ~MDS_CROSS_REF;
 
-       rc = md_intent_lock(tgt->ltd_exp, op_data, lmm, lmmsize, it,
-                            flags, reqp, cb_blocking, extra_lock_flags);
+       rc = md_intent_lock(tgt->ltd_exp, op_data, it, reqp, cb_blocking,
+                           extra_lock_flags);
        if (rc < 0)
                RETURN(rc);
 
@@ -480,8 +476,8 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
 
                op_data->op_fid1 = lsm->lsm_md_oinfo[1].lmo_fid;
                it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE;
-               rc = md_intent_lock(tgt->ltd_exp, op_data, lmm, lmmsize, it,
-                                   flags, reqp, cb_blocking, extra_lock_flags);
+               rc = md_intent_lock(tgt->ltd_exp, op_data, it, reqp,
+                                   cb_blocking, extra_lock_flags);
        }
        /*
         * MDS has returned success. Probably name has been resolved in
@@ -493,8 +489,8 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
 
        /* Not cross-ref case, just get out of here. */
        if (unlikely((body->valid & OBD_MD_MDS))) {
-               rc = lmv_intent_remote(exp, lmm, lmmsize, it, NULL, flags,
-                                      reqp, cb_blocking, extra_lock_flags);
+               rc = lmv_intent_remote(exp, it, NULL, reqp, cb_blocking,
+                                      extra_lock_flags);
                if (rc != 0)
                        RETURN(rc);
                body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY);
@@ -506,9 +502,8 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
 }
 
 int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
-                    void *lmm, int lmmsize, struct lookup_intent *it,
-                    int flags, struct ptlrpc_request **reqp,
-                    ldlm_blocking_callback cb_blocking,
+                   struct lookup_intent *it, struct ptlrpc_request **reqp,
+                   ldlm_blocking_callback cb_blocking,
                    __u64 extra_lock_flags)
 {
         struct obd_device *obd = exp->exp_obd;
@@ -526,15 +521,14 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
         if (rc)
                 RETURN(rc);
 
-        if (it->it_op & (IT_LOOKUP | IT_GETATTR | IT_LAYOUT))
-                rc = lmv_intent_lookup(exp, op_data, lmm, lmmsize, it,
-                                       flags, reqp, cb_blocking,
-                                       extra_lock_flags);
-        else if (it->it_op & IT_OPEN)
-                rc = lmv_intent_open(exp, op_data, lmm, lmmsize, it,
-                                     flags, reqp, cb_blocking,
-                                     extra_lock_flags);
-        else
-                LBUG();
-        RETURN(rc);
+       if (it->it_op & (IT_LOOKUP | IT_GETATTR | IT_LAYOUT))
+               rc = lmv_intent_lookup(exp, op_data, it, reqp, cb_blocking,
+                                      extra_lock_flags);
+       else if (it->it_op & IT_OPEN)
+               rc = lmv_intent_open(exp, op_data, it, reqp, cb_blocking,
+                                    extra_lock_flags);
+       else
+               LBUG();
+
+       RETURN(rc);
 }
index 5cadf54..c3485b4 100644 (file)
 int lmv_check_connect(struct obd_device *obd);
 
 int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
-                    void *lmm, int lmmsize, struct lookup_intent *it,
-                    int flags, struct ptlrpc_request **reqp,
-                    ldlm_blocking_callback cb_blocking,
-                   __u64 extra_lock_flags);
-
-int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
-                      void *lmm, int lmmsize, struct lookup_intent *it,
-                      int flags, struct ptlrpc_request **reqp,
-                      ldlm_blocking_callback cb_blocking,
-                     __u64 extra_lock_flags);
-
-int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
-                    void *lmm, int lmmsize, struct lookup_intent *it,
-                    int flags, struct ptlrpc_request **reqp,
-                    ldlm_blocking_callback cb_blocking,
+                   struct lookup_intent *it, struct ptlrpc_request **reqp,
+                   ldlm_blocking_callback cb_blocking,
                    __u64 extra_lock_flags);
 
 int lmv_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
index 4b1d9f0..659d3de 100644 (file)
@@ -1872,69 +1872,10 @@ static int lmv_done_writing(struct obd_export *exp,
 }
 
 static int
-lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
-                  struct lookup_intent *it, struct md_op_data *op_data,
-                  struct lustre_handle *lockh, void *lmm, int lmmsize,
-                  __u64 extra_lock_flags)
-{
-        struct ptlrpc_request      *req = it->d.lustre.it_data;
-        struct obd_device          *obd = exp->exp_obd;
-        struct lmv_obd             *lmv = &obd->u.lmv;
-        struct lustre_handle        plock;
-        struct lmv_tgt_desc        *tgt;
-        struct md_op_data          *rdata;
-        struct lu_fid               fid1;
-        struct mdt_body            *body;
-        int                         rc = 0;
-        int                         pmode;
-        ENTRY;
-
-        body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
-        LASSERT(body != NULL);
-
-        if (!(body->valid & OBD_MD_MDS))
-                RETURN(0);
-
-        CDEBUG(D_INODE, "REMOTE_ENQUEUE '%s' on "DFID" -> "DFID"\n",
-               LL_IT2STR(it), PFID(&op_data->op_fid1), PFID(&body->fid1));
-
-        /*
-         * We got LOOKUP lock, but we really need attrs.
-         */
-        pmode = it->d.lustre.it_lock_mode;
-        LASSERT(pmode != 0);
-        memcpy(&plock, lockh, sizeof(plock));
-        it->d.lustre.it_lock_mode = 0;
-        it->d.lustre.it_data = NULL;
-        fid1 = body->fid1;
-
-        ptlrpc_req_finished(req);
-
-        tgt = lmv_find_target(lmv, &fid1);
-        if (IS_ERR(tgt))
-                GOTO(out, rc = PTR_ERR(tgt));
-
-        OBD_ALLOC_PTR(rdata);
-        if (rdata == NULL)
-                GOTO(out, rc = -ENOMEM);
-
-        rdata->op_fid1 = fid1;
-        rdata->op_bias = MDS_CROSS_REF;
-
-        rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh,
-                        lmm, lmmsize, NULL, extra_lock_flags);
-        OBD_FREE_PTR(rdata);
-        EXIT;
-out:
-        ldlm_lock_decref(&plock, pmode);
-        return rc;
-}
-
-static int
 lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
-            struct lookup_intent *it, struct md_op_data *op_data,
-            struct lustre_handle *lockh, void *lmm, int lmmsize,
-           struct ptlrpc_request **req, __u64 extra_lock_flags)
+           const union ldlm_policy_data *policy,
+           struct lookup_intent *it, struct md_op_data *op_data,
+           struct lustre_handle *lockh, __u64 extra_lock_flags)
 {
        struct obd_device        *obd = exp->exp_obd;
        struct lmv_obd           *lmv = &obd->u.lmv;
@@ -1956,13 +1897,9 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
        CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID" -> mds #%d\n",
               LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx);
 
-       rc = md_enqueue(tgt->ltd_exp, einfo, it, op_data, lockh,
-                       lmm, lmmsize, req, extra_lock_flags);
+       rc = md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh,
+                       extra_lock_flags);
 
-       if (rc == 0 && it && it->it_op == IT_OPEN) {
-               rc = lmv_enqueue_remote(exp, einfo, it, op_data, lockh,
-                                       lmm, lmmsize, extra_lock_flags);
-       }
        RETURN(rc);
 }
 
index b6ed204..2e5dcdb 100644 (file)
@@ -83,16 +83,16 @@ int mdc_find_cbdata(struct obd_export *exp, const struct lu_fid *fid,
                     ldlm_iterator_t it, void *data);
 
 int mdc_intent_lock(struct obd_export *exp,
-                    struct md_op_data *,
-                    void *lmm, int lmmsize,
-                    struct lookup_intent *, int,
-                    struct ptlrpc_request **reqp,
+                   struct md_op_data *op_data,
+                   struct lookup_intent *it,
+                   struct ptlrpc_request **reqp,
                    ldlm_blocking_callback cb_blocking,
                    __u64 extra_lock_flags);
+
 int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
-                struct lookup_intent *it, struct md_op_data *op_data,
-                struct lustre_handle *lockh, void *lmm, int lmmsize,
-               struct ptlrpc_request **req, __u64 extra_lock_flags);
+               const union ldlm_policy_data *policy,
+               struct lookup_intent *it, struct md_op_data *op_data,
+               struct lustre_handle *lockh, __u64 extra_lock_flags);
 
 int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid,
                            struct list_head *cancels, ldlm_mode_t mode,
index bf68ed9..fecf49a 100644 (file)
@@ -263,19 +263,19 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,
         }
 }
 
-static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp,
-                                                   struct lookup_intent *it,
-                                                   struct md_op_data *op_data,
-                                                   void *lmm, int lmmsize,
-                                                   void *cb_data)
+static struct ptlrpc_request *
+mdc_intent_open_pack(struct obd_export *exp, struct lookup_intent *it,
+                    struct md_op_data *op_data)
 {
-        struct ptlrpc_request *req;
-        struct obd_device     *obddev = class_exp2obd(exp);
-        struct ldlm_intent    *lit;
-       struct list_head       cancels = LIST_HEAD_INIT(cancels);
-        int                    count = 0;
-        int                    mode;
-        int                    rc;
+       struct ptlrpc_request   *req;
+       struct obd_device       *obddev = class_exp2obd(exp);
+       struct ldlm_intent      *lit;
+       const void              *lmm = op_data->op_data;
+       int                      lmmsize = op_data->op_data_size;
+       struct list_head         cancels = LIST_HEAD_INIT(cancels);
+       int                      count = 0;
+       int                      mode;
+       int                      rc;
         ENTRY;
 
         it->it_create_mode = (it->it_create_mode & ~S_IFMT) | S_IFREG;
@@ -327,8 +327,8 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp,
 
         req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
                              op_data->op_namelen + 1);
-        req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT,
-                             max(lmmsize, obddev->u.cli.cl_default_mds_easize));
+       req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT,
+                            max(lmmsize, obddev->u.cli.cl_default_mds_easize));
 
        rc = ldlm_prep_enqueue_req(exp, req, &cancels, count);
        if (rc < 0) {
@@ -777,10 +777,11 @@ static int mdc_finish_enqueue(struct obd_export *exp,
 
 /* We always reserve enough space in the reply packet for a stripe MD, because
  * we don't know in advance the file type. */
-int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
-                struct lookup_intent *it, struct md_op_data *op_data,
-                struct lustre_handle *lockh, void *lmm, int lmmsize,
-               struct ptlrpc_request **reqp, __u64 extra_lock_flags)
+int mdc_enqueue(struct obd_export *exp,
+               struct ldlm_enqueue_info *einfo,
+               const union ldlm_policy_data *policy,
+               struct lookup_intent *it, struct md_op_data *op_data,
+               struct lustre_handle *lockh, __u64 extra_lock_flags)
 {
         struct obd_device     *obddev = class_exp2obd(exp);
         struct ptlrpc_request *req = NULL;
@@ -795,7 +796,6 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
                            { .l_inodebits = { MDS_INODELOCK_LAYOUT } };
        static const ldlm_policy_data_t getxattr_policy = {
                              .l_inodebits = { MDS_INODELOCK_XATTR } };
-        ldlm_policy_data_t const *policy = &lookup_policy;
         int                    generation, resends = 0;
         struct ldlm_reply     *lockrep;
        enum lvb_type          lvb_type = 0;
@@ -803,38 +803,32 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
 
         LASSERTF(!it || einfo->ei_type == LDLM_IBITS, "lock type %d\n",
                  einfo->ei_type);
-
         fid_build_reg_res_name(&op_data->op_fid1, &res_id);
 
-       if (it) {
+       if (it != NULL) {
+               LASSERT(policy == NULL);
+
                saved_flags |= LDLM_FL_HAS_INTENT;
-               if (it->it_op & (IT_UNLINK | IT_GETATTR | IT_READDIR))
+               if (it->it_op & (IT_OPEN | IT_UNLINK | IT_GETATTR | IT_READDIR))
                        policy = &update_policy;
                else if (it->it_op & IT_LAYOUT)
                        policy = &layout_policy;
                else if (it->it_op & (IT_GETXATTR | IT_SETXATTR))
                        policy = &getxattr_policy;
+               else
+                       policy = &lookup_policy;
        }
 
-        LASSERT(reqp == NULL);
-
         generation = obddev->u.cli.cl_import->imp_generation;
 resend:
         flags = saved_flags;
-        if (!it) {
-                /* The only way right now is FLOCK, in this case we hide flock
-                   policy as lmm, but lmmsize is 0 */
-                LASSERT(lmm && lmmsize == 0);
-                LASSERTF(einfo->ei_type == LDLM_FLOCK, "lock type %d\n",
-                         einfo->ei_type);
-                policy = (ldlm_policy_data_t *)lmm;
-                res_id.name[3] = LDLM_FLOCK;
-        } else if (it->it_op & IT_OPEN) {
-                req = mdc_intent_open_pack(exp, it, op_data, lmm, lmmsize,
-                                           einfo->ei_cbdata);
-                policy = &update_policy;
-                einfo->ei_cbdata = NULL;
-                lmm = NULL;
+       if (it == NULL) {
+               /* The only way right now is FLOCK. */
+               LASSERTF(einfo->ei_type == LDLM_FLOCK, "lock type %d\n",
+                        einfo->ei_type);
+               res_id.name[3] = LDLM_FLOCK;
+       } else if (it->it_op & IT_OPEN) {
+               req = mdc_intent_open_pack(exp, it, op_data);
        } else if (it->it_op & IT_UNLINK) {
                req = mdc_intent_unlink_pack(exp, it, op_data);
        } else if (it->it_op & (IT_GETATTR | IT_LOOKUP)) {
@@ -1154,10 +1148,8 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
  * child lookup.
  */
 int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
-                    void *lmm, int lmmsize, struct lookup_intent *it,
-                    int lookup_flags, struct ptlrpc_request **reqp,
-                    ldlm_blocking_callback cb_blocking,
-                   __u64 extra_lock_flags)
+                   struct lookup_intent *it, struct ptlrpc_request **reqp,
+                   ldlm_blocking_callback cb_blocking, __u64 extra_lock_flags)
 {
        struct ldlm_enqueue_info einfo = {
                .ei_type        = LDLM_IBITS,
@@ -1198,12 +1190,13 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
                        RETURN(rc);
                }
        }
-       rc = mdc_enqueue(exp, &einfo, it, op_data, &lockh, lmm, lmmsize, NULL,
+
+       rc = mdc_enqueue(exp, &einfo, NULL, it, op_data, &lockh,
                         extra_lock_flags);
        if (rc < 0)
                RETURN(rc);
 
-        *reqp = it->d.lustre.it_data;
+       *reqp = it->d.lustre.it_data;
         rc = mdc_finish_intent_lock(exp, *reqp, op_data, it, &lockh);
         RETURN(rc);
 }
index 00ceb06..9dc00ce 100644 (file)
@@ -1528,7 +1528,7 @@ static int mdc_read_page(struct obd_export *exp, struct md_op_data *op_data,
 
        mapping = dir->i_mapping;
 
-       rc = mdc_intent_lock(exp, op_data, NULL, 0, &it, 0, &enq_req,
+       rc = mdc_intent_lock(exp, op_data, &it, &enq_req,
                             cb_op->md_blocking_ast, 0);
        if (enq_req != NULL)
                ptlrpc_req_finished(enq_req);