- LASSERTF(new_lock != NULL,
- "lockh "LPX64"\n", lh->mlh_reg_lh.cookie);
+ 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 "LPX64"\n",
+ lh->mlh_reg_lh.cookie);
+ lh->mlh_reg_lh.cookie = 0;
+ RETURN(-ESTALE);
+ }
+
+ LASSERTF(new_lock != NULL,
+ "lockh "LPX64" flags "LPX64" rc %d\n",
+ lh->mlh_reg_lh.cookie, flags, result);