Whamcloud - gitweb
LU-6142 ldlm: minor list_entry improvements in ldlm_request.c 38/49738/3
authorMr. NeilBrown <neilb@suse.de>
Mon, 23 Jan 2023 21:51:18 +0000 (16:51 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 Feb 2023 06:26:14 +0000 (06:26 +0000)
Small clarify improvements, and one local variable avoided.

Linux-commit: cb830bef04f1bd80da7eca3d3edaea590f4b350b

Change-Id: I1a34849adca228a465a2b771fb0aa707a9283c7c
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/+/49738
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ldlm/ldlm_request.c

index a51e555..a6f4a75 100644 (file)
@@ -2178,8 +2178,7 @@ int ldlm_cli_cancel_list(struct list_head *cancels, int count,
         */
        while (count > 0) {
                LASSERT(!list_empty(cancels));
-               lock = list_entry(cancels->next, struct ldlm_lock,
-                                 l_bl_ast);
+               lock = list_first_entry(cancels, struct ldlm_lock, l_bl_ast);
                LASSERT(lock->l_conn_export);
 
                if (exp_connect_cancelset(lock->l_conn_export)) {
@@ -2305,26 +2304,21 @@ int ldlm_cli_cancel_unused(struct ldlm_namespace *ns,
 int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter,
                          void *closure)
 {
-       struct list_head *tmp, *next;
+       struct ldlm_lock *tmp;
        struct ldlm_lock *lock;
        int rc = LDLM_ITER_CONTINUE;
 
        ENTRY;
-
        if (!res)
                RETURN(LDLM_ITER_CONTINUE);
 
        lock_res(res);
-       list_for_each_safe(tmp, next, &res->lr_granted) {
-               lock = list_entry(tmp, struct ldlm_lock, l_res_link);
-
+       list_for_each_entry_safe(lock, tmp, &res->lr_granted, l_res_link) {
                if (iter(lock, closure) == LDLM_ITER_STOP)
                        GOTO(out, rc = LDLM_ITER_STOP);
        }
 
-       list_for_each_safe(tmp, next, &res->lr_waiting) {
-               lock = list_entry(tmp, struct ldlm_lock, l_res_link);
-
+       list_for_each_entry_safe(lock, tmp, &res->lr_waiting, l_res_link) {
                if (iter(lock, closure) == LDLM_ITER_STOP)
                        GOTO(out, rc = LDLM_ITER_STOP);
        }