+ else if (res->lr_type == LDLM_FLOCK) {
+ /* We should not add locks to granted list in the following
+ * cases:
+ * - this is an UNLOCK but not a real lock;
+ * - this is a TEST lock;
+ * - this is a F_CANCELLK lock (async flock has req_mode == 0)
+ * - this is a deadlock (flock cannot be granted) */
+ if (lock->l_req_mode == 0 ||
+ lock->l_req_mode == LCK_NL ||
+ ldlm_is_test_lock(lock) ||
+ ldlm_is_flock_deadlock(lock))
+ RETURN_EXIT;
+ ldlm_resource_add_lock(res, &res->lr_granted, lock);
+ } else {
+ LBUG();
+ }