- restart:
- rc = ldlm_inodebits_compat_queue(&res->lr_granted, lock, &rpc_list);
- rc += ldlm_inodebits_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);
+ LASSERT((intention == LDLM_PROCESS_ENQUEUE && work_list == NULL) ||
+ (intention == LDLM_PROCESS_RECOVERY && work_list != NULL));
+restart:
+ rc = ldlm_inodebits_compat_queue(&res->lr_granted, lock, &rpc_list);
+ rc += ldlm_inodebits_compat_queue(&res->lr_waiting, lock, &rpc_list);
+
+ if (rc != 2) {
+ /* if there were only bits to try and all are conflicting */
+ if ((lock->l_policy_data.l_inodebits.bits |
+ lock->l_policy_data.l_inodebits.try_bits) == 0) {
+ rc = ELDLM_LOCK_WOULDBLOCK;
+ } else {
+ rc = ldlm_handle_conflict_lock(lock, flags,
+ &rpc_list, 0);
+ if (rc == -ERESTART)
+ GOTO(restart, rc);