Whamcloud - gitweb
b=17757
authorzhanghc <zhanghc>
Tue, 3 Mar 2009 16:20:01 +0000 (16:20 +0000)
committerzhanghc <zhanghc>
Tue, 3 Mar 2009 16:20:01 +0000 (16:20 +0000)
clear DISP_OPEN_LOCK flag in "reconstruct_open"
if the corresponding lock was canceled

i=Green
i=Johann

lustre/include/lustre_dlm.h
lustre/include/lustre_mds.h
lustre/mdc/mdc_locks.c
lustre/mds/handler.c
lustre/mds/mds_open.c

index b8df94d..c629386 100644 (file)
@@ -876,11 +876,6 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res,
                                int lock_flags, int cancel_flags, void *opaque);
 int ldlm_cli_cancel_list(struct list_head *head, int count,
                          struct ptlrpc_request *req, int off);
-/* mds/handler.c */
-/* This has to be here because recursive inclusion sucks. */
-int intent_disposition(struct ldlm_reply *rep, int flag);
-void intent_set_disposition(struct ldlm_reply *rep, int flag);
-
 
 /* ioctls for trying requests */
 #define IOC_LDLM_TYPE                   'f'
index 0812a2d..73e7521 100644 (file)
@@ -143,14 +143,43 @@ struct mds_file_data {
 int mds_reint_rec(struct mds_update_record *r, int offset,
                   struct ptlrpc_request *req, struct lustre_handle *);
 
-/* mds/mds_lov.c */
+/* mds/handler.c */
+static int inline ldlm_reply_disposition(struct ldlm_reply *rep, int flag)
+{
+        return (rep ? rep->lock_policy_res1 & flag : 0);
+}
+
+static void inline ldlm_reply_set_disposition(struct ldlm_reply *rep, int flag)
+{
+        if (rep)
+                rep->lock_policy_res1 |= flag;
+}
+
+static void inline ldlm_reply_clear_disposition(struct ldlm_reply *rep,
+                                                int flag)
+{
+        if (rep)
+                rep->lock_policy_res1 &= ~flag;
+}
 
 /* mdc/mdc_locks.c */
 struct md_enqueue_info;
 
-int it_disposition(struct lookup_intent *it, int flag);
-void it_set_disposition(struct lookup_intent *it, int flag);
-void it_clear_disposition(struct lookup_intent *it, int flag);
+static int inline it_disposition(struct lookup_intent *it, int flag)
+{
+        return it->d.lustre.it_disposition & flag;
+}
+
+static void inline it_set_disposition(struct lookup_intent *it, int flag)
+{
+        it->d.lustre.it_disposition |= flag;
+}
+
+static inline void it_clear_disposition(struct lookup_intent *it, int flag)
+{
+        it->d.lustre.it_disposition &= ~flag;
+}
+
 int it_open_error(int phase, struct lookup_intent *it);
 void mdc_set_lock_data(__u64 *lockh, void *data);
 int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid,
index c44fbfe..4fa21eb 100644 (file)
 #include <lprocfs_status.h>
 #include "mdc_internal.h"
 
-int it_disposition(struct lookup_intent *it, int flag)
-{
-        return it->d.lustre.it_disposition & flag;
-}
-EXPORT_SYMBOL(it_disposition);
-
-void it_set_disposition(struct lookup_intent *it, int flag)
-{
-        it->d.lustre.it_disposition |= flag;
-}
-EXPORT_SYMBOL(it_set_disposition);
-
-void it_clear_disposition(struct lookup_intent *it, int flag)
-{
-        it->d.lustre.it_disposition &= ~flag;
-}
-EXPORT_SYMBOL(it_clear_disposition);
-
 int it_open_error(int phase, struct lookup_intent *it)
 {
         if (it_disposition(it, DISP_OPEN_OPEN)) {
index 940e4f8..200ea24 100644 (file)
@@ -1003,7 +1003,7 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset,
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
         cleanup_phase = 1; /* kernel context */
-        intent_set_disposition(rep, DISP_LOOKUP_EXECD);
+        ldlm_reply_set_disposition(rep, DISP_LOOKUP_EXECD);
 
         /* FIXME: handle raw lookup */
 #if 0
@@ -1086,12 +1086,12 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset,
         cleanup_phase = 2; /* dchild, dparent, locks */
 
         if (dchild->d_inode == NULL) {
-                intent_set_disposition(rep, DISP_LOOKUP_NEG);
+                ldlm_reply_set_disposition(rep, DISP_LOOKUP_NEG);
                 /* in the intent case, the policy clears this error:
                    the disposition is enough */
                 GOTO(cleanup, rc = -ENOENT);
         } else {
-                intent_set_disposition(rep, DISP_LOOKUP_POS);
+                ldlm_reply_set_disposition(rep, DISP_LOOKUP_POS);
         }
 
         if (req->rq_repmsg == NULL) {
@@ -2444,20 +2444,6 @@ static void fixup_handle_for_resent_req(struct ptlrpc_request *req, int offset,
                   remote_hdl.cookie);
 }
 
-int intent_disposition(struct ldlm_reply *rep, int flag)
-{
-        if (!rep)
-                return 0;
-        return (rep->lock_policy_res1 & flag);
-}
-
-void intent_set_disposition(struct ldlm_reply *rep, int flag)
-{
-        if (!rep)
-                return;
-        rep->lock_policy_res1 |= flag;
-}
-
 #define IS_CLIENT_DISCONNECT_ERROR(error) \
                 (error == -ENOTCONN || error == -ENODEV)
 
@@ -2518,7 +2504,7 @@ static int mds_intent_policy(struct ldlm_namespace *ns,
                 RETURN(req->rq_status = rc);
 
         rep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF, sizeof(*rep));
-        intent_set_disposition(rep, DISP_IT_EXECD);
+        ldlm_reply_set_disposition(rep, DISP_IT_EXECD);
 
         /* execute policy */
         switch ((long)it->opc) {
@@ -2534,16 +2520,16 @@ static int mds_intent_policy(struct ldlm_namespace *ns,
 #if 0
                 /* We abort the lock if the lookup was negative and
                  * we did not make it to the OPEN portion */
-                if (!intent_disposition(rep, DISP_LOOKUP_EXECD))
+                if (!ldlm_reply_disposition(rep, DISP_LOOKUP_EXECD))
                         RETURN(ELDLM_LOCK_ABORTED);
-                if (intent_disposition(rep, DISP_LOOKUP_NEG) &&
-                    !intent_disposition(rep, DISP_OPEN_OPEN))
+                if (ldlm_reply_disposition(rep, DISP_LOOKUP_NEG) &&
+                    !ldlm_reply_disposition(rep, DISP_OPEN_OPEN))
 #endif
 
                 /* If there was an error of some sort or if we are not
                  * returning any locks */
                  if (rep->lock_policy_res2 ||
-                     !intent_disposition(rep, DISP_OPEN_LOCK)) {
+                     !ldlm_reply_disposition(rep, DISP_OPEN_LOCK)) {
                         /* If it is the disconnect error (ENODEV & ENOCONN)
                          * ptlrpc layer should know this imediately, it should
                          * be replied by rq_stats, otherwise, return it by
@@ -2579,9 +2565,9 @@ static int mds_intent_policy(struct ldlm_namespace *ns,
                    policy_res{1,2} with disposition and status.
                    - replay: returns 0 & req->status is old status
                    - otherwise: returns req->status */
-                if (intent_disposition(rep, DISP_LOOKUP_NEG))
+                if (ldlm_reply_disposition(rep, DISP_LOOKUP_NEG))
                         rep->lock_policy_res2 = 0;
-                if (!intent_disposition(rep, DISP_LOOKUP_POS) ||
+                if (!ldlm_reply_disposition(rep, DISP_LOOKUP_POS) ||
                     rep->lock_policy_res2)
                         RETURN(ELDLM_LOCK_ABORTED);
                 if (req->rq_status != 0) {
index b9bb335..64d5211 100644 (file)
@@ -528,10 +528,10 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
 
         /* copy rc, transno and disp; steal locks */
         mds_req_from_lcd(req, lcd);
-        intent_set_disposition(rep, le32_to_cpu(lcd->lcd_last_data));
+        ldlm_reply_set_disposition(rep, le32_to_cpu(lcd->lcd_last_data));
 
         /* Only replay if create or open actually happened. */
-        if (!intent_disposition(rep, DISP_OPEN_CREATE | DISP_OPEN_OPEN) ) {
+        if (!ldlm_reply_disposition(rep, DISP_OPEN_CREATE | DISP_OPEN_OPEN) ) {
                 EXIT;
                 return; /* error looking up parent or child */
         }
@@ -569,8 +569,8 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
         /* At this point, we know we have a child. We'll send
          * it back _unless_ it not created and open failed.
          */
-        if (intent_disposition(rep, DISP_OPEN_OPEN) &&
-            !intent_disposition(rep, DISP_OPEN_CREATE) &&
+        if (ldlm_reply_disposition(rep, DISP_OPEN_OPEN) &&
+            !ldlm_reply_disposition(rep, DISP_OPEN_CREATE) &&
             req->rq_status) {
                 GOTO(out_dput, 0);
         }
@@ -617,7 +617,7 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
         /* If we didn't get as far as trying to open, then some locking thing
          * probably went wrong, and we'll just bail here.
          */
-        if (!intent_disposition(rep, DISP_OPEN_OPEN))
+        if (!ldlm_reply_disposition(rep, DISP_OPEN_OPEN))
                 GOTO(out_dput, 0);
 
         /* If we failed, then we must have failed opening, so don't look for
@@ -676,14 +676,14 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
 
         mds_mfd_put(mfd);
 
-        if (!intent_disposition(rep, DISP_OPEN_LOCK))
+        if (!ldlm_reply_disposition(rep, DISP_OPEN_LOCK))
                 GOTO(out_dput, 0);
 
         /* child_lockh has been set in fixup_handle_for_resent_req called
          * in mds_intent_policy for resent request */
         if (child_lockh == NULL || !lustre_handle_is_used(child_lockh)) {
                 /* the lock is already canceled! clear DISP_OPEN_LOCK */
-                intent_disposition(rep, ~DISP_OPEN_LOCK);
+                ldlm_reply_clear_disposition(rep, DISP_OPEN_LOCK);
         }
 
  out_dput:
@@ -799,7 +799,7 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild,
         if ((rc = mds_lov_prepare_objids(obd,lmm)) != 0)
                 RETURN(rc);
 
-        intent_set_disposition(rep, DISP_OPEN_OPEN);
+        ldlm_reply_set_disposition(rep, DISP_OPEN_OPEN);
         mfd = mds_dentry_open(dchild, mds->mds_vfsmnt, flags, req);
         if (IS_ERR(mfd))
                 RETURN(PTR_ERR(mfd));
@@ -851,8 +851,8 @@ static int mds_open_by_fid(struct ptlrpc_request *req, struct ll_fid *fid,
 
         mds_pack_inode2fid(&body->fid1, dchild->d_inode);
         mds_pack_inode2body(body, dchild->d_inode);
-        intent_set_disposition(rep, DISP_LOOKUP_EXECD);
-        intent_set_disposition(rep, DISP_LOOKUP_POS);
+        ldlm_reply_set_disposition(rep, DISP_LOOKUP_EXECD);
+        ldlm_reply_set_disposition(rep, DISP_LOOKUP_POS);
 
         rc = mds_finish_open(req, dchild, body, flags, &handle, rec, rep, NULL);
         rc = mds_finish_transno(mds, dchild->d_inode, handle,
@@ -1054,8 +1054,8 @@ int mds_open(struct mds_update_record *rec, int offset,
                 } else {
                         /* Just cannot find parent - make it look like
                          * usual negative lookup to avoid extra MDS RPC */
-                        intent_set_disposition(rep, DISP_LOOKUP_EXECD);
-                        intent_set_disposition(rep, DISP_LOOKUP_NEG);
+                        ldlm_reply_set_disposition(rep, DISP_LOOKUP_EXECD);
+                        ldlm_reply_set_disposition(rep, DISP_LOOKUP_NEG);
                 }
                 GOTO(cleanup, rc);
         }
@@ -1074,11 +1074,11 @@ int mds_open(struct mds_update_record *rec, int offset,
 
         cleanup_phase = 2; /* child dentry */
 
-        intent_set_disposition(rep, DISP_LOOKUP_EXECD);
+        ldlm_reply_set_disposition(rep, DISP_LOOKUP_EXECD);
         if (dchild->d_inode)
-                intent_set_disposition(rep, DISP_LOOKUP_POS);
+                ldlm_reply_set_disposition(rep, DISP_LOOKUP_POS);
         else
-                intent_set_disposition(rep, DISP_LOOKUP_NEG);
+                ldlm_reply_set_disposition(rep, DISP_LOOKUP_NEG);
 
         /*Step 3: If the child was negative, and we're supposed to, create it.*/
         if (dchild->d_inode == NULL) {
@@ -1107,7 +1107,7 @@ int mds_open(struct mds_update_record *rec, int offset,
                                 current->fsuid, gid, 1, &rec_pending,
                                 NULL, NULL, 0);
 
-                intent_set_disposition(rep, DISP_OPEN_CREATE);
+                ldlm_reply_set_disposition(rep, DISP_OPEN_CREATE);
                 handle = fsfilt_start(obd, dparent->d_inode, FSFILT_OP_CREATE,
                                       NULL);
                 if (IS_ERR(handle)) {
@@ -1170,7 +1170,7 @@ int mds_open(struct mds_update_record *rec, int offset,
                 /* for nfs and join - we need two locks for same fid, but
                  * with different mode */
                 if (need_open_lock && !use_parent)  {
-                        intent_set_disposition(rep, DISP_OPEN_LOCK);
+                        ldlm_reply_set_disposition(rep, DISP_OPEN_LOCK);
                         need_open_lock = 0;
                 }
         }
@@ -1226,7 +1226,7 @@ found_child:
                         GOTO(cleanup, rc = -EACCES);
                 }
                 if (ll_permission(dchild->d_inode, acc_mode, NULL)) {
-                        intent_set_disposition(rep, DISP_OPEN_OPEN);
+                        ldlm_reply_set_disposition(rep, DISP_OPEN_OPEN);
                         GOTO(cleanup, rc = -EACCES);
                 }
         } else if (rec->ur_flags & MDS_OPEN_DIRECTORY) {
@@ -1256,7 +1256,7 @@ found_child:
                         GOTO(cleanup, rc);
 
                 /* Let mds_intent_policy know that we have a lock to return */
-                intent_set_disposition(rep, DISP_OPEN_LOCK);
+                ldlm_reply_set_disposition(rep, DISP_OPEN_LOCK);
         }
 
         if (!S_ISREG(dchild->d_inode->i_mode) &&