Whamcloud - gitweb
LU-9997 ldlm: check lock cancellation in ldlm_cli_cancel() 80/29080/6
authorJinshan Xiong <jinshan.xiong@intel.com>
Fri, 15 Sep 2017 19:23:58 +0000 (19:23 +0000)
committerJinshan Xiong <jinshan.xiong@intel.com>
Wed, 15 Nov 2017 17:20:58 +0000 (17:20 +0000)
In that case, the assert for 'list_empty(&lock->l_bl_ast)' will fail
because the lock is already in a cancel list.

This patch checks if the lock is already being canceled in prior.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: I04b9df789cf3b3b5e6dd61a647376307f9975f4a
Reviewed-on: https://review.whamcloud.com/29080
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/ldlm/ldlm_internal.h
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_request.c

index e798997..062f12c 100644 (file)
@@ -362,6 +362,19 @@ static inline int is_granted_or_cancelled(struct ldlm_lock *lock)
         return ret;
 }
 
+static inline bool is_bl_done(struct ldlm_lock *lock)
+{
+       bool bl_done = true;
+
+       if (!ldlm_is_bl_done(lock)) {
+               lock_res_and_lock(lock);
+               bl_done = ldlm_is_bl_done(lock);
+               unlock_res_and_lock(lock);
+       }
+
+       return bl_done;
+}
+
 typedef void (*ldlm_policy_wire_to_local_t)(const union ldlm_wire_policy_data *,
                                            union ldlm_policy_data *);
 typedef void (*ldlm_policy_local_to_wire_t)(const union ldlm_policy_data *,
index b7ec3df..93e7960 100644 (file)
@@ -2301,19 +2301,6 @@ void ldlm_reprocess_recovery_done(struct ldlm_namespace *ns)
        EXIT;
 }
 
-static bool is_bl_done(struct ldlm_lock *lock)
-{
-       bool bl_done = true;
-
-       if (!ldlm_is_bl_done(lock)) {
-               lock_res_and_lock(lock);
-               bl_done = ldlm_is_bl_done(lock);
-               unlock_res_and_lock(lock);
-       }
-
-       return bl_done;
-}
-
 /**
  * Helper function to call blocking AST for LDLM lock \a lock in a
  * "cancelling" mode.
index 859568d..d1d068f 100644 (file)
@@ -1392,8 +1392,15 @@ int ldlm_cli_cancel(const struct lustre_handle *lockh,
 
        lock_res_and_lock(lock);
        /* Lock is being canceled and the caller doesn't want to wait */
-       if (ldlm_is_canceling(lock) && (cancel_flags & LCF_ASYNC)) {
-               unlock_res_and_lock(lock);
+       if (ldlm_is_canceling(lock)) {
+               if (cancel_flags & LCF_ASYNC) {
+                       unlock_res_and_lock(lock);
+               } else {
+                       struct l_wait_info lwi = { 0 };
+
+                       unlock_res_and_lock(lock);
+                       l_wait_event(lock->l_waitq, is_bl_done(lock), &lwi);
+               }
                LDLM_LOCK_RELEASE(lock);
                RETURN(0);
        }