Whamcloud - gitweb
LU-5934 mdt: faulty assertion in mdt_intent_reint 79/13179/2
authorLiang Zhen <liang.zhen@intel.com>
Wed, 24 Dec 2014 05:52:43 +0000 (13:52 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 10 Jan 2015 04:39:34 +0000 (04:39 +0000)
mdt_intent_reint() may set lhc::mlh_reg_lh for resent request,
which means lhc::mlh_reg_lh can be a valid lock handle when
processing of resent request failed and assert(rc == 0) is faulty.

Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Change-Id: I65628d6585cfcec94b820ab631bd391fe77186f2
Reviewed-on: http://review.whamcloud.com/13179
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Li Wei <wei.g.li@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_handler.c

index 8b47a57..d8c56b2 100644 (file)
@@ -2367,7 +2367,7 @@ int mdt_check_resent_lock(struct mdt_thread_info *info,
                          struct mdt_lock_handle *lhc)
 {
        /* the lock might already be gotten in ldlm_handle_enqueue() */
-       if (lustre_handle_is_used(&lhc->mlh_reg_lh)) {
+       if (unlikely(lustre_handle_is_used(&lhc->mlh_reg_lh))) {
                struct ptlrpc_request *req = mdt_info_req(info);
                struct ldlm_lock      *lock;
 
@@ -3400,8 +3400,8 @@ static int mdt_intent_reint(enum mdt_it_code opcode,
 
        /* the open lock or the lock for cross-ref object should be
         * returned to the client */
-       if (rc == -MDT_EREMOTE_OPEN || mdt_get_disposition(rep, DISP_OPEN_LOCK)) {
-               LASSERT(lustre_handle_is_used(&lhc->mlh_reg_lh));
+       if (lustre_handle_is_used(&lhc->mlh_reg_lh) &&
+           (rc == 0 || rc == -MDT_EREMOTE_OPEN)) {
                rep->lock_policy_res2 = 0;
                rc = mdt_intent_lock_replace(info, lockp, lhc, flags);
                RETURN(rc);
@@ -3413,6 +3413,7 @@ static int mdt_intent_reint(enum mdt_it_code opcode,
             mdt_get_disposition(rep, DISP_LOOKUP_NEG))
                 rep->lock_policy_res2 = 0;
 
+       lhc->mlh_reg_lh.cookie = 0ull;
         if (rc == -ENOTCONN || rc == -ENODEV ||
             rc == -EOVERFLOW) { /**< if VBR failure then return error */
                 /*
@@ -3421,28 +3422,13 @@ static int mdt_intent_reint(enum mdt_it_code opcode,
                  * will detect this, then disconnect, reconnect the import
                  * immediately, instead of impacting the following the rpc.
                  */
-                lhc->mlh_reg_lh.cookie = 0ull;
                 RETURN(rc);
-        } else {
-                /*
-                 * For other cases, the error will be returned by intent.
-                 * and client will retrieve the result from intent.
-                 */
-                 /*
-                  * FIXME: when open lock is finished, that should be
-                  * checked here.
-                  */
-                if (lustre_handle_is_used(&lhc->mlh_reg_lh)) {
-                        LASSERTF(rc == 0, "Error occurred but lock handle "
-                                 "is still in use, rc = %d\n", rc);
-                        rep->lock_policy_res2 = 0;
-                       rc = mdt_intent_lock_replace(info, lockp, lhc, flags);
-                        RETURN(rc);
-                } else {
-                        lhc->mlh_reg_lh.cookie = 0ull;
-                        RETURN(ELDLM_LOCK_ABORTED);
-                }
         }
+       /*
+        * For other cases, the error will be returned by intent, and client
+        * will retrieve the result from intent.
+        */
+       RETURN(ELDLM_LOCK_ABORTED);
 }
 
 static int mdt_intent_code(long itcode)