All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] staging: lustre: assorted code improvements for list manipulations.
@ 2017-10-30  4:59 ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

There are mostly conversions of list_for_each() to
list_for_each_entry() and similar.  list_first_entry()
also makes a few appearances.

Thanks,
NeilBrown


---

NeilBrown (10):
      staging: lustre: use list_last_entry to simplify fld_cache_shrink
      staging: lustre: ldlm: use list_for_each_entry in ldlm_extent_shift_kms()
      staging: lustre: ldlm: use list_first_entry in ldlm_lock
      staging: lustre: ldlm: use list_for_each_entry in ldlm_lock.c
      staging: lustre: ldlm: use list_first_entry in ldlm_lockd.c
      staging: lustre: ldlm: minor list_entry improvements in ldlm_request.c
      staging: lustre: ldlm: use list_for_each_entry in ldlm_resource.c
      staging: lustre: lov: use list_for_each_entry in lov_obd.c
      staging: lustre: simplfy lov_finish_set()
      staging: lustre: obdclass: simplify cl_lock_fini()


 drivers/staging/lustre/lustre/fld/fld_cache.c      |   13 ++++++-------
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c   |    4 +---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   18 +++++++-----------
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |   10 +++++-----
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   12 ++++--------
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   20 +++++++-------------
 drivers/staging/lustre/lustre/lov/lov_obd.c        |    6 ++----
 drivers/staging/lustre/lustre/lov/lov_request.c    |   10 ++++------
 drivers/staging/lustre/lustre/obdclass/cl_lock.c   |    9 ++++-----
 9 files changed, 40 insertions(+), 62 deletions(-)

--
Signature

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 01/10] staging: lustre: use list_last_entry to simplify fld_cache_shrink
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-10-30  4:59   ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

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

diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c
index b723ece02eff..c01709cd22a1 100644
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -212,19 +212,18 @@ static inline void fld_cache_entry_add(struct fld_cache *cache,
  */
 static int fld_cache_shrink(struct fld_cache *cache)
 {
-	struct fld_cache_entry *flde;
-	struct list_head *curr;
 	int num = 0;
 
 	if (cache->fci_cache_count < cache->fci_cache_size)
 		return 0;
 
-	curr = cache->fci_lru.prev;
-
 	while (cache->fci_cache_count + cache->fci_threshold >
-	       cache->fci_cache_size && curr != &cache->fci_lru) {
-		flde = list_entry(curr, struct fld_cache_entry, fce_lru);
-		curr = curr->prev;
+	       cache->fci_cache_size &&
+	       !list_empty(&cache->fci_lru)) {
+		struct fld_cache_entry *flde =
+			list_last_entry(&cache->fci_lru,
+					struct fld_cache_entry, fce_lru);
+
 		fld_cache_entry_delete(cache, flde);
 		num++;
 	}

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 02/10] staging: lustre: ldlm: use list_for_each_entry in ldlm_extent_shift_kms()
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-10-30  4:59   ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index 2cc6dc2b281f..c9bf9ae40f7d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -63,7 +63,6 @@
 __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms)
 {
 	struct ldlm_resource *res = lock->l_resource;
-	struct list_head *tmp;
 	struct ldlm_lock *lck;
 	__u64 kms = 0;
 
@@ -73,8 +72,7 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms)
 	 */
 	ldlm_set_kms_ignore(lock);
 
