Skip to contentSkip to conversation

Staging: lustre: lov: Use list_for_each_entry instead of list_for_each

PATCH Superseded Bhumika Goyal 2 participants 6 messages Feb 25, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: lustre: lov: Use list_for_each_entry instead of list_for_each

Use list_for_each_entry instead of list_for_each and list_entry as it simplifies the code. Done using coccinelle:

@@
type T,T2;
identifier I1,I2;
expression e1,e2;
iterator name list_for_each_entry;
iterator name list_for_each;
@@

- T *I1;
...
- list_for_each(I1,e1)
+ list_for_each_entry(I2,e1,e2)
{
...when!=T *I1;
- I2=list_entry(I1,T2,e2);
...
}

@@
type T,T2,T3;
identifier I1,I2,I3;
expression e1,e2;
@@

- T *I1;
+ T3 *I3;
...
- list_for_each(I1,e1)
+ list_for_each_entry(I3,e1,e2)
{
...when!=T *I1;
- T3 *I3=list_entry(I1,T2,e2);
...
}

---
 drivers/staging/lustre/lustre/lov/lov_obd.c     | 19 ++++---------------
 drivers/staging/lustre/lustre/lov/lov_request.c |  5 +----
 2 files changed, 5 insertions(+), 19 deletions(-)
drivers/staging/lustre/lustre/lov/lov_obd.c +4 -15
index dcaa5a1..1ce7341 100644
@@ -1064,7 +1064,6 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp,
 	struct lov_request_set *set;
 	struct obd_info oinfo;
 	struct lov_request *req;
-	struct list_head *pos;
 	struct lov_obd *lov;
 	int rc = 0, err = 0;
 
@@ -1084,9 +1083,7 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp,
 	if (rc)
 		goto out;
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		if (oa->o_valid & OBD_MD_FLCOOKIE)
 			oti->oti_logcookies = set->set_cookies + req->rq_stripe;
 
@@ -1131,7 +1128,6 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
 {
 	struct lov_request_set *lovset;
 	struct lov_obd *lov;
-	struct list_head *pos;
 	struct lov_request *req;
 	int rc = 0, err;
 
@@ -1151,9 +1147,7 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
 	       POSTID(&oinfo->oi_md->lsm_oi), oinfo->oi_md->lsm_stripe_count,
 	       oinfo->oi_md->lsm_stripe_size);
 
