Whamcloud - gitweb
LU-5369 mdt: check lock handle instead assert 05/44905/4
authorYang Sheng <ys@whamcloud.com>
Mon, 13 Sep 2021 21:04:00 +0000 (05:04 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 22 Sep 2021 04:41:29 +0000 (04:41 +0000)
The lock handle could be NULL inn some corner case.
We should check it instead of LBUG.

Signed-off-by: Yang Sheng <ys@whamcloud.com>
Change-Id: I1afa7f8c129c104b012ae23141318365c388c503
Reviewed-on: https://review.whamcloud.com/44905
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/mdt/mdt_handler.c

index 7f54b59..9181c9a 100644 (file)
@@ -4254,25 +4254,29 @@ int mdt_intent_lock_replace(struct mdt_thread_info *info,
        /* If possible resent found a lock, @lh is set to its handle */
        new_lock = ldlm_handle2lock_long(&lh->mlh_reg_lh, 0);
 
-        if (new_lock == NULL && (flags & LDLM_FL_INTENT_ONLY)) {
-                lh->mlh_reg_lh.cookie = 0;
-                RETURN(0);
-        }
-
-       if (new_lock == NULL && (flags & LDLM_FL_RESENT)) {
-               /* Lock is pinned by ldlm_handle_enqueue0() as it is
-                * a resend case, however, it could be already destroyed
-                * due to client eviction or a raced cancel RPC. */
-               LDLM_DEBUG_NOLOCK("Invalid lock handle %#llx\n",
-                                 lh->mlh_reg_lh.cookie);
+       if (new_lock == NULL) {
+               if (flags & LDLM_FL_INTENT_ONLY) {
+                       result = 0;
+               } else if (flags & LDLM_FL_RESENT) {
+                       /* Lock is pinned by ldlm_handle_enqueue0() as it is a
+                        * resend case, however, it could be already destroyed
+                        * due to client eviction or a raced cancel RPC.
+                        */
+                       LDLM_DEBUG_NOLOCK("Invalid lock handle %#llx\n",
+                                         lh->mlh_reg_lh.cookie);
+                       result = -ESTALE;
+               } else {
+                       CERROR("%s: Invalid lockh=%#llx flags=%#llx fid1="DFID" fid2="DFID": rc = %d\n",
+                              mdt_obd_name(info->mti_mdt),
+                              lh->mlh_reg_lh.cookie, flags,
+                              PFID(&info->mti_tmp_fid1),
+                              PFID(&info->mti_tmp_fid2), result);
+                       result = -ESTALE;
+               }
                lh->mlh_reg_lh.cookie = 0;
-               RETURN(-ESTALE);
+               RETURN(result);
        }
 
-       LASSERTF(new_lock != NULL,
-                "lockh %#llx flags %#llx : rc = %d\n",
-                lh->mlh_reg_lh.cookie, flags, result);
-
         /*
          * If we've already given this lock to a client once, then we should
          * have no readers or writers.  Otherwise, we should have one reader