Whamcloud - gitweb
LU-11102 ldlm: don't skip bl_ast for local lock
[fs/lustre-release.git] / lustre / ldlm / ldlm_inodebits.c
index 269c49a..fd1c62c 100644 (file)
@@ -57,6 +57,7 @@
 #include "ldlm_internal.h"
 
 #ifdef HAVE_SERVER_SUPPORT
+
 /**
  * Determine if the lock is compatible with all locks on the queue.
  *
@@ -325,7 +326,7 @@ int ldlm_inodebits_drop(struct ldlm_lock *lock, __u64 to_drop)
 
        /* Just return if there are no conflicting bits */
        if ((lock->l_policy_data.l_inodebits.bits & to_drop) == 0) {
-               LDLM_WARN(lock, "try to drop unset bits %#llx/%#llx\n",
+               LDLM_WARN(lock, "try to drop unset bits %#llx/%#llx",
                          lock->l_policy_data.l_inodebits.bits, to_drop);
                /* nothing to do */
                RETURN(0);
@@ -356,13 +357,19 @@ int ldlm_cli_dropbits(struct ldlm_lock *lock, __u64 drop_bits)
 
        ldlm_lock2handle(lock, &lockh);
        lock_res_and_lock(lock);
-       /* check if all bits are cancelled */
+       /* check if all bits are blocked */
        if (!(lock->l_policy_data.l_inodebits.bits & ~drop_bits)) {
                unlock_res_and_lock(lock);
                /* return error to continue with cancel */
                GOTO(exit, rc = -EINVAL);
        }
 
+       /* check if no common bits, consider this as successful convert */
+       if (!(lock->l_policy_data.l_inodebits.bits & drop_bits)) {
+               unlock_res_and_lock(lock);
+               GOTO(exit, rc = 0);
+       }
+
        /* check if there is race with cancel */
        if (ldlm_is_canceling(lock) || ldlm_is_cancel(lock)) {
                unlock_res_and_lock(lock);
@@ -408,11 +415,12 @@ int ldlm_cli_dropbits(struct ldlm_lock *lock, __u64 drop_bits)
        rc = ldlm_cli_convert(lock, &flags);
        if (rc) {
                lock_res_and_lock(lock);
-               ldlm_clear_converting(lock);
-               ldlm_set_cbpending(lock);
-               ldlm_set_bl_ast(lock);
+               if (ldlm_is_converting(lock)) {
+                       ldlm_clear_converting(lock);
+                       ldlm_set_cbpending(lock);
+                       ldlm_set_bl_ast(lock);
+               }
                unlock_res_and_lock(lock);
-               LASSERT(list_empty(&lock->l_lru));
                GOTO(exit, rc);
        }
        EXIT;