- restart:
- rc = ldlm_plain_compat_queue(&res->lr_granted, lock, &rpc_list);
- rc += ldlm_plain_compat_queue(&res->lr_waiting, lock, &rpc_list);
-
- 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.
- *
- * 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);
- unlock_res(res);
- rc = ldlm_run_ast_work(ldlm_res_to_ns(res), &rpc_list,
- LDLM_WORK_BL_AST);
- lock_res(res);
- if (rc == -ERESTART) {
- /* We were granted while waiting, nothing left to do */
- if (lock->l_granted_mode == lock->l_req_mode)
- GOTO(out, rc = 0);
- /* Lock was destroyed while we were waiting, abort */
- if (ldlm_is_destroyed(lock))
- GOTO(out, rc = -EAGAIN);
-
- /* Otherwise try again */
- GOTO(restart, rc);
- }
- *flags |= LDLM_FL_BLOCK_GRANTED;
- } else {
- ldlm_resource_unlink_lock(lock);
- ldlm_grant_lock(lock, NULL);
- }
+ rc = ldlm_plain_compat_queue(&res->lr_granted, lock, work_list);
+ rc += ldlm_plain_compat_queue(&res->lr_waiting, lock, work_list);