Whamcloud - gitweb
LU-6142 ldlm: use list_for_each_entry in ldlm_lock.c 34/49734/4
authorMr. NeilBrown <neilb@suse.de>
Mon, 23 Jan 2023 21:24:59 +0000 (16:24 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 Feb 2023 06:26:05 +0000 (06:26 +0000)
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 <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49734
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ldlm/ldlm_lock.c

index 4018722..f1d2868 100644 (file)
@@ -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,