-
- /* 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) {
- 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);
- return;
- }
-
- cfs_hash_put(exp->exp_lock_hash, &lock->l_exp_hash);
- }
-
+ /* 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);
+ }
+ }