summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorBhaktipriya Shridhar <bhaktipriya96@gmail.com>2016-03-11 20:06:51 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-03-12 06:09:09 (GMT)
commit8adddc36b1fc4a71f3172585e1c71b88c0740a5c (patch)
treef3ea59f74f7c0ecc2c6b8807e9bf209722dec069 /drivers/staging
parentc997866cd27495ae28bc07596457e2bd83fb3275 (diff)
downloadlinux-8adddc36b1fc4a71f3172585e1c71b88c0740a5c.tar.xz
staging: lustre: osc: Use list_for_each_entry_safe
Doubly linked lists which are iterated using list_empty and list_entry macros have been replaced with list_for_each_entry_safe macro. This makes the iteration simpler and more readable. This patch replaces the while loop containing list_empty and list_entry with list_for_each_entry_safe. This was done with Coccinelle. @@ expression E1; identifier I1, I2; type T; iterator name list_for_each_entry_safe; @@ T *I1; + T *tmp; ... - while (list_empty(&E1) == 0) + list_for_each_entry_safe (I1, tmp, &E1, I2) { ...when != T *I1; - I1 = list_entry(E1.next, T, I2); ... } Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_page.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index 537107c..d720b1a 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -563,6 +563,7 @@ int osc_lru_shrink(struct client_obd *cli, int target)
struct cl_object *clobj = NULL;
struct cl_page **pvec;
struct osc_page *opg;
+ struct osc_page *temp;
int maxscan = 0;
int count = 0;
int index = 0;
@@ -582,14 +583,12 @@ int osc_lru_shrink(struct client_obd *cli, int target)
client_obd_list_lock(&cli->cl_lru_list_lock);
atomic_inc(&cli->cl_lru_shrinkers);
maxscan = min(target << 1, atomic_read(&cli->cl_lru_in_list));
- while (!list_empty(&cli->cl_lru_list)) {
+ list_for_each_entry_safe(opg, temp, &cli->cl_lru_list, ops_lru) {
struct cl_page *page;
if (--maxscan < 0)
break;
- opg = list_entry(cli->cl_lru_list.next, struct osc_page,
- ops_lru);
page = cl_page_top(opg->ops_cl.cpl_page);
if (cl_page_in_use_noref(page)) {
list_move_tail(&opg->ops_lru, &cli->cl_lru_list);