Whamcloud - gitweb
LU-2927 mdt: Not return -EREMOTE for open lock.
authorwangdi <di.wang@whamcloud.com>
Sat, 28 Dec 2013 04:10:57 +0000 (20:10 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 25 Mar 2013 01:58:53 +0000 (21:58 -0400)
Instead of returning -EREMOTE for open_lock, it will check
the open lock by the DISP_OPEN_LOCK, otherwise it will cause
transno being wrongly set to 0.

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: I4f3bccea87872ca191b0b6c2142e8897be3d731a
Reviewed-on: http://review.whamcloud.com/5694
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_open.c

index f7ed271..ba3f24d 100644 (file)
@@ -3788,14 +3788,16 @@ static int mdt_intent_reint(enum mdt_it_code opcode,
         if (rc != 0)
                 mdt_set_disposition(info, rep, DISP_LOOKUP_EXECD);
 
         if (rc != 0)
                 mdt_set_disposition(info, rep, DISP_LOOKUP_EXECD);
 
-        /* Cross-ref case, the lock should be returned to the client */
-        if (rc == -EREMOTE) {
-                LASSERT(lustre_handle_is_used(&lhc->mlh_reg_lh));
-                rep->lock_policy_res2 = 0;
-                rc = mdt_intent_lock_replace(info, lockp, NULL, lhc, flags);
-                RETURN(rc);
-        }
-        rep->lock_policy_res2 = clear_serious(rc);
+       /* the open lock or the lock for cross-ref object should be
+        * returned to the client */
+       if (rc == -EREMOTE || mdt_get_disposition(rep, DISP_OPEN_LOCK)) {
+               LASSERT(lustre_handle_is_used(&lhc->mlh_reg_lh));
+               rep->lock_policy_res2 = 0;
+               rc = mdt_intent_lock_replace(info, lockp, NULL, lhc, flags);
+               RETURN(rc);
+       }
+
+       rep->lock_policy_res2 = clear_serious(rc);
 
         if (rep->lock_policy_res2 == -ENOENT &&
             mdt_get_disposition(rep, DISP_LOOKUP_NEG))
 
         if (rep->lock_policy_res2 == -ENOENT &&
             mdt_get_disposition(rep, DISP_LOOKUP_NEG))
index cd14179..e1717dd 100644 (file)
@@ -838,9 +838,13 @@ int mdt_finish_open(struct mdt_thread_info *info,
         * that looks like it was actually almost succesful and a failure at the
         * same time */
        if (OBD_FAIL_CHECK(OBD_FAIL_MDS_NEGATIVE_POSITIVE)) {
         * that looks like it was actually almost succesful and a failure at the
         * same time */
        if (OBD_FAIL_CHECK(OBD_FAIL_MDS_NEGATIVE_POSITIVE)) {
-               mdt_set_disposition(info, rep, DISP_OPEN_LOCK | \
-                                   DISP_OPEN_OPEN | DISP_LOOKUP_NEG | \
-                                   DISP_LOOKUP_POS);
+               mdt_set_disposition(info, rep, DISP_OPEN_OPEN |
+                                              DISP_LOOKUP_NEG |
+                                              DISP_LOOKUP_POS);
+
+               if (flags & MDS_OPEN_LOCK)
+                       mdt_set_disposition(info, rep, DISP_OPEN_LOCK);
+
                RETURN(-ENOENT);
        }
 
                RETURN(-ENOENT);
        }
 
@@ -1252,8 +1256,14 @@ static void mdt_object_open_unlock(struct mdt_thread_info *info,
                 * if open or layout lock is granted. */
                rc = 1;
        }
                 * if open or layout lock is granted. */
                rc = 1;
        }
-       if (rc != 0)
+
+       if (rc != 0) {
+               struct ldlm_reply       *ldlm_rep;
+
+               ldlm_rep = req_capsule_server_get(info->mti_pill, &RMF_DLM_REP);
+               mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_LOCK);
                mdt_object_unlock(info, obj, lhc, 1);
                mdt_object_unlock(info, obj, lhc, 1);
+       }
 }
 
 int mdt_open_by_fid_lock(struct mdt_thread_info *info, struct ldlm_reply *rep,
 }
 
 int mdt_open_by_fid_lock(struct mdt_thread_info *info, struct ldlm_reply *rep,
@@ -1679,12 +1689,10 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
        /* get openlock if this is not replay and if a client requested it */
        if (!req_is_replay(req)) {
                rc = mdt_object_open_lock(info, child, lhc, &ibits);
        /* get openlock if this is not replay and if a client requested it */
        if (!req_is_replay(req)) {
                rc = mdt_object_open_lock(info, child, lhc, &ibits);
-               if (rc != 0) {
+               if (rc != 0)
                        GOTO(out_child, result = rc);
                        GOTO(out_child, result = rc);
-               } else if (create_flags & MDS_OPEN_LOCK) {
-                       result = -EREMOTE;
+               else if (create_flags & MDS_OPEN_LOCK)
                        mdt_set_disposition(info, ldlm_rep, DISP_OPEN_LOCK);
                        mdt_set_disposition(info, ldlm_rep, DISP_OPEN_LOCK);
-               }
        }
 
        /* Try to open it now. */
        }
 
        /* Try to open it now. */
@@ -1704,7 +1712,9 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
                                        lname,
                                        &info->mti_attr, 0);
                        if (rc != 0)
                                        lname,
                                        &info->mti_attr, 0);
                        if (rc != 0)
-                               CERROR("Error in cleanup of open\n");
+                               CERROR("%s: "DFID" cleanup of open: rc = %d\n",
+                                      mdt_obd_name(info->mti_mdt),
+                                      PFID(mdt_object_fid(child)), rc);
                        mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_CREATE);
                }
        }
                        mdt_clear_disposition(info, ldlm_rep, DISP_OPEN_CREATE);
                }
        }
@@ -1715,9 +1725,9 @@ out_child:
 out_parent:
         mdt_object_unlock_put(info, parent, lh, result || !created);
 out:
 out_parent:
         mdt_object_unlock_put(info, parent, lh, result || !created);
 out:
-        if (result && result != -EREMOTE)
-                lustre_msg_set_transno(req->rq_repmsg, 0);
-        return result;
+       if (result)
+               lustre_msg_set_transno(req->rq_repmsg, 0);
+       return result;
 }
 
 #define MFD_CLOSED(mode) (((mode) & ~(MDS_FMODE_EPOCH | MDS_FMODE_SOM | \
 }
 
 #define MFD_CLOSED(mode) (((mode) & ~(MDS_FMODE_EPOCH | MDS_FMODE_SOM | \