- /* before flock's complete ast gets here, the flock
- * can possibly be freed by another thread
- */
- if (lock->l_destroyed) {
- LDLM_DEBUG(lock, "already destroyed by another thread");
- RETURN(0);
+ OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CP_CB_WAIT, 10);
+
+ lock_res_and_lock(lock);
+ if (lock->l_destroyed || lock->l_flags & LDLM_FL_FAILED) {
+ LDLM_DEBUG(lock, "client-side enqueue waking up: destroyed");
+ unlock_res(lock->l_resource);
+ RETURN(-EIO);
+ }
+ if (rc) {
+ LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)",
+ rc);
+ unlock_res_and_lock(lock);
+ RETURN(rc);