From 685fb4b17fd3e34817f47457d1b7f6d629a1a7fc Mon Sep 17 00:00:00 2001 From: "Mr. NeilBrown" Date: Mon, 23 Jan 2023 16:24:59 -0500 Subject: [PATCH] LU-6142 ldlm: use list_for_each_entry in ldlm_lock.c This makes some slightly-confusing code a bit clearer, and avoids the need for 'tmp'. Linux-commit: 557d001aa51fd6171d7a68dec21f8327fc824173 Change-Id: If9d070492e0016fa235fb38726f7c7a3b380d580 Signed-off-by: Mr. NeilBrown Signed-off-by: Greg Kroah-Hartman Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49734 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Shaun Tancheff Reviewed-by: Jian Yu Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- lustre/ldlm/ldlm_lock.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 4018722..f1d2868 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -973,19 +973,16 @@ static void search_granted_lock(struct list_head *queue, struct ldlm_lock *req, struct sl_insert_point *prev) { - struct list_head *tmp; - struct ldlm_lock *lock, *mode_end, *policy_end; - ENTRY; - - list_for_each(tmp, queue) { - lock = list_entry(tmp, struct ldlm_lock, l_res_link); + struct ldlm_lock *lock, *mode_end, *policy_end; + ENTRY; + list_for_each_entry(lock, queue, l_res_link) { mode_end = list_entry(lock->l_sl_mode.prev, - struct ldlm_lock, l_sl_mode); + struct ldlm_lock, l_sl_mode); if (lock->l_req_mode != req->l_req_mode) { /* jump to last lock of mode group */ - tmp = &mode_end->l_res_link; + lock = mode_end; continue; } @@ -1023,9 +1020,7 @@ static void search_granted_lock(struct list_head *queue, break; /* go to next policy group within mode group */ - tmp = policy_end->l_res_link.next; - lock = list_entry(tmp, struct ldlm_lock, - l_res_link); + lock = list_next_entry(policy_end, l_res_link); } /* loop over policy groups within the mode group */ /* insert point is last lock of the mode group, -- 1.8.3.1