linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: Change list_for_each to list_for_each_entry
       [not found] <CGME20201231015213epcms2p5ef76aa6b26ab74e045a86f6a13b31d51@epcms2p5>
@ 2020-12-31  1:52 ` Daejun Park
  2021-01-05 21:56   ` harshad shirwadkar
  0 siblings, 1 reply; 4+ messages in thread
From: Daejun Park @ 2020-12-31  1:52 UTC (permalink / raw)
  To: tytso, adilger.kernel; +Cc: linux-kernel, linux-ext4

list_for_each + list_entry can be changed to list_for_each_entry
It reduces number of variables and lines.

Signed-off-by: Daejun Park <daejun7.park@samsung.com>
---
 fs/ext4/fast_commit.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
index 5b6bb3ef0f33..dc58471971db 100644
--- a/fs/ext4/fast_commit.c
+++ b/fs/ext4/fast_commit.c
@@ -915,13 +915,11 @@ static int ext4_fc_submit_inode_data_all(journal_t *journal)
 	struct super_block *sb = (struct super_block *)(journal->j_private);
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	struct ext4_inode_info *ei;
-	struct list_head *pos;
 	int ret = 0;
 
 	spin_lock(&sbi->s_fc_lock);
 	ext4_set_mount_flag(sb, EXT4_MF_FC_COMMITTING);
-	list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
-		ei = list_entry(pos, struct ext4_inode_info, i_fc_list);
+	list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {
 		ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING);
 		while (atomic_read(&ei->i_fc_updates)) {
 			DEFINE_WAIT(wait);
@@ -1099,8 +1097,7 @@ static int ext4_fc_perform_commit(journal_t *journal)
 		goto out;
 	}
 
