public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter()
@ 2024-09-25 19:54 Markus Elfring
  2024-09-26  3:45 ` Zhang Yi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Markus Elfring @ 2024-09-25 19:54 UTC (permalink / raw)
  To: linux-ext4, Andreas Dilger, Jan Kara, Matthew Bobrowski,
	Ritesh Harjani, Theodore Ts'o
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 25 Sep 2024 21:47:39 +0200

An ext4_journal_stop(handle) call was immediately used after a return value
check for a ext4_orphan_add() call in this function implementation.
Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/ext4/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index f14aed14b9cf..23005f1345a8 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -564,12 +564,9 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
 		}

 		ret = ext4_orphan_add(handle, inode);
-		if (ret) {
-			ext4_journal_stop(handle);
-			goto out;
-		}
-
 		ext4_journal_stop(handle);
+		if (ret)
+			goto out;
 	}

 	if (ilock_shared && !unwritten)
--
2.46.1


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

* Re: [PATCH] ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter()
  2024-09-25 19:54 [PATCH] ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter() Markus Elfring
@ 2024-09-26  3:45 ` Zhang Yi
  2024-09-26  7:55 ` Jan Kara
  2024-10-31 14:33 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Zhang Yi @ 2024-09-26  3:45 UTC (permalink / raw)
  To: Markus Elfring, linux-ext4, Andreas Dilger, Jan Kara,
	Matthew Bobrowski, Ritesh Harjani, Theodore Ts'o
  Cc: LKML, kernel-janitors

On 2024/9/26 3:54, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 25 Sep 2024 21:47:39 +0200
> 
> An ext4_journal_stop(handle) call was immediately used after a return value
> check for a ext4_orphan_add() call in this function implementation.
> Thus call such a function only once instead directly before the check.
> 
> This issue was transformed by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Looks good to me.

Reviewed-by: Zhang Yi <yi.zhang@huawei.com>

> ---
>  fs/ext4/file.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index f14aed14b9cf..23005f1345a8 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -564,12 +564,9 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
>  		}
> 
>  		ret = ext4_orphan_add(handle, inode);
> -		if (ret) {
> -			ext4_journal_stop(handle);
> -			goto out;
> -		}
> -
>  		ext4_journal_stop(handle);
> +		if (ret)
> +			goto out;
>  	}
> 
>  	if (ilock_shared && !unwritten)
> --
> 2.46.1
> 
> 


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

* Re: [PATCH] ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter()
  2024-09-25 19:54 [PATCH] ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter() Markus Elfring
  2024-09-26  3:45 ` Zhang Yi
@ 2024-09-26  7:55 ` Jan Kara
  2024-10-31 14:33 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2024-09-26  7:55 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-ext4, Andreas Dilger, Jan Kara, Matthew Bobrowski,
	Ritesh Harjani, Theodore Ts'o, LKML, kernel-janitors

On Wed 25-09-24 21:54:18, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 25 Sep 2024 21:47:39 +0200
> 
> An ext4_journal_stop(handle) call was immediately used after a return value
> check for a ext4_orphan_add() call in this function implementation.
> Thus call such a function only once instead directly before the check.
> 
> This issue was transformed by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/file.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ext4/file.c b/fs/ext4/file.c
> index f14aed14b9cf..23005f1345a8 100644
> --- a/fs/ext4/file.c
> +++ b/fs/ext4/file.c
> @@ -564,12 +564,9 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
>  		}
> 
>  		ret = ext4_orphan_add(handle, inode);
> -		if (ret) {
> -			ext4_journal_stop(handle);
> -			goto out;
> -		}
> -
>  		ext4_journal_stop(handle);
> +		if (ret)
> +			goto out;
>  	}
> 
>  	if (ilock_shared && !unwritten)
> --
> 2.46.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH] ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter()
  2024-09-25 19:54 [PATCH] ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter() Markus Elfring
  2024-09-26  3:45 ` Zhang Yi
  2024-09-26  7:55 ` Jan Kara
@ 2024-10-31 14:33 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2024-10-31 14:33 UTC (permalink / raw)
  To: linux-ext4, Andreas Dilger, Jan Kara, Matthew Bobrowski,
	Ritesh Harjani, Markus Elfring
  Cc: Theodore Ts'o, LKML, kernel-janitors


On Wed, 25 Sep 2024 21:54:18 +0200, Markus Elfring wrote:
> An ext4_journal_stop(handle) call was immediately used after a return value
> check for a ext4_orphan_add() call in this function implementation.
> Thus call such a function only once instead directly before the check.
> 
> This issue was transformed by using the Coccinelle software.
> 
> 
> [...]

Applied, thanks!

[1/1] ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter()
      commit: d431a2cd28e8b7a91474d496e9226ef06a31c6eb

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

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

end of thread, other threads:[~2024-10-31 14:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25 19:54 [PATCH] ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter() Markus Elfring
2024-09-26  3:45 ` Zhang Yi
2024-09-26  7:55 ` Jan Kara
2024-10-31 14:33 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox