Whamcloud - gitweb
- unland b_fid to HEAD
[fs/lustre-release.git] / lustre / ldlm / ldlm_plain.c
index a9d7702..9a693e3 100644 (file)
@@ -43,6 +43,8 @@ ldlm_plain_compat_queue(struct list_head *queue, struct ldlm_lock *req,
         int compat = 1;
         ENTRY;
 
+        lockmode_verify(req_mode);
+
         list_for_each(tmp, queue) {
                 lock = list_entry(tmp, struct ldlm_lock, l_res_link);
 
@@ -105,9 +107,13 @@ int ldlm_process_plain_lock(struct ldlm_lock *lock, int *flags, int first_enq,
 
         if (rc != 2) {
                 /* If either of the compat_queue()s returned 0, then we
-                 * have ASTs to send and must go onto the waiting list. */
-                ldlm_resource_unlink_lock(lock);
-                ldlm_resource_add_lock(res, &res->lr_waiting, lock);
+                 * have ASTs to send and must go onto the waiting list.
+                 *
+                 * bug 2322: we used to unlink and re-add here, which was a
+                 * terrible folly -- if we goto restart, we could get
+                 * re-ordered!  Causes deadlock, because ASTs aren't sent! */
+                if (list_empty(&lock->l_res_link))
+                        ldlm_resource_add_lock(res, &res->lr_waiting, lock);
                 l_unlock(&res->lr_namespace->ns_lock);
                 rc = ldlm_run_ast_work(res->lr_namespace, &rpc_list);
                 l_lock(&res->lr_namespace->ns_lock);