Skip to contentSkip to conversation

ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter()

PATCH Applied Markus Elfring 4 participants 4 messages Sep 25, 2024 – Oct 31, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: Call ext4_journal_stop(handle) only once in ext4_dio_write_iter()

From: Markus Elfring <[email protected]>
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.

---
 fs/ext4/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/ext4/file.c +2 -5
index f14aed14b9cf..23005f1345a8 100644
@@ -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

reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Markus Elfring

From: Markus Elfring <[email protected]>
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.

Looks good to me.

Quoted 27 lines
---
 fs/ext4/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/ext4/file.c +2 -6
index f14aed14b9cf..23005f1345a8 100644
@@ -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

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Markus Elfring
Quoted 10 lines · Markus Elfring

From: Markus Elfring <[email protected]>
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.

Looks good. Feel free to add:

Honza

Quoted 26 lines
---
 fs/ext4/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/ext4/file.c +2 -6
index f14aed14b9cf..23005f1345a8 100644
@@ -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

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Applied
#3 lore raw
In reply to Markus Elfring
Quoted 8 lines · Markus Elfring

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,

Signature · 1 line
Theodore Ts'o <[email protected]>