From: Yang Sheng Date: Mon, 13 Sep 2021 21:04:00 +0000 (+0800) Subject: LU-5369 mdt: check lock handle instead assert X-Git-Tag: 2.14.55~29 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=5e4411e99cd7d0ccf4e51fac1442673844626639 LU-5369 mdt: check lock handle instead assert The lock handle could be NULL inn some corner case. We should check it instead of LBUG. Signed-off-by: Yang Sheng Change-Id: I1afa7f8c129c104b012ae23141318365c388c503 Reviewed-on: https://review.whamcloud.com/44905 Reviewed-by: Andreas Dilger Tested-by: jenkins Reviewed-by: Mike Pershin Tested-by: Maloo --- diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 7f54b59..9181c9a 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -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