-	list_for_each(tmp, &res->lr_granted) {
-		lck = list_entry(tmp, struct ldlm_lock, l_res_link);
+	list_for_each_entry(lck, &res->lr_granted, l_res_link) {
 
 		if (ldlm_is_kms_ignore(lck))
 			continue;

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 03/10] staging: lustre: ldlm: use list_first_entry in ldlm_lock
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-10-30  4:59   ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

This make the code (slightly) more readable.

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

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index b5d84f3f6071..ed061cc46986 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1685,7 +1685,7 @@ ldlm_work_bl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
 	if (list_empty(arg->list))
 		return -ENOENT;
 
-	lock = list_entry(arg->list->next, struct ldlm_lock, l_bl_ast);
+	lock = list_first_entry(arg->list, struct ldlm_lock, l_bl_ast);
 
 	/* nobody should touch l_bl_ast */
 	lock_res_and_lock(lock);
@@ -1721,7 +1721,7 @@ ldlm_work_cp_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
 	if (list_empty(arg->list))
 		return -ENOENT;
 
-	lock = list_entry(arg->list->next, struct ldlm_lock, l_cp_ast);
+	lock = list_first_entry(arg->list, struct ldlm_lock, l_cp_ast);
 
 	/* It's possible to receive a completion AST before we've set
 	 * the l_completion_ast pointer: either because the AST arrived
@@ -1767,7 +1767,7 @@ ldlm_work_revoke_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
 	if (list_empty(arg->list))
 		return -ENOENT;
 
-	lock = list_entry(arg->list->next, struct ldlm_lock, l_rk_ast);
+	lock = list_first_entry(arg->list, struct ldlm_lock, l_rk_ast);
 	list_del_init(&lock->l_rk_ast);
 
 	/* the desc just pretend to exclusive */
@@ -1794,7 +1794,7 @@ static int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
 	if (list_empty(arg->list))
 		return -ENOENT;
 
-	gl_work = list_entry(arg->list->next, struct ldlm_glimpse_work,
+	gl_work = list_first_entry(arg->list, struct ldlm_glimpse_work,
 			     gl_list);
 	list_del_init(&gl_work->gl_list);
 

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 04/10] staging: lustre: ldlm: use list_for_each_entry in ldlm_lock.c
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-10-30  4:59   ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

This makes some slightly-confusing code a bit clearer, and
avoids the need for 'tmp'.

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

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index ed061cc46986..036a509eb515 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -885,17 +885,15 @@ 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;
 
-	list_for_each(tmp, queue) {
-		lock = list_entry(tmp, struct ldlm_lock, l_res_link);
+	list_for_each_entry(lock, queue, l_res_link) {
 
 		mode_end = list_prev_entry(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;
 		}
 
@@ -932,9 +930,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,

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 05/10] staging: lustre: ldlm: use list_first_entry in ldlm_lockd.c
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-10-30  4:59   ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

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

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index e2707336586c..2aaa5e91c66c 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -693,13 +693,13 @@ static int ldlm_bl_get_work(struct ldlm_bl_pool *blp,
 	/* process a request from the blp_list at least every blp_num_threads */
 	if (!list_empty(&blp->blp_list) &&
 	    (list_empty(&blp->blp_prio_list) || num_bl == 0))
-		blwi = list_entry(blp->blp_list.next,
-				  struct ldlm_bl_work_item, blwi_entry);
+		blwi = list_first_entry(&blp->blp_list,
+					struct ldlm_bl_work_item, blwi_entry);
 	else
 		if (!list_empty(&blp->blp_prio_list))
-			blwi = list_entry(blp->blp_prio_list.next,
-					  struct ldlm_bl_work_item,
-					  blwi_entry);
+			blwi = list_first_entry(&blp->blp_prio_list,
+						struct ldlm_bl_work_item,
+						blwi_entry);
 
 	if (blwi) {
 		if (++num_bl >= num_th)

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 06/10] staging: lustre: ldlm: minor list_entry improvements in ldlm_request.c
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-10-30  4:59   ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index f5e791a92f62..1e7b8fc4dd00 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1642,7 +1642,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)) {
@@ -1766,7 +1766,7 @@ EXPORT_SYMBOL(ldlm_cli_cancel_unused);
 static 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;
 
@@ -1774,18 +1774,14 @@ static int ldlm_resource_foreach(struct ldlm_resource *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) {
 			rc = LDLM_ITER_STOP;
 			goto out;
 		}
 	}
 
-	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) {
 			rc = LDLM_ITER_STOP;
 			goto out;

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 07/10] staging: lustre: ldlm: use list_for_each_entry in ldlm_resource.c
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-10-30  4:59   ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

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 c2ddf7312571..980d970174d8 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -751,24 +751,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;
@@ -1282,19 +1280,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));
 }

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-10-30  4:59   ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/lov/lov_obd.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index fefd3c588681..7e013229d7b5 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -827,11 +827,9 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 static int lov_cleanup(struct obd_device *obd)
 {
 	struct lov_obd *lov = &obd->u.lov;
-	struct list_head *pos, *tmp;
-	struct pool_desc *pool;
+	struct pool_desc *pool, *tmp;
 
-	list_for_each_safe(pos, tmp, &lov->lov_pool_list) {
-		pool = list_entry(pos, struct pool_desc, pool_list);
+	list_for_each_entry_safe(pool, tmp, &lov->lov_pool_list, pool_list) {
 		/* free pool structs */
 		CDEBUG(D_INFO, "delete pool %p\n", pool);
 		/* In the function below, .hs_keycmp resolves to

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 09/10] staging: lustre: simplfy lov_finish_set()
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-10-30  4:59   ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

When deleting everything from a list, a while loop
is cleaner than list_for_each_safe().

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/lov/lov_request.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
index 9d3b3f3e9f10..54f883e359ce 100644
--- a/drivers/staging/lustre/lustre/lov/lov_request.c
+++ b/drivers/staging/lustre/lustre/lov/lov_request.c
@@ -48,15 +48,13 @@ static void lov_init_set(struct lov_request_set *set)
 
 static void lov_finish_set(struct lov_request_set *set)
 {
-	struct list_head *pos, *n;
+	struct lov_request *req;
 
 	LASSERT(set);
-	list_for_each_safe(pos, n, &set->set_list) {
-		struct lov_request *req = list_entry(pos,
-							 struct lov_request,
-							 rq_link);
+	while ((req = list_first_entry_or_null(&set->set_list,
+					       struct lov_request,
+					       rq_link)) != NULL) {
 		list_del_init(&req->rq_link);
-
 		kfree(req->rq_oi.oi_osfs);
 		kfree(req);
 	}

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 10/10] staging: lustre: obdclass: simplify cl_lock_fini()
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-10-30  4:59   ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

Using list_first_entry_or_null() makes this (slightly)
simpler.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/obdclass/cl_lock.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c
index 20e64051d2d6..fa97f4b39bd1 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c
@@ -78,13 +78,12 @@ EXPORT_SYMBOL(cl_lock_slice_add);
 
 void cl_lock_fini(const struct lu_env *env, struct cl_lock *lock)
 {
+	struct cl_lock_slice *slice;
 	cl_lock_trace(D_DLMTRACE, env, "destroy lock", lock);
 
-	while (!list_empty(&lock->cll_layers)) {
-		struct cl_lock_slice *slice;
-
-		slice = list_entry(lock->cll_layers.next,
-				   struct cl_lock_slice, cls_linkage);
+	while ((slice = list_first_entry_or_null(&lock->cll_layers,
+						 struct cl_lock_slice,
+						 cls_linkage)) != NULL) {
 		list_del_init(lock->cll_layers.next);
 		slice->cls_ops->clo_fini(env, slice);
 	}

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 00/10] staging: lustre: assorted code improvements for list manipulations.
@ 2017-10-30  4:59 ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

There are mostly conversions of list_for_each() to
list_for_each_entry() and similar.  list_first_entry()
also makes a few appearances.

Thanks,
NeilBrown


---

NeilBrown (10):
      staging: lustre: use list_last_entry to simplify fld_cache_shrink
      staging: lustre: ldlm: use list_for_each_entry in ldlm_extent_shift_kms()
      staging: lustre: ldlm: use list_first_entry in ldlm_lock
      staging: lustre: ldlm: use list_for_each_entry in ldlm_lock.c
      staging: lustre: ldlm: use list_first_entry in ldlm_lockd.c
      staging: lustre: ldlm: minor list_entry improvements in ldlm_request.c
      staging: lustre: ldlm: use list_for_each_entry in ldlm_resource.c
      staging: lustre: lov: use list_for_each_entry in lov_obd.c
      staging: lustre: simplfy lov_finish_set()
      staging: lustre: obdclass: simplify cl_lock_fini()


 drivers/staging/lustre/lustre/fld/fld_cache.c      |   13 ++++++-------
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c   |    4 +---
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   18 +++++++-----------
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c    |   10 +++++-----
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |   12 ++++--------
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |   20 +++++++-------------
 drivers/staging/lustre/lustre/lov/lov_obd.c        |    6 ++----
 drivers/staging/lustre/lustre/lov/lov_request.c    |   10 ++++------
 drivers/staging/lustre/lustre/obdclass/cl_lock.c   |    9 ++++-----
 9 files changed, 40 insertions(+), 62 deletions(-)

--
Signature

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 02/10] staging: lustre: ldlm: use list_for_each_entry in ldlm_extent_shift_kms()
@ 2017-10-30  4:59   ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index 2cc6dc2b281f..c9bf9ae40f7d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -63,7 +63,6 @@
 __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms)
 {
 	struct ldlm_resource *res = lock->l_resource;
-	struct list_head *tmp;
 	struct ldlm_lock *lck;
 	__u64 kms = 0;
 
@@ -73,8 +72,7 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms)
 	 */
 	ldlm_set_kms_ignore(lock);
 
-	list_for_each(tmp, &res->lr_granted) {
-		lck = list_entry(tmp, struct ldlm_lock, l_res_link);
+	list_for_each_entry(lck, &res->lr_granted, l_res_link) {
 
 		if (ldlm_is_kms_ignore(lck))
 			continue;

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 01/10] staging: lustre: use list_last_entry to simplify fld_cache_shrink
@ 2017-10-30  4:59   ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

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

diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c
index b723ece02eff..c01709cd22a1 100644
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -212,19 +212,18 @@ static inline void fld_cache_entry_add(struct fld_cache *cache,
  */
 static int fld_cache_shrink(struct fld_cache *cache)
 {
-	struct fld_cache_entry *flde;
-	struct list_head *curr;
 	int num = 0;
 
 	if (cache->fci_cache_count < cache->fci_cache_size)
 		return 0;
 
-	curr = cache->fci_lru.prev;
-
 	while (cache->fci_cache_count + cache->fci_threshold >
-	       cache->fci_cache_size && curr != &cache->fci_lru) {
-		flde = list_entry(curr, struct fld_cache_entry, fce_lru);
-		curr = curr->prev;
+	       cache->fci_cache_size &&
+	       !list_empty(&cache->fci_lru)) {
+		struct fld_cache_entry *flde =
+			list_last_entry(&cache->fci_lru,
+					struct fld_cache_entry, fce_lru);
+
 		fld_cache_entry_delete(cache, flde);
 		num++;
 	}

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 04/10] staging: lustre: ldlm: use list_for_each_entry in ldlm_lock.c
@ 2017-10-30  4:59   ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

This makes some slightly-confusing code a bit clearer, and
avoids the need for 'tmp'.

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

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index ed061cc46986..036a509eb515 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -885,17 +885,15 @@ 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;
 
-	list_for_each(tmp, queue) {
-		lock = list_entry(tmp, struct ldlm_lock, l_res_link);
+	list_for_each_entry(lock, queue, l_res_link) {
 
 		mode_end = list_prev_entry(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;
 		}
 
@@ -932,9 +930,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,

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 03/10] staging: lustre: ldlm: use list_first_entry in ldlm_lock
@ 2017-10-30  4:59   ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

This make the code (slightly) more readable.

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

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index b5d84f3f6071..ed061cc46986 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1685,7 +1685,7 @@ ldlm_work_bl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
 	if (list_empty(arg->list))
 		return -ENOENT;
 
-	lock = list_entry(arg->list->next, struct ldlm_lock, l_bl_ast);
+	lock = list_first_entry(arg->list, struct ldlm_lock, l_bl_ast);
 
 	/* nobody should touch l_bl_ast */
 	lock_res_and_lock(lock);
@@ -1721,7 +1721,7 @@ ldlm_work_cp_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
 	if (list_empty(arg->list))
 		return -ENOENT;
 
-	lock = list_entry(arg->list->next, struct ldlm_lock, l_cp_ast);
+	lock = list_first_entry(arg->list, struct ldlm_lock, l_cp_ast);
 
 	/* It's possible to receive a completion AST before we've set
 	 * the l_completion_ast pointer: either because the AST arrived
@@ -1767,7 +1767,7 @@ ldlm_work_revoke_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
 	if (list_empty(arg->list))
 		return -ENOENT;
 
-	lock = list_entry(arg->list->next, struct ldlm_lock, l_rk_ast);
+	lock = list_first_entry(arg->list, struct ldlm_lock, l_rk_ast);
 	list_del_init(&lock->l_rk_ast);
 
 	/* the desc just pretend to exclusive */
@@ -1794,7 +1794,7 @@ static int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
 	if (list_empty(arg->list))
 		return -ENOENT;
 
-	gl_work = list_entry(arg->list->next, struct ldlm_glimpse_work,
+	gl_work = list_first_entry(arg->list, struct ldlm_glimpse_work,
 			     gl_list);
 	list_del_init(&gl_work->gl_list);
 

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 05/10] staging: lustre: ldlm: use list_first_entry in ldlm_lockd.c
@ 2017-10-30  4:59   ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

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

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index e2707336586c..2aaa5e91c66c 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -693,13 +693,13 @@ static int ldlm_bl_get_work(struct ldlm_bl_pool *blp,
 	/* process a request from the blp_list at least every blp_num_threads */
 	if (!list_empty(&blp->blp_list) &&
 	    (list_empty(&blp->blp_prio_list) || num_bl == 0))
-		blwi = list_entry(blp->blp_list.next,
-				  struct ldlm_bl_work_item, blwi_entry);
+		blwi = list_first_entry(&blp->blp_list,
+					struct ldlm_bl_work_item, blwi_entry);
 	else
 		if (!list_empty(&blp->blp_prio_list))
-			blwi = list_entry(blp->blp_prio_list.next,
-					  struct ldlm_bl_work_item,
-					  blwi_entry);
+			blwi = list_first_entry(&blp->blp_prio_list,
+						struct ldlm_bl_work_item,
+						blwi_entry);
 
 	if (blwi) {
 		if (++num_bl >= num_th)

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 06/10] staging: lustre: ldlm: minor list_entry improvements in ldlm_request.c
@ 2017-10-30  4:59   ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index f5e791a92f62..1e7b8fc4dd00 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1642,7 +1642,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)) {
@@ -1766,7 +1766,7 @@ EXPORT_SYMBOL(ldlm_cli_cancel_unused);
 static 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;
 
@@ -1774,18 +1774,14 @@ static int ldlm_resource_foreach(struct ldlm_resource *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) {
 			rc = LDLM_ITER_STOP;
 			goto out;
 		}
 	}
 
-	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) {
 			rc = LDLM_ITER_STOP;
 			goto out;

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 07/10] staging: lustre: ldlm: use list_for_each_entry in ldlm_resource.c
@ 2017-10-30  4:59   ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

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 c2ddf7312571..980d970174d8 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -751,24 +751,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;
@@ -1282,19 +1280,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));
 }

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c
@ 2017-10-30  4:59   ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/lov/lov_obd.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index fefd3c588681..7e013229d7b5 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -827,11 +827,9 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 static int lov_cleanup(struct obd_device *obd)
 {
 	struct lov_obd *lov = &obd->u.lov;
-	struct list_head *pos, *tmp;
-	struct pool_desc *pool;
+	struct pool_desc *pool, *tmp;
 
-	list_for_each_safe(pos, tmp, &lov->lov_pool_list) {
-		pool = list_entry(pos, struct pool_desc, pool_list);
+	list_for_each_entry_safe(pool, tmp, &lov->lov_pool_list, pool_list) {
 		/* free pool structs */
 		CDEBUG(D_INFO, "delete pool %p\n", pool);
 		/* In the function below, .hs_keycmp resolves to

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 09/10] staging: lustre: simplfy lov_finish_set()
@ 2017-10-30  4:59   ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

When deleting everything from a list, a while loop
is cleaner than list_for_each_safe().

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/lov/lov_request.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
index 9d3b3f3e9f10..54f883e359ce 100644
--- a/drivers/staging/lustre/lustre/lov/lov_request.c
+++ b/drivers/staging/lustre/lustre/lov/lov_request.c
@@ -48,15 +48,13 @@ static void lov_init_set(struct lov_request_set *set)
 
 static void lov_finish_set(struct lov_request_set *set)
 {
-	struct list_head *pos, *n;
+	struct lov_request *req;
 
 	LASSERT(set);
-	list_for_each_safe(pos, n, &set->set_list) {
-		struct lov_request *req = list_entry(pos,
-							 struct lov_request,
-							 rq_link);
+	while ((req = list_first_entry_or_null(&set->set_list,
+					       struct lov_request,
+					       rq_link)) != NULL) {
 		list_del_init(&req->rq_link);
-
 		kfree(req->rq_oi.oi_osfs);
 		kfree(req);
 	}

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 10/10] staging: lustre: obdclass: simplify cl_lock_fini()
@ 2017-10-30  4:59   ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-10-30  4:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: linux-kernel, lustre-devel

Using list_first_entry_or_null() makes this (slightly)
simpler.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/obdclass/cl_lock.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c
index 20e64051d2d6..fa97f4b39bd1 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c
@@ -78,13 +78,12 @@ EXPORT_SYMBOL(cl_lock_slice_add);
 
 void cl_lock_fini(const struct lu_env *env, struct cl_lock *lock)
 {
+	struct cl_lock_slice *slice;
 	cl_lock_trace(D_DLMTRACE, env, "destroy lock", lock);
 
-	while (!list_empty(&lock->cll_layers)) {
-		struct cl_lock_slice *slice;
-
-		slice = list_entry(lock->cll_layers.next,
-				   struct cl_lock_slice, cls_linkage);
+	while ((slice = list_first_entry_or_null(&lock->cll_layers,
+						 struct cl_lock_slice,
+						 cls_linkage)) != NULL) {
 		list_del_init(lock->cll_layers.next);
 		slice->cls_ops->clo_fini(env, slice);
 	}

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c
  2017-10-30  4:59   ` [lustre-devel] " NeilBrown
@ 2017-11-24 15:43     ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 32+ messages in thread
From: Greg Kroah-Hartman @ 2017-11-24 15:43 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Andreas Dilger, James Simmons, linux-kernel, lustre-devel

On Mon, Oct 30, 2017 at 03:59:27PM +1100, NeilBrown wrote:
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/lov/lov_obd.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

I can't take patches with no changelog text at all, sorry.

greg k-h

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c
@ 2017-11-24 15:43     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 32+ messages in thread
From: Greg Kroah-Hartman @ 2017-11-24 15:43 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Andreas Dilger, James Simmons, linux-kernel, lustre-devel

On Mon, Oct 30, 2017 at 03:59:27PM +1100, NeilBrown wrote:
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lustre/lov/lov_obd.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

I can't take patches with no changelog text at all, sorry.

greg k-h

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 00/10] staging: lustre: assorted code improvements for list manipulations.
  2017-10-30  4:59 ` [lustre-devel] " NeilBrown
@ 2017-11-24 15:44   ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 32+ messages in thread
From: Greg Kroah-Hartman @ 2017-11-24 15:44 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Andreas Dilger, James Simmons, linux-kernel, lustre-devel

On Mon, Oct 30, 2017 at 03:59:27PM +1100, NeilBrown wrote:
> There are mostly conversions of list_for_each() to
> list_for_each_entry() and similar.  list_first_entry()
> also makes a few appearances.

I've taken the patches that had a changelog text.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 00/10] staging: lustre: assorted code improvements for list manipulations.
@ 2017-11-24 15:44   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 32+ messages in thread
From: Greg Kroah-Hartman @ 2017-11-24 15:44 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Andreas Dilger, James Simmons, linux-kernel, lustre-devel

On Mon, Oct 30, 2017 at 03:59:27PM +1100, NeilBrown wrote:
> There are mostly conversions of list_for_each() to
> list_for_each_entry() and similar.  list_first_entry()
> also makes a few appearances.

I've taken the patches that had a changelog text.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c
  2017-11-24 15:43     ` [lustre-devel] " Greg Kroah-Hartman
@ 2017-11-29  3:01       ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-11-29  3:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Oleg Drokin, Andreas Dilger, James Simmons, linux-kernel, lustre-devel

[-- Attachment #1: Type: text/plain, Size: 1218 bytes --]

Subject: [PATCH] staging: lustre: lov: use list_for_each_entry in lov_obd.c

Using the *_entry macro simplifies the code slightly.

Signed-off-by: NeilBrown <neilb@suse.com>
---

Resubmitted with non-empty changelog text.

Thanks,
NeilBrown

 drivers/staging/lustre/lustre/lov/lov_obd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 7ce01026a409..ec70c12e5b40 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -828,11 +828,9 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 static int lov_cleanup(struct obd_device *obd)
 {
 	struct lov_obd *lov = &obd->u.lov;
-	struct list_head *pos, *tmp;
-	struct pool_desc *pool;
+	struct pool_desc *pool, *tmp;
 
-	list_for_each_safe(pos, tmp, &lov->lov_pool_list) {
-		pool = list_entry(pos, struct pool_desc, pool_list);
+	list_for_each_entry_safe(pool, tmp, &lov->lov_pool_list, pool_list) {
 		/* free pool structs */
 		CDEBUG(D_INFO, "delete pool %p\n", pool);
 		/* In the function below, .hs_keycmp resolves to
-- 
2.14.0.rc0.dirty


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c
@ 2017-11-29  3:01       ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-11-29  3:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Oleg Drokin, Andreas Dilger, James Simmons, linux-kernel, lustre-devel

Subject: [PATCH] staging: lustre: lov: use list_for_each_entry in lov_obd.c

Using the *_entry macro simplifies the code slightly.

Signed-off-by: NeilBrown <neilb@suse.com>
---

Resubmitted with non-empty changelog text.

Thanks,
NeilBrown

 drivers/staging/lustre/lustre/lov/lov_obd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 7ce01026a409..ec70c12e5b40 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -828,11 +828,9 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 static int lov_cleanup(struct obd_device *obd)
 {
 	struct lov_obd *lov = &obd->u.lov;
-	struct list_head *pos, *tmp;
-	struct pool_desc *pool;
+	struct pool_desc *pool, *tmp;
 
-	list_for_each_safe(pos, tmp, &lov->lov_pool_list) {
-		pool = list_entry(pos, struct pool_desc, pool_list);
+	list_for_each_entry_safe(pool, tmp, &lov->lov_pool_list, pool_list) {
 		/* free pool structs */
 		CDEBUG(D_INFO, "delete pool %p\n", pool);
 		/* In the function below, .hs_keycmp resolves to
-- 
2.14.0.rc0.dirty

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20171129/c4003335/attachment.sig>

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c
  2017-11-29  3:01       ` [lustre-devel] " NeilBrown
@ 2017-11-29  9:40         ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 32+ messages in thread
From: Greg Kroah-Hartman @ 2017-11-29  9:40 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Andreas Dilger, James Simmons, linux-kernel, lustre-devel

On Wed, Nov 29, 2017 at 02:01:12PM +1100, NeilBrown wrote:
> Subject: [PATCH] staging: lustre: lov: use list_for_each_entry in lov_obd.c

Why is there a subject line in the body of the text here?  Will git
figure this out correctly?

> Using the *_entry macro simplifies the code slightly.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
> 
> Resubmitted with non-empty changelog text.

Did I apply the others?  Can you just send a new series of whatever I
didn't apply so it's obvious for me as to what to do?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c
@ 2017-11-29  9:40         ` Greg Kroah-Hartman
  0 siblings, 0 replies; 32+ messages in thread
From: Greg Kroah-Hartman @ 2017-11-29  9:40 UTC (permalink / raw)
  To: NeilBrown
  Cc: Oleg Drokin, Andreas Dilger, James Simmons, linux-kernel, lustre-devel

On Wed, Nov 29, 2017 at 02:01:12PM +1100, NeilBrown wrote:
> Subject: [PATCH] staging: lustre: lov: use list_for_each_entry in lov_obd.c

Why is there a subject line in the body of the text here?  Will git
figure this out correctly?

> Using the *_entry macro simplifies the code slightly.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
> 
> Resubmitted with non-empty changelog text.

Did I apply the others?  Can you just send a new series of whatever I
didn't apply so it's obvious for me as to what to do?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c
  2017-11-29  9:40         ` [lustre-devel] " Greg Kroah-Hartman
@ 2017-11-29 11:37           ` NeilBrown
  -1 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-11-29 11:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Oleg Drokin, Andreas Dilger, James Simmons, linux-kernel, lustre-devel

[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

On Wed, Nov 29 2017, Greg Kroah-Hartman wrote:

> On Wed, Nov 29, 2017 at 02:01:12PM +1100, NeilBrown wrote:
>> Subject: [PATCH] staging: lustre: lov: use list_for_each_entry in lov_obd.c
>
> Why is there a subject line in the body of the text here?  Will git
> figure this out correctly?

Because I wanted to leave the original subject unchanged so it would be
fairly clear to you the context of the email, but also wanted to be
certain picked up the right subject (though in this case it would have
worked right anyway I think).
Yes, "git am" will see the Subject: line in the body and over-ride the
Subject line in the headers.

Thanks,
NeilBrown


>
>> Using the *_entry macro simplifies the code slightly.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>> 
>> Resubmitted with non-empty changelog text.
>
> Did I apply the others?  Can you just send a new series of whatever I
> didn't apply so it's obvious for me as to what to do?
>
> thanks,
>
> greg k-h

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [lustre-devel] [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c
@ 2017-11-29 11:37           ` NeilBrown
  0 siblings, 0 replies; 32+ messages in thread
From: NeilBrown @ 2017-11-29 11:37 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Oleg Drokin, Andreas Dilger, James Simmons, linux-kernel, lustre-devel

On Wed, Nov 29 2017, Greg Kroah-Hartman wrote:

> On Wed, Nov 29, 2017 at 02:01:12PM +1100, NeilBrown wrote:
>> Subject: [PATCH] staging: lustre: lov: use list_for_each_entry in lov_obd.c
>
> Why is there a subject line in the body of the text here?  Will git
> figure this out correctly?

Because I wanted to leave the original subject unchanged so it would be
fairly clear to you the context of the email, but also wanted to be
certain picked up the right subject (though in this case it would have
worked right anyway I think).
Yes, "git am" will see the Subject: line in the body and over-ride the
Subject line in the headers.

Thanks,
NeilBrown


>
>> Using the *_entry macro simplifies the code slightly.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>> ---
>> 
>> Resubmitted with non-empty changelog text.
>
> Did I apply the others?  Can you just send a new series of whatever I
> didn't apply so it's obvious for me as to what to do?
>
> thanks,
>
> greg k-h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20171129/2003f661/attachment.sig>

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2017-11-29 11:38 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-30  4:59 [PATCH 00/10] staging: lustre: assorted code improvements for list manipulations NeilBrown
2017-10-30  4:59 ` [lustre-devel] " NeilBrown
2017-10-30  4:59 ` [PATCH 09/10] staging: lustre: simplfy lov_finish_set() NeilBrown
2017-10-30  4:59   ` [lustre-devel] " NeilBrown
2017-10-30  4:59 ` [PATCH 07/10] staging: lustre: ldlm: use list_for_each_entry in ldlm_resource.c NeilBrown
2017-10-30  4:59   ` [lustre-devel] " NeilBrown
2017-10-30  4:59 ` [PATCH 08/10] staging: lustre: lov: use list_for_each_entry in lov_obd.c NeilBrown
2017-10-30  4:59   ` [lustre-devel] " NeilBrown
2017-11-24 15:43   ` Greg Kroah-Hartman
2017-11-24 15:43     ` [lustre-devel] " Greg Kroah-Hartman
2017-11-29  3:01     ` NeilBrown
2017-11-29  3:01       ` [lustre-devel] " NeilBrown
2017-11-29  9:40       ` Greg Kroah-Hartman
2017-11-29  9:40         ` [lustre-devel] " Greg Kroah-Hartman
2017-11-29 11:37         ` NeilBrown
2017-11-29 11:37           ` [lustre-devel] " NeilBrown
2017-10-30  4:59 ` [PATCH 06/10] staging: lustre: ldlm: minor list_entry improvements in ldlm_request.c NeilBrown
2017-10-30  4:59   ` [lustre-devel] " NeilBrown
2017-10-30  4:59 ` [PATCH 01/10] staging: lustre: use list_last_entry to simplify fld_cache_shrink NeilBrown
2017-10-30  4:59   ` [lustre-devel] " NeilBrown
2017-10-30  4:59 ` [PATCH 03/10] staging: lustre: ldlm: use list_first_entry in ldlm_lock NeilBrown
2017-10-30  4:59   ` [lustre-devel] " NeilBrown
2017-10-30  4:59 ` [PATCH 04/10] staging: lustre: ldlm: use list_for_each_entry in ldlm_lock.c NeilBrown
2017-10-30  4:59   ` [lustre-devel] " NeilBrown
2017-10-30  4:59 ` [PATCH 10/10] staging: lustre: obdclass: simplify cl_lock_fini() NeilBrown
2017-10-30  4:59   ` [lustre-devel] " NeilBrown
2017-10-30  4:59 ` [PATCH 05/10] staging: lustre: ldlm: use list_first_entry in ldlm_lockd.c NeilBrown
2017-10-30  4:59   ` [lustre-devel] " NeilBrown
2017-10-30  4:59 ` [PATCH 02/10] staging: lustre: ldlm: use list_for_each_entry in ldlm_extent_shift_kms() NeilBrown
2017-10-30  4:59   ` [lustre-devel] " NeilBrown
2017-11-24 15:44 ` [PATCH 00/10] staging: lustre: assorted code improvements for list manipulations Greg Kroah-Hartman
2017-11-24 15:44   ` [lustre-devel] " Greg Kroah-Hartman

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.