Whamcloud - gitweb
LU-1222 ldlm: Fix the race in AST sender vs multiple arriving RPCs
[fs/lustre-release.git] / lustre / ldlm / ldlm_lockd.c
index dfac3e8..558eee3 100644 (file)
@@ -29,8 +29,7 @@
  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011 Whamcloud, Inc.
- *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -180,13 +179,15 @@ static int expired_lock_main(void *arg)
 
                 cfs_spin_lock_bh(&waiting_locks_spinlock);
                 if (expired_lock_thread.elt_dump) {
+                        struct libcfs_debug_msg_data msgdata = {
+                                .msg_file = __FILE__,
+                                .msg_fn = "waiting_locks_callback",
+                                .msg_line = expired_lock_thread.elt_dump };
                         cfs_spin_unlock_bh(&waiting_locks_spinlock);
 
                         /* from waiting_locks_callback, but not in timer */
                         libcfs_debug_dumplog();
-                        libcfs_run_lbug_upcall(__FILE__,
-                                                "waiting_locks_callback",
-                                                expired_lock_thread.elt_dump);
+                        libcfs_run_lbug_upcall(&msgdata);
 
                         cfs_spin_lock_bh(&waiting_locks_spinlock);
                         expired_lock_thread.elt_dump = 0;
@@ -666,7 +667,6 @@ static int ldlm_cb_interpret(const struct lu_env *env,
         struct ldlm_cb_async_args *ca   = data;
         struct ldlm_lock          *lock = ca->ca_lock;
         struct ldlm_cb_set_arg    *arg  = ca->ca_set_arg;
-        int count;
         ENTRY;
 
         LASSERT(lock != NULL);
@@ -679,11 +679,10 @@ static int ldlm_cb_interpret(const struct lu_env *env,
         }
         LDLM_LOCK_RELEASE(lock);
 
-        count = cfs_atomic_dec_return(&arg->rpcs);
-        if (count < arg->threshold)
+        if (cfs_atomic_dec_return(&arg->rpcs) < arg->threshold)
                 cfs_waitq_signal(&arg->waitq);
-        if (count == 0)
-                ldlm_csa_put(arg);
+
+        ldlm_csa_put(arg);
         RETURN(0);
 }
 
@@ -702,8 +701,8 @@ static inline int ldlm_bl_and_cp_ast_tail(struct ptlrpc_request *req,
                         cfs_atomic_inc(&arg->restart);
         } else {
                 LDLM_LOCK_GET(lock);
-                if (cfs_atomic_inc_return(&arg->rpcs) == 1)
-                        cfs_atomic_inc(&arg->refcount);
+                cfs_atomic_inc(&arg->rpcs);
+                cfs_atomic_inc(&arg->refcount);
                 ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1);
         }