Whamcloud - gitweb
LU-12616 obclass: fix MDS start/stop race
[fs/lustre-release.git] / lustre / ldlm / ldlm_request.c
index bfbf599..54100d7 100644 (file)
@@ -150,6 +150,19 @@ int ldlm_expired_completion_wait(void *data)
        RETURN(0);
 }
 
+int is_granted_or_cancelled_nolock(struct ldlm_lock *lock)
+{
+       int ret = 0;
+
+       check_res_locked(lock->l_resource);
+       if (ldlm_is_granted(lock) && !ldlm_is_cp_reqd(lock))
+               ret = 1;
+       else if (ldlm_is_failed(lock) || ldlm_is_cancel(lock))
+               ret = 1;
+       return ret;
+}
+EXPORT_SYMBOL(is_granted_or_cancelled_nolock);
+
 /**
  * Calculate the Completion timeout (covering enqueue, BL AST, data flush,
  * lock cancel, and their replies). Used for lock completion timeout on the
@@ -226,7 +239,7 @@ int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data)
 
        LDLM_DEBUG(lock,
                   "client-side enqueue returned a blocked lock, going forward");
-       ldlm_reprocess_all(lock->l_resource);
+       ldlm_reprocess_all(lock->l_resource, NULL);
        RETURN(0);
 }
 EXPORT_SYMBOL(ldlm_completion_ast_async);
@@ -1336,7 +1349,7 @@ static __u64 ldlm_cli_cancel_local(struct ldlm_lock *lock)
                }
                LDLM_DEBUG(lock, "server-side local cancel");
                ldlm_lock_cancel(lock);
-               ldlm_reprocess_all(lock->l_resource);
+               ldlm_reprocess_all(lock->l_resource, lock);
        }
 
        RETURN(rc);
@@ -1675,8 +1688,7 @@ int ldlm_cli_cancel_list_local(struct list_head *cancels, int count,
                 */
                if (!(cancel_flags & LCF_BL_AST) && (rc == LDLM_FL_BL_AST)) {
                        LDLM_DEBUG(lock, "Cancel lock separately");
-                       list_del_init(&lock->l_bl_ast);
-                       list_add(&lock->l_bl_ast, &head);
+                       list_move(&lock->l_bl_ast, &head);
                        bl_ast++;
                        continue;
                }
@@ -2179,12 +2191,19 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res,
                /*
                 * If policy is given and this is IBITS lock, add to list only
                 * those locks that match by policy.
-                * Skip locks with DoM bit always to don't flush data.
                 */
-               if (policy && (lock->l_resource->lr_type == LDLM_IBITS) &&
-                   (!(lock->l_policy_data.l_inodebits.bits &
-                     policy->l_inodebits.bits) || ldlm_has_dom(lock)))
-                       continue;
+               if (policy && (lock->l_resource->lr_type == LDLM_IBITS)) {
+                       if (!(lock->l_policy_data.l_inodebits.bits &
+                             policy->l_inodebits.bits))
+                               continue;
+                       /* Skip locks with DoM bit if it is not set in policy
+                        * to don't flush data by side-bits. Lock convert will
+                        * drop those bits separately.
+                        */
+                       if (ldlm_has_dom(lock) &&
+                           !(policy->l_inodebits.bits & MDS_INODELOCK_DOM))
+                               continue;
+               }
 
                /* See CBPENDING comment in ldlm_cancel_lru */
                lock->l_flags |= LDLM_FL_CBPENDING | LDLM_FL_CANCELING |