if (req == lock)
RETURN(compat);
- if (lockmode_compat(lock->l_req_mode, req_mode)) {
- /* jump to next mode group */
- if (LDLM_SL_HEAD(&lock->l_sl_mode))
- tmp = &list_entry(lock->l_sl_mode.next,
- struct ldlm_lock,
- l_sl_mode)->l_res_link;
+ /* last lock in mode group */
+ tmp = &list_entry(lock->l_sl_mode.prev,
+ struct ldlm_lock,
+ l_sl_mode)->l_res_link;
+
+ if (lockmode_compat(lock->l_req_mode, req_mode))
continue;
- }
if (!work_list)
RETURN(0);
compat = 0;
+
+ /* add locks of the mode group to @work_list as
+ * blocking locks for @req */
if (lock->l_blocking_ast)
ldlm_add_ast_work_item(lock, req, work_list);
- if (LDLM_SL_HEAD(&lock->l_sl_mode)) {
- /* add all members of the mode group */
- do {
- tmp = lock->l_res_link.next;
- lock = list_entry(tmp, struct ldlm_lock,
- l_res_link);
+ {
+ struct list_head *head;
+
+ head = &lock->l_sl_mode;
+ list_for_each_entry(lock, head, l_sl_mode)
if (lock->l_blocking_ast)
- ldlm_add_ast_work_item(
- lock, req, work_list);
- } while (!LDLM_SL_TAIL(&lock->l_sl_mode));
+ ldlm_add_ast_work_item(lock, req,
+ work_list);
}
}
/* If first_enq is 0 (ie, called from ldlm_reprocess_queue):
* - blocking ASTs have already been sent
- * - the caller has already initialized req->lr_tmp
* - must call this function with the resource lock held
*
* 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)
{
struct ldlm_resource *res = lock->l_resource;
- struct list_head rpc_list = CFS_LIST_HEAD_INIT(rpc_list);
+ CFS_LIST_HEAD(rpc_list);
int rc;
ENTRY;
if (list_empty(&lock->l_res_link))
ldlm_resource_add_lock(res, &res->lr_waiting, lock);
unlock_res(res);
- rc = ldlm_run_bl_ast_work(&rpc_list);
+ rc = ldlm_run_ast_work(&rpc_list, LDLM_WORK_BL_AST);
lock_res(res);
if (rc == -ERESTART)
GOTO(restart, -ERESTART);