- remote_hdl = dlmreq->lock_handle[0];
- /* If the client does not require open lock, it does not need to
- * search lock in exp_lock_hash, since the server thread will
- * make sure the lock will be released, and the resend request
- * can always re-enqueue the lock */
- if ((opcode != MDT_IT_OPEN) || (opcode == MDT_IT_OPEN &&
- info->mti_spec.sp_cr_flags & MDS_OPEN_LOCK)) {
- /* In the function below, .hs_keycmp resolves to
- * ldlm_export_lock_keycmp() */
- /* coverity[overrun-buffer-val] */
- lock = cfs_hash_lookup(exp->exp_lock_hash, &remote_hdl);
- if (lock) {
- lock_res_and_lock(lock);
- if (lock != new_lock) {
- lh->mlh_reg_lh.cookie = lock->l_handle.h_cookie;
- lh->mlh_reg_mode = lock->l_granted_mode;
-
- LDLM_DEBUG(lock, "Restoring lock cookie");
- DEBUG_REQ(D_DLMTRACE, req,
- "restoring lock cookie "LPX64,
- lh->mlh_reg_lh.cookie);
- if (old_lock)
- *old_lock = LDLM_LOCK_GET(lock);
- cfs_hash_put(exp->exp_lock_hash,
- &lock->l_exp_hash);
- unlock_res_and_lock(lock);
- return;
- }
- cfs_hash_put(exp->exp_lock_hash, &lock->l_exp_hash);
- unlock_res_and_lock(lock);
- }
+
+ /* Check if this is a resend case (MSG_RESENT is set on RPC) and a
+ * lock was found by ldlm_handle_enqueue(); if so @lh must be
+ * initialized. */
+ if (flags & LDLM_FL_RESENT) {
+ lh->mlh_reg_lh.cookie = new_lock->l_handle.h_cookie;
+ lh->mlh_reg_mode = new_lock->l_granted_mode;
+
+ LDLM_DEBUG(new_lock, "Restoring lock cookie");
+ DEBUG_REQ(D_DLMTRACE, req, "restoring lock cookie "LPX64,
+ lh->mlh_reg_lh.cookie);
+ return;