-	list_for_each(pos, &lovset->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &lovset->set_list, rq_link) {
 		CDEBUG(D_INFO, "objid " DOSTID "[%d] has subobj " DOSTID " at idx%u\n",
 		       POSTID(&oinfo->oi_oa->o_oi), req->rq_stripe,
 		       POSTID(&req->rq_oi.oi_oa->o_oi), req->rq_idx);
@@ -1204,7 +1198,6 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
 {
 	struct lov_request_set *set;
 	struct lov_request *req;
-	struct list_head *pos;
 	struct lov_obd *lov;
 	int rc = 0;
 
@@ -1228,9 +1221,7 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
 	       oinfo->oi_md->lsm_stripe_count,
 	       oinfo->oi_md->lsm_stripe_size);
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		if (oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE)
 			oti->oti_logcookies = set->set_cookies + req->rq_stripe;
 
@@ -1324,7 +1315,6 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo,
 	struct obd_device      *obd = class_exp2obd(exp);
 	struct lov_request_set *set;
 	struct lov_request *req;
-	struct list_head *pos;
 	struct lov_obd *lov;
 	int rc = 0;
 
@@ -1335,8 +1325,7 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo,
 	if (rc)
 		return rc;
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		rc = obd_statfs_async(lov->lov_tgts[req->rq_idx]->ltd_exp,
 				      &req->rq_oi, max_age, rqset);
 		if (rc)
drivers/staging/lustre/lustre/lov/lov_request.c +1 -4
index 6c5ae05..34c26ec 100644
@@ -190,7 +190,6 @@ out:
 
 static int common_attr_done(struct lov_request_set *set)
 {
-	struct list_head *pos;
 	struct lov_request *req;
 	struct obdo *tmp_oa;
 	int rc = 0, attrset = 0;
@@ -207,9 +206,7 @@ static int common_attr_done(struct lov_request_set *set)
 		goto out;
 	}
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		if (!req->rq_complete || req->rq_rc)
 			continue;
 		if (req->rq_oi.oi_oa->o_valid == 0)   /* inactive stripe */
Signature · 1 line
1.9.1
#1 lore raw
Quoted 2 lines · Bhumika Goyal

Use list_for_each_entry instead of list_for_each and list_entry as it simplifies the code. Done using coccinelle:

Did you check in each case that req is not used after the loop?

julia

Quoted 154 lines

@@
type T,T2;
identifier I1,I2;
expression e1,e2;
iterator name list_for_each_entry;
iterator name list_for_each;
@@

- T *I1;
...
- list_for_each(I1,e1)
+ list_for_each_entry(I2,e1,e2)
{
...when!=T *I1;
- I2=list_entry(I1,T2,e2);
...
}

@@
type T,T2,T3;
identifier I1,I2,I3;
expression e1,e2;
@@

- T *I1;
+ T3 *I3;
...
- list_for_each(I1,e1)
+ list_for_each_entry(I3,e1,e2)
{
...when!=T *I1;
- T3 *I3=list_entry(I1,T2,e2);
...
}

---
 drivers/staging/lustre/lustre/lov/lov_obd.c     | 19 ++++---------------
 drivers/staging/lustre/lustre/lov/lov_request.c |  5 +----
 2 files changed, 5 insertions(+), 19 deletions(-)
drivers/staging/lustre/lustre/lov/lov_obd.c +4 -15
index dcaa5a1..1ce7341 100644
@@ -1064,7 +1064,6 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp,
 	struct lov_request_set *set;
 	struct obd_info oinfo;
 	struct lov_request *req;
-	struct list_head *pos;
 	struct lov_obd *lov;
 	int rc = 0, err = 0;
 
@@ -1084,9 +1083,7 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp,
 	if (rc)
 		goto out;
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		if (oa->o_valid & OBD_MD_FLCOOKIE)
 			oti->oti_logcookies = set->set_cookies + req->rq_stripe;
 
@@ -1131,7 +1128,6 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
 {
 	struct lov_request_set *lovset;
 	struct lov_obd *lov;
-	struct list_head *pos;
 	struct lov_request *req;
 	int rc = 0, err;
 
@@ -1151,9 +1147,7 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
 	       POSTID(&oinfo->oi_md->lsm_oi), oinfo->oi_md->lsm_stripe_count,
 	       oinfo->oi_md->lsm_stripe_size);
 
-	list_for_each(pos, &lovset->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &lovset->set_list, rq_link) {
 		CDEBUG(D_INFO, "objid " DOSTID "[%d] has subobj " DOSTID " at idx%u\n",
 		       POSTID(&oinfo->oi_oa->o_oi), req->rq_stripe,
 		       POSTID(&req->rq_oi.oi_oa->o_oi), req->rq_idx);
@@ -1204,7 +1198,6 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
 {
 	struct lov_request_set *set;
 	struct lov_request *req;
-	struct list_head *pos;
 	struct lov_obd *lov;
 	int rc = 0;
 
@@ -1228,9 +1221,7 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
 	       oinfo->oi_md->lsm_stripe_count,
 	       oinfo->oi_md->lsm_stripe_size);
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		if (oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE)
 			oti->oti_logcookies = set->set_cookies + req->rq_stripe;
 
@@ -1324,7 +1315,6 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo,
 	struct obd_device      *obd = class_exp2obd(exp);
 	struct lov_request_set *set;
 	struct lov_request *req;
-	struct list_head *pos;
 	struct lov_obd *lov;
 	int rc = 0;
 
@@ -1335,8 +1325,7 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo,
 	if (rc)
 		return rc;
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		rc = obd_statfs_async(lov->lov_tgts[req->rq_idx]->ltd_exp,
 				      &req->rq_oi, max_age, rqset);
 		if (rc)
drivers/staging/lustre/lustre/lov/lov_request.c +1 -5
index 6c5ae05..34c26ec 100644
@@ -190,7 +190,6 @@ out:
 
 static int common_attr_done(struct lov_request_set *set)
 {
-	struct list_head *pos;
 	struct lov_request *req;
 	struct obdo *tmp_oa;
 	int rc = 0, attrset = 0;
@@ -207,9 +206,7 @@ static int common_attr_done(struct lov_request_set *set)
 		goto out;
 	}
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		if (!req->rq_complete || req->rq_rc)
 			continue;
 		if (req->rq_oi.oi_oa->o_valid == 0)   /* inactive stripe */
--

1.9.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1456415872-7808-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 10 lines · Julia Lawall
Quoted 2 lines · Bhumika Goyal

Use list_for_each_entry instead of list_for_each and list_entry as it simplifies the code. Done using coccinelle:

Did you check in each case that req is not used after the loop?

julia

Yes I checked and req is not used anywhere after list_for_each_entry loop in each case.

Thanks,
Bhumika

Quoted 174 lines
Quoted 36 lines

@@
type T,T2;
identifier I1,I2;
expression e1,e2;
iterator name list_for_each_entry;
iterator name list_for_each;
@@

- T *I1;
...
- list_for_each(I1,e1)
+ list_for_each_entry(I2,e1,e2)
{
...when!=T *I1;
- I2=list_entry(I1,T2,e2);
...
}

@@
type T,T2,T3;
identifier I1,I2,I3;
expression e1,e2;
@@

- T *I1;
+ T3 *I3;
...
- list_for_each(I1,e1)
+ list_for_each_entry(I3,e1,e2)
{
...when!=T *I1;
- T3 *I3=list_entry(I1,T2,e2);
...
}

Review

Quoted 7 lines
---
 drivers/staging/lustre/lustre/lov/lov_obd.c     | 19 ++++---------------
 drivers/staging/lustre/lustre/lov/lov_request.c |  5 +----
 2 files changed, 5 insertions(+), 19 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/lustre/lustre/lov/lov_obd.c

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_destroy(const struct lu_env *env,

Quoted 4 lines

index dcaa5a1..1ce7341 100644

drivers/staging/lustre/lustre/lov/lov_obd.c +0 -0
@@ -1064,7 +1064,6 @@ static int lov_destroy(const struct lu_env *env,

struct obd_export *exp,

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_destroy(const struct lu_env *env,

Quoted 8 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +0 -1
      struct lov_request_set *set;
      struct obd_info oinfo;
      struct lov_request *req;
-     struct list_head *pos;
      struct lov_obd *lov;
      int rc = 0, err = 0;
 
@@ -1084,9 +1083,7 @@ static int lov_destroy(const struct lu_env *env,

struct obd_export *exp,

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_destroy(const struct lu_env *env, struct obd_export *exp,

Quoted 9 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +1 -3
      if (rc)
              goto out;
 
-     list_for_each(pos, &set->set_list) {
-             req = list_entry(pos, struct lov_request, rq_link);
-
+     list_for_each_entry(req, &set->set_list, rq_link) {
              if (oa->o_valid & OBD_MD_FLCOOKIE)
                      oti->oti_logcookies = set->set_cookies +

req->rq_stripe;

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_getattr_async(struct obd_export

Quoted 2 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +0 -0
@@ -1131,7 +1128,6 @@ static int lov_getattr_async(struct obd_export

*exp, struct obd_info *oinfo,

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_getattr_async(struct obd_export

Quoted 8 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +0 -1
 {
      struct lov_request_set *lovset;
      struct lov_obd *lov;
-     struct list_head *pos;
      struct lov_request *req;
      int rc = 0, err;
 
@@ -1151,9 +1147,7 @@ static int lov_getattr_async(struct obd_export

*exp, struct obd_info *oinfo,

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_getattr_async(struct obd_export · line 1147

Quoted 1 line
drivers/staging/lustre/lustre/lov/lov_obd.c +0 -0
             POSTID(&oinfo->oi_md->lsm_oi),

oinfo->oi_md->lsm_stripe_count,

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo,

Quoted 7 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +1 -3
             oinfo->oi_md->lsm_stripe_size);
 
-     list_for_each(pos, &lovset->set_list) {
-             req = list_entry(pos, struct lov_request, rq_link);
-
+     list_for_each_entry(req, &lovset->set_list, rq_link) {
              CDEBUG(D_INFO, "objid " DOSTID "[%d] has subobj " DOSTID "

at idx%u\n",

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_setattr_async(struct obd_export

Quoted 3 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +0 -0
                     POSTID(&oinfo->oi_oa->o_oi), req->rq_stripe,
                     POSTID(&req->rq_oi.oi_oa->o_oi), req->rq_idx);
@@ -1204,7 +1198,6 @@ static int lov_setattr_async(struct obd_export

*exp, struct obd_info *oinfo,

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_setattr_async(struct obd_export

Quoted 8 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +0 -1
 {
      struct lov_request_set *set;
      struct lov_request *req;
-     struct list_head *pos;
      struct lov_obd *lov;
      int rc = 0;
 
@@ -1228,9 +1221,7 @@ static int lov_setattr_async(struct obd_export

*exp, struct obd_info *oinfo,

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,

Quoted 9 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +1 -3
             oinfo->oi_md->lsm_stripe_count,
             oinfo->oi_md->lsm_stripe_size);
 
-     list_for_each(pos, &set->set_list) {
-             req = list_entry(pos, struct lov_request, rq_link);
-
+     list_for_each_entry(req, &set->set_list, rq_link) {
              if (oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE)
                      oti->oti_logcookies = set->set_cookies +

req->rq_stripe;

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_statfs_async(struct obd_export

Quoted 2 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +0 -0
@@ -1324,7 +1315,6 @@ static int lov_statfs_async(struct obd_export

*exp, struct obd_info *oinfo,

drivers/staging/lustre/lustre/lov/lov_obd.c static int lov_statfs_async(struct obd_export

Quoted 8 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +0 -1
      struct obd_device      *obd = class_exp2obd(exp);
      struct lov_request_set *set;
      struct lov_request *req;
-     struct list_head *pos;
      struct lov_obd *lov;
      int rc = 0;
 
@@ -1335,8 +1325,7 @@ static int lov_statfs_async(struct obd_export

*exp, struct obd_info *oinfo,

Review

Quoted 10 lines
drivers/staging/lustre/lustre/lov/lov_obd.c +1 -2
      if (rc)
              return rc;
 
-     list_for_each(pos, &set->set_list) {
-             req = list_entry(pos, struct lov_request, rq_link);
+     list_for_each_entry(req, &set->set_list, rq_link) {
              rc = obd_statfs_async(lov->lov_tgts[req->rq_idx]->ltd_exp,
                                    &req->rq_oi, max_age, rqset);
              if (rc)
(quoted diff) +0 -0

b/drivers/staging/lustre/lustre/lov/lov_request.c

drivers/staging/lustre/lustre/lov/lov_request.c static int common_attr_done(struct lov_request_set

Quoted 12 lines

index 6c5ae05..34c26ec 100644

drivers/staging/lustre/lustre/lov/lov_request.c +0 -1
@@ -190,7 +190,6 @@ out:
 
 static int common_attr_done(struct lov_request_set *set)
 {
-     struct list_head *pos;
      struct lov_request *req;
      struct obdo *tmp_oa;
      int rc = 0, attrset = 0;
@@ -207,9 +206,7 @@ static int common_attr_done(struct lov_request_set

*set)

Quoted 13 lines
drivers/staging/lustre/lustre/lov/lov_request.c +1 -4
              goto out;
      }
 
-     list_for_each(pos, &set->set_list) {
-             req = list_entry(pos, struct lov_request, rq_link);
-
+     list_for_each_entry(req, &set->set_list, rq_link) {
              if (!req->rq_complete || req->rq_rc)
                      continue;
              if (req->rq_oi.oi_oa->o_valid == 0)   /* inactive stripe */
--

1.9.1

Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines

To post to this group, send email to [email protected]. To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/1456415872-7808-1-git-send-email-bhumirks%40gmail.com
.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 9 lines · Bhumika Goyal

On Thu, Feb 25, 2016 at 9:31 PM, Julia Lawall <[email protected]> wrote:
On Thu, 25 Feb 2016, Bhumika Goyal wrote:

> Use list_for_each_entry instead of list_for_each and list_entry as it
> simplifies the code. Done using coccinelle:

Quoted 7 lines

Did you check in each case that req is not used after the loop?

julia

Yes I checked and req is not used anywhere after list_for_each_entry loop in each case.

OK, it would be good to update the patch with that information. Basically, req should only be used inside the loop.

julia

#4 lore raw
Quoted 19 lines · Julia Lawall
Quoted 3 lines · Bhumika Goyal

On Thu, Feb 25, 2016 at 9:31 PM, Julia Lawall <[email protected]>

Quoted 11 lines · wrote:

On Thu, 25 Feb 2016, Bhumika Goyal wrote:

> Use list_for_each_entry instead of list_for_each and list_entry as it
> simplifies the code. Done using coccinelle:

Did you check in each case that req is not used after the loop?

julia

Quoted 9 lines
Quoted 1 line

Yes I checked and req is not used anywhere after list_for_each_entry

loop in

Quoted 1 line

each case.

OK, it would be good to update the patch with that information. Basically, req should only be used inside the loop.

julia

Ok I will update the patch and send a v2 :D .

Thanks,
Bhumika

#5 lore raw

PATCH v2 1/1 Staging: lustre: lov: Use list_for_each_entry instead of list_for_each

In reply to Bhumika Goyal

Use list_for_each_entry instead of list_for_each and list_entry as it simplifies the code. Done using coccinelle:

@@
type T,T2;
identifier I1,I2;
expression e1,e2;
iterator name list_for_each_entry;
iterator name list_for_each;
@@

- T *I1;
...
- list_for_each(I1,e1)
+ list_for_each_entry(I2,e1,e2)
{
...when!=T *I1;
- I2=list_entry(I1,T2,e2);
...
}
...when!=I2;

@@
type T,T2,T3;
identifier I1,I2,I3;
expression e1,e2;
@@

- T *I1;
+ T3 *I3;
...
- list_for_each(I1,e1)
+ list_for_each_entry(I3,e1,e2)
{
...when!=T *I1;
- T3 *I3=list_entry(I1,T2,e2);
...
}
...when!=I3;

---
Changes in v2:
* Change semantic patch to check for any occurrence of req outside the list_for_each_entry loop.

 drivers/staging/lustre/lustre/lov/lov_obd.c     | 19 ++++---------------
 drivers/staging/lustre/lustre/lov/lov_request.c |  5 +----
 2 files changed, 5 insertions(+), 19 deletions(-)
drivers/staging/lustre/lustre/lov/lov_obd.c +4 -15
index dcaa5a1..1ce7341 100644
@@ -1064,7 +1064,6 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp,
 	struct lov_request_set *set;
 	struct obd_info oinfo;
 	struct lov_request *req;
-	struct list_head *pos;
 	struct lov_obd *lov;
 	int rc = 0, err = 0;
 
@@ -1084,9 +1083,7 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp,
 	if (rc)
 		goto out;
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		if (oa->o_valid & OBD_MD_FLCOOKIE)
 			oti->oti_logcookies = set->set_cookies + req->rq_stripe;
 
@@ -1131,7 +1128,6 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
 {
 	struct lov_request_set *lovset;
 	struct lov_obd *lov;
-	struct list_head *pos;
 	struct lov_request *req;
 	int rc = 0, err;
 
@@ -1151,9 +1147,7 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
 	       POSTID(&oinfo->oi_md->lsm_oi), oinfo->oi_md->lsm_stripe_count,
 	       oinfo->oi_md->lsm_stripe_size);
 
-	list_for_each(pos, &lovset->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &lovset->set_list, rq_link) {
 		CDEBUG(D_INFO, "objid " DOSTID "[%d] has subobj " DOSTID " at idx%u\n",
 		       POSTID(&oinfo->oi_oa->o_oi), req->rq_stripe,
 		       POSTID(&req->rq_oi.oi_oa->o_oi), req->rq_idx);
@@ -1204,7 +1198,6 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
 {
 	struct lov_request_set *set;
 	struct lov_request *req;
-	struct list_head *pos;
 	struct lov_obd *lov;
 	int rc = 0;
 
@@ -1228,9 +1221,7 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
 	       oinfo->oi_md->lsm_stripe_count,
 	       oinfo->oi_md->lsm_stripe_size);
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		if (oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE)
 			oti->oti_logcookies = set->set_cookies + req->rq_stripe;
 
@@ -1324,7 +1315,6 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo,
 	struct obd_device      *obd = class_exp2obd(exp);
 	struct lov_request_set *set;
 	struct lov_request *req;
-	struct list_head *pos;
 	struct lov_obd *lov;
 	int rc = 0;
 
@@ -1335,8 +1325,7 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo,
 	if (rc)
 		return rc;
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		rc = obd_statfs_async(lov->lov_tgts[req->rq_idx]->ltd_exp,
 				      &req->rq_oi, max_age, rqset);
 		if (rc)
drivers/staging/lustre/lustre/lov/lov_request.c +1 -4
index 6c5ae05..34c26ec 100644
@@ -190,7 +190,6 @@ out:
 
 static int common_attr_done(struct lov_request_set *set)
 {
-	struct list_head *pos;
 	struct lov_request *req;
 	struct obdo *tmp_oa;
 	int rc = 0, attrset = 0;
@@ -207,9 +206,7 @@ static int common_attr_done(struct lov_request_set *set)
 		goto out;
 	}
 
-	list_for_each(pos, &set->set_list) {
-		req = list_entry(pos, struct lov_request, rq_link);
-
+	list_for_each_entry(req, &set->set_list, rq_link) {
 		if (!req->rq_complete || req->rq_rc)
 			continue;
 		if (req->rq_oi.oi_oa->o_valid == 0)   /* inactive stripe */
Signature · 1 line
1.9.1