-	list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
-		iter = list_entry(pos, struct ext4_inode_info, i_fc_list);
+	list_for_each_entry(iter, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {
 		inode = &iter->vfs_inode;
 		if (!ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING))
 			continue;
-- 
2.25.1


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

* Re: [PATCH] ext4: Change list_for_each to list_for_each_entry
  2020-12-31  1:52 ` [PATCH] ext4: Change list_for_each to list_for_each_entry Daejun Park
@ 2021-01-05 21:56   ` harshad shirwadkar
  2021-01-08 23:00     ` harshad shirwadkar
       [not found]     ` <CGME20201231015213epcms2p5ef76aa6b26ab74e045a86f6a13b31d51@epcms2p6>
  0 siblings, 2 replies; 4+ messages in thread
From: harshad shirwadkar @ 2021-01-05 21:56 UTC (permalink / raw)
  To: daejun7.park; +Cc: tytso, adilger.kernel, linux-kernel, linux-ext4

Looks good to me, thanks!

Reviewed-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>

On Wed, Dec 30, 2020 at 5:56 PM Daejun Park <daejun7.park@samsung.com> wrote:
>
> list_for_each + list_entry can be changed to list_for_each_entry
> It reduces number of variables and lines.
>
> Signed-off-by: Daejun Park <daejun7.park@samsung.com>
> ---
>  fs/ext4/fast_commit.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> index 5b6bb3ef0f33..dc58471971db 100644
> --- a/fs/ext4/fast_commit.c
> +++ b/fs/ext4/fast_commit.c
> @@ -915,13 +915,11 @@ static int ext4_fc_submit_inode_data_all(journal_t *journal)
>         struct super_block *sb = (struct super_block *)(journal->j_private);
>         struct ext4_sb_info *sbi = EXT4_SB(sb);
>         struct ext4_inode_info *ei;
> -       struct list_head *pos;
>         int ret = 0;
>
>         spin_lock(&sbi->s_fc_lock);
>         ext4_set_mount_flag(sb, EXT4_MF_FC_COMMITTING);
> -       list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
> -               ei = list_entry(pos, struct ext4_inode_info, i_fc_list);
> +       list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {
>                 ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING);
>                 while (atomic_read(&ei->i_fc_updates)) {
>                         DEFINE_WAIT(wait);
> @@ -1099,8 +1097,7 @@ static int ext4_fc_perform_commit(journal_t *journal)
>                 goto out;
>         }
>
> -       list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
> -               iter = list_entry(pos, struct ext4_inode_info, i_fc_list);
> +       list_for_each_entry(iter, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {
>                 inode = &iter->vfs_inode;
>                 if (!ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING))
>                         continue;
> --
> 2.25.1
>

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

* Re: [PATCH] ext4: Change list_for_each to list_for_each_entry
  2021-01-05 21:56   ` harshad shirwadkar
@ 2021-01-08 23:00     ` harshad shirwadkar
       [not found]     ` <CGME20201231015213epcms2p5ef76aa6b26ab74e045a86f6a13b31d51@epcms2p6>
  1 sibling, 0 replies; 4+ messages in thread
From: harshad shirwadkar @ 2021-01-08 23:00 UTC (permalink / raw)
  To: daejun7.park; +Cc: tytso, adilger.kernel, linux-kernel, linux-ext4

Hey Daejun,

I was taking a look at this again, and just noticed one quick thing:

On Tue, Jan 5, 2021 at 1:56 PM harshad shirwadkar
<harshadshirwadkar@gmail.com> wrote:
>
> Looks good to me, thanks!
>
> Reviewed-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
>
> On Wed, Dec 30, 2020 at 5:56 PM Daejun Park <daejun7.park@samsung.com> wrote:
> >
> > list_for_each + list_entry can be changed to list_for_each_entry
> > It reduces number of variables and lines.
> >
> > Signed-off-by: Daejun Park <daejun7.park@samsung.com>
> > ---
> >  fs/ext4/fast_commit.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> > index 5b6bb3ef0f33..dc58471971db 100644
> > --- a/fs/ext4/fast_commit.c
> > +++ b/fs/ext4/fast_commit.c
> > @@ -915,13 +915,11 @@ static int ext4_fc_submit_inode_data_all(journal_t *journal)
> >         struct super_block *sb = (struct super_block *)(journal->j_private);
> >         struct ext4_sb_info *sbi = EXT4_SB(sb);
> >         struct ext4_inode_info *ei;
> > -       struct list_head *pos;
> >         int ret = 0;
> >
> >         spin_lock(&sbi->s_fc_lock);
> >         ext4_set_mount_flag(sb, EXT4_MF_FC_COMMITTING);
> > -       list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
> > -               ei = list_entry(pos, struct ext4_inode_info, i_fc_list);
> > +       list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {
> >                 ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING);
> >                 while (atomic_read(&ei->i_fc_updates)) {
> >                         DEFINE_WAIT(wait);
> > @@ -1099,8 +1097,7 @@ static int ext4_fc_perform_commit(journal_t *journal)
> >                 goto out;
> >         }
> >
> > -       list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
> > -               iter = list_entry(pos, struct ext4_inode_info, i_fc_list);
Variable "pos" isn't used anymore after this patch. You removed it for
the ext4_fc_submit_inode_data_all() function, but missed removing it
in this function. That's throwing me a warning.

Thanks,
Harshad

> > +       list_for_each_entry(iter, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {
> >                 inode = &iter->vfs_inode;
> >                 if (!ext4_test_inode_state(inode, EXT4_STATE_FC_COMMITTING))
> >                         continue;
> > --
> > 2.25.1
> >

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

* RE: Re: [PATCH] ext4: Change list_for_each to list_for_each_entry
       [not found]     ` <CGME20201231015213epcms2p5ef76aa6b26ab74e045a86f6a13b31d51@epcms2p6>
@ 2021-01-11  1:18       ` Daejun Park
  0 siblings, 0 replies; 4+ messages in thread
From: Daejun Park @ 2021-01-11  1:18 UTC (permalink / raw)
  To: harshad shirwadkar, Daejun Park
  Cc: tytso, adilger.kernel, linux-kernel, linux-ext4

Hi Harshad,

> > > list_for_each + list_entry can be changed to list_for_each_entry
> > > It reduces number of variables and lines.
> > >
> > > Signed-off-by: Daejun Park <daejun7.park@samsung.com>
> > > ---
> > >  fs/ext4/fast_commit.c | 7 ++-----
> > >  1 file changed, 2 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c
> > > index 5b6bb3ef0f33..dc58471971db 100644
> > > --- a/fs/ext4/fast_commit.c
> > > +++ b/fs/ext4/fast_commit.c
> > > @@ -915,13 +915,11 @@ static int ext4_fc_submit_inode_data_all(journal_t *journal)
> > >         struct super_block *sb = (struct super_block *)(journal->j_private);
> > >         struct ext4_sb_info *sbi = EXT4_SB(sb);
> > >         struct ext4_inode_info *ei;
> > > -       struct list_head *pos;
> > >         int ret = 0;
> > >
> > >         spin_lock(&sbi->s_fc_lock);
> > >         ext4_set_mount_flag(sb, EXT4_MF_FC_COMMITTING);
> > > -       list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
> > > -               ei = list_entry(pos, struct ext4_inode_info, i_fc_list);
> > > +       list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {
> > >                 ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING);
> > >                 while (atomic_read(&ei->i_fc_updates)) {
> > >                         DEFINE_WAIT(wait);
> > > @@ -1099,8 +1097,7 @@ static int ext4_fc_perform_commit(journal_t *journal)
> > >                 goto out;
> > >         }
> > >
> > > -       list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
> > > -               iter = list_entry(pos, struct ext4_inode_info, i_fc_list);
> Variable "pos" isn't used anymore after this patch. You removed it for
> the ext4_fc_submit_inode_data_all() function, but missed removing it
> in this function. That's throwing me a warning.
> 
Thanks for comment, I will remove this. And I will change some list_for_each_safe
macro at new patch.

Thanks,
Daejun

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

end of thread, other threads:[~2021-01-11  1:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20201231015213epcms2p5ef76aa6b26ab74e045a86f6a13b31d51@epcms2p5>
2020-12-31  1:52 ` [PATCH] ext4: Change list_for_each to list_for_each_entry Daejun Park
2021-01-05 21:56   ` harshad shirwadkar
2021-01-08 23:00     ` harshad shirwadkar
     [not found]     ` <CGME20201231015213epcms2p5ef76aa6b26ab74e045a86f6a13b31d51@epcms2p6>
2021-01-11  1:18       ` Daejun Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).