Whamcloud - gitweb
LU-6142 ldlm: use list_for_each_entry in ldlm_resource.c 39/49739/2
authorMr. NeilBrown <neilb@suse.de>
Mon, 23 Jan 2023 21:55:55 +0000 (16:55 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 3 Feb 2023 06:49:26 +0000 (06:49 +0000)
Having a stand-alone "list_entry()" call is often a sign
that something like "list_for_each_entry()" would
make the code clearer.

Linux-commit: 5eb50608ed0fa076d2783898055fb20934a3828c

Change-Id: I5abd6cc7ec0abd31acc55f5af58f440c4f7609a7
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/+/49739
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ldlm/ldlm_resource.c

index 1616cb2..155406e 100644 (file)
@@ -1026,25 +1026,22 @@ EXPORT_SYMBOL(ldlm_namespace_new);
  * locks with refs.
  */
 static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
-                            __u64 flags)
+                            u64 flags)
 {
-       struct list_head *tmp;
        int rc = 0, client = ns_is_client(ldlm_res_to_ns(res));
        bool local_only = !!(flags & LDLM_FL_LOCAL_ONLY);
 
        do {
-               struct ldlm_lock *lock = NULL;
+               struct ldlm_lock *lock = NULL, *tmp;
 
                /* First, we look for non-cleaned-yet lock
                 * all cleaned locks are marked by CLEANED flag. */
                lock_res(res);
-               list_for_each(tmp, q) {
-                       lock = list_entry(tmp, struct ldlm_lock,
-                                         l_res_link);
-                       if (ldlm_is_cleaned(lock)) {
-                               lock = NULL;
+               list_for_each_entry(tmp, q, l_res_link) {
+                       if (ldlm_is_cleaned(tmp))
                                continue;
-                       }
+
+                       lock = tmp;
                        LDLM_LOCK_GET(lock);
                        ldlm_set_cleaned(lock);
                        break;
@@ -1725,19 +1722,15 @@ void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc)
  */
 void ldlm_dump_all_namespaces(enum ldlm_side client, int level)
 {
-       struct list_head *tmp;
+       struct ldlm_namespace *ns;
 
        if (!((libcfs_debug | D_ERROR) & level))
                return;
 
        mutex_lock(ldlm_namespace_lock(client));
 
-       list_for_each(tmp, ldlm_namespace_list(client)) {
-               struct ldlm_namespace *ns;
-
-               ns = list_entry(tmp, struct ldlm_namespace, ns_list_chain);
+       list_for_each_entry(ns, ldlm_namespace_list(client), ns_list_chain)
                ldlm_namespace_dump(level, ns);
-       }
 
        mutex_unlock(ldlm_namespace_lock(client));
 }