- struct list_head *tmp;
- struct ldlm_lock *lock;
- ldlm_mode_t req_mode = req->l_req_mode;
- __u64 req_bits = req->l_policy_data.l_inodebits.bits;
- int compat = 1;
- ENTRY;
-
- LASSERT(req_bits); /* There is no sense in lock with no bits set,
- I think. Also such a lock would be compatible
- with any other bit lock */
-
- list_for_each(tmp, queue) {
- struct list_head *mode_tail;
-
- lock = list_entry(tmp, struct ldlm_lock, l_res_link);
-
- if (req == lock)
- RETURN(compat);
-
- /* last lock in mode group */
- LASSERT(lock->l_sl_mode.prev != NULL);
- mode_tail = &list_entry(lock->l_sl_mode.prev,
- struct ldlm_lock,
- l_sl_mode)->l_res_link;
-
- /* locks are compatible, bits don't matter */
- if (lockmode_compat(lock->l_req_mode, req_mode)) {
- /* jump to last lock in mode group */
- tmp = mode_tail;
- continue;
- }
-
- if (lock->l_req_mode == LCK_COS) {
- if (lock->l_client_cookie == req->l_client_cookie) {
- tmp = mode_tail;
- } else {
- tmp = mode_tail;
- if (!work_list)
- RETURN(0);
- compat = 0;
- if (lock->l_blocking_ast)
- ldlm_add_ast_work_item(lock, req,
- work_list);
- }
- continue;
- }
+ struct list_head *tmp;
+ struct ldlm_lock *lock;
+ __u64 req_bits = req->l_policy_data.l_inodebits.bits;
+ int compat = 1;
+ ENTRY;
+
+ /* There is no sense in lock with no bits set, I think.
+ * Also, such a lock would be compatible with any other bit lock */
+ LASSERT(req_bits != 0);
+
+ list_for_each(tmp, queue) {
+ struct list_head *mode_tail;
+
+ lock = list_entry(tmp, struct ldlm_lock, l_res_link);
+
+ /* We stop walking the queue if we hit ourselves so we don't
+ * take conflicting locks enqueued after us into account,
+ * or we'd wait forever. */
+ if (req == lock)
+ RETURN(compat);