- * If first_enq is 1 (ie, called from ldlm_lock_enqueue):
- * - blocking ASTs have not been sent
- * - the caller has NOT initialized req->lr_tmp, so we must
- * - must call this function with the resource lock held */
-int ldlm_process_plain_lock(struct ldlm_lock *lock, int *flags, int first_enq,
- ldlm_error_t *err, struct list_head *work_list)
+ * This function looks for any conflicts for \a lock in the granted or
+ * waiting queues. The lock is granted if no conflicts are found in
+ * either queue.
+ */
+int ldlm_process_plain_lock(struct ldlm_lock *lock, __u64 *flags,
+ enum ldlm_process_intention intention,
+ enum ldlm_error *err, struct list_head *work_list)
+{
+ struct ldlm_resource *res = lock->l_resource;
+ struct list_head *grant_work = intention == LDLM_PROCESS_ENQUEUE ?
+ NULL : work_list;
+ int rc;
+
+ ENTRY;
+ LASSERT(!ldlm_is_granted(lock));
+ check_res_locked(res);
+ *err = ELDLM_OK;
+
+ if (intention == LDLM_PROCESS_RESCAN) {
+ LASSERT(work_list != NULL);
+ rc = ldlm_plain_compat_queue(&res->lr_granted, lock, NULL);
+ if (!rc)
+ RETURN(LDLM_ITER_STOP);
+ rc = ldlm_plain_compat_queue(&res->lr_waiting, lock, NULL);
+ if (!rc)
+ RETURN(LDLM_ITER_STOP);
+
+ ldlm_resource_unlink_lock(lock);
+ ldlm_grant_lock(lock, grant_work);
+ RETURN(LDLM_ITER_CONTINUE);
+ }
+
+ rc = ldlm_plain_compat_queue(&res->lr_granted, lock, work_list);
+ rc += ldlm_plain_compat_queue(&res->lr_waiting, lock, work_list);
+
+ if (rc == 2) {
+ ldlm_resource_unlink_lock(lock);
+ ldlm_grant_lock(lock, grant_work);
+ }
+
+ RETURN(LDLM_ITER_CONTINUE);
+}
+#endif /* HAVE_SERVER_SUPPORT */
+
+void ldlm_plain_policy_wire_to_local(const union ldlm_wire_policy_data *wpolicy,
+ union ldlm_policy_data *lpolicy)
+{
+ /* No policy for plain locks */
+}
+
+void ldlm_plain_policy_local_to_wire(const union ldlm_policy_data *lpolicy,
+ union ldlm_wire_policy_data *wpolicy)