All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Oleg Drokin <oleg.drokin@intel.com>,
	James Simmons <jsimmons@infradead.org>,
	Andreas Dilger <andreas.dilger@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, lustre-devel@lists.lustre.org
Subject: [PATCH 05/12] staging: lustre: ldlm: use list_for_each_entry in ldlm_resource.c
Date: Wed, 13 Dec 2017 14:15:54 +1100	[thread overview]
Message-ID: <151313495491.27582.1409394419999876978.stgit@noble> (raw)
In-Reply-To: <151313493380.27582.16490205348451477393.stgit@noble>

Having a stand-alone "list_entry()" call is often a sign
that something like "list_for_each_entry()" would
make the code clearer.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 2689ffdf10e3..9958533cc227 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -752,24 +752,22 @@ extern struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
 static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
 			     __u64 flags)
 {
-	struct list_head *tmp;
 	int rc = 0;
 	bool local_only = !!(flags & LDLM_FL_LOCAL_ONLY);
 
 	do {
-		struct ldlm_lock *lock = NULL;
+		struct ldlm_lock *lock = NULL, *tmp;
 		struct lustre_handle lockh;
 
 		/* 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;
@@ -1283,19 +1281,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));
 }

WARNING: multiple messages have this Message-ID (diff)
From: NeilBrown <neilb@suse.com>
To: Oleg Drokin <oleg.drokin@intel.com>,
	James Simmons <jsimmons@infradead.org>,
	Andreas Dilger <andreas.dilger@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 05/12] staging: lustre: ldlm: use list_for_each_entry in ldlm_resource.c
Date: Wed, 13 Dec 2017 14:15:54 +1100	[thread overview]
Message-ID: <151313495491.27582.1409394419999876978.stgit@noble> (raw)
In-Reply-To: <151313493380.27582.16490205348451477393.stgit@noble>

Having a stand-alone "list_entry()" call is often a sign
that something like "list_for_each_entry()" would
make the code clearer.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 2689ffdf10e3..9958533cc227 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -752,24 +752,22 @@ extern struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
 static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
 			     __u64 flags)
 {
-	struct list_head *tmp;
 	int rc = 0;
 	bool local_only = !!(flags & LDLM_FL_LOCAL_ONLY);
 
 	do {
-		struct ldlm_lock *lock = NULL;
+		struct ldlm_lock *lock = NULL, *tmp;
 		struct lustre_handle lockh;
 
 		/* 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;
@@ -1283,19 +1281,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));
 }

  parent reply	other threads:[~2017-12-13  3:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13  3:15 [PATCH 00/13] Assorted lustre clean-ups NeilBrown
2017-12-13  3:15 ` [lustre-devel] " NeilBrown
2017-12-13  3:15 ` [PATCH 03/12] staging: lustre: ldlm: use list_first_entry in ldlm_lockd.c NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown
2017-12-13  3:15 ` [PATCH 04/12] staging: lustre: ldlm: minor list_entry improvements in ldlm_request.c NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown
2017-12-13  3:15 ` [PATCH 06/12] staging: lustre: lov: use list_for_each_entry in lov_obd.c NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown
2017-12-13  3:15 ` NeilBrown [this message]
2017-12-13  3:15   ` [lustre-devel] [PATCH 05/12] staging: lustre: ldlm: use list_for_each_entry in ldlm_resource.c NeilBrown
2017-12-13  3:15 ` [PATCH 02/12] staging: lustre: ldlm: use list_for_each_entry in ldlm_extent_shift_kms() NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown
2017-12-13  3:15 ` [PATCH 01/12] staging: lustre: use list_last_entry to simplify fld_cache_shrink NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown
2017-12-13  3:15 ` [PATCH 08/12] staging: lustre: libcfs: remove unused rounding functions NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown
2017-12-13  3:15 ` [PATCH 11/12] staging: lustre: libcfs: discard KLASSERT() NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown
2017-12-13  3:15 ` [PATCH 10/12] staging: lustre: libcfs: discard MAX_NUMERIC_VALUE NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown
2017-12-13  3:15 ` [PATCH 07/12] staging: lustre: libcfs: simplify memory allocation NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown
2017-12-14  0:00   ` NeilBrown
2017-12-14  0:00     ` [lustre-devel] " NeilBrown
2017-12-14  3:34   ` Patrick Farrell
2017-12-13  3:15 ` [PATCH 12/12] staging: lustre: libcfs: discard LASSERT_CHECKED NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown
2017-12-13  3:33   ` Patrick Farrell
2017-12-13 10:22     ` Luis de Bethencourt
2017-12-13 10:22       ` Luis de Bethencourt
2017-12-13  3:15 ` [PATCH 09/12] staging: lustre: libcfs: discard MKSTR() macro NeilBrown
2017-12-13  3:15   ` [lustre-devel] " NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=151313495491.27582.1409394419999876978.stgit@noble \
    --to=neilb@suse.com \
    --cc=andreas.dilger@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jsimmons@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    --cc=oleg.drokin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.