Whamcloud - gitweb
LU-2177 ldlm: flock completion fixes.
[fs/lustre-release.git] / lustre / ldlm / ldlm_request.c
index d01c9d6..44b9676 100644 (file)
@@ -504,20 +504,23 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns,
         else
                 LDLM_DEBUG(lock, "lock was granted or failed in race");
 
-        ldlm_lock_decref_internal(lock, mode);
-
-        /* XXX - HACK because we shouldn't call ldlm_lock_destroy()
-         *       from llite/file.c/ll_file_flock(). */
-        /* This code makes for the fact that we do not have blocking handler on
-         * a client for flock locks. As such this is the place where we must
-         * completely kill failed locks. (interrupted and those that
-         * were waiting to be granted when server evicted us. */
-        if (lock->l_resource->lr_type == LDLM_FLOCK) {
-                lock_res_and_lock(lock);
-                ldlm_resource_unlink_lock(lock);
-                ldlm_lock_destroy_nolock(lock);
-                unlock_res_and_lock(lock);
-        }
+       /* XXX - HACK because we shouldn't call ldlm_lock_destroy()
+        *       from llite/file.c/ll_file_flock(). */
+       /* This code makes for the fact that we do not have blocking handler on
+        * a client for flock locks. As such this is the place where we must
+        * completely kill failed locks. (interrupted and those that
+        * were waiting to be granted when server evicted us. */
+       if (lock->l_resource->lr_type == LDLM_FLOCK) {
+               lock_res_and_lock(lock);
+               if (!ldlm_is_destroyed(lock)) {
+                       ldlm_resource_unlink_lock(lock);
+                       ldlm_lock_decref_internal_nolock(lock, mode);
+                       ldlm_lock_destroy_nolock(lock);
+               }
+               unlock_res_and_lock(lock);
+       } else {
+               ldlm_lock_decref_internal(lock, mode);
+       }
 }
 
 /**
@@ -605,10 +608,6 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
        *flags = ldlm_flags_from_wire(reply->lock_flags);
        lock->l_flags |= ldlm_flags_from_wire(reply->lock_flags &
                                              LDLM_FL_INHERIT_MASK);
-        /* move NO_TIMEOUT flag to the lock to force ldlm_lock_match()
-         * to wait with no timeout as well */
-       lock->l_flags |= ldlm_flags_from_wire(reply->lock_flags &
-                                             LDLM_FL_NO_TIMEOUT);
         unlock_res_and_lock(lock);
 
        CDEBUG(D_INFO, "local: %p, remote cookie: "LPX64", flags: "LPX64"\n",