[Devel] [PATCH vz10 v3 04/11] ext4: check journal early in ext4_sync_files

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 22 22:14:10 MSK 2025


From: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

Move journal availability check earlier in the function, right after
obtaining the journal pointer. This allows for early exit when
no journal is available, improving code flow and readability.

Part of rework for ext4_sync_files function.

Fixes: 26337aacaafa9 ("ext4: add mfsync support")
https://virtuozzo.atlassian.net/browse/VSTOR-107255
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

Feature: ext4: optimized sync of a set of files - mfsync()
---
 fs/ext4/fsync.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index f31086efb7977..9905b2363908f 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -196,6 +196,8 @@ int ext4_sync_files(struct file **files, unsigned int *flags, unsigned int nr_fi
 	J_ASSERT(ext4_journal_current_handle() == NULL);
 
 	journal = EXT4_SB(sb)->s_journal;
+	if (!journal)
+		 return -ENOTSUPP;
 	if (sb_rdonly(sb)) {
 		return 0;
 	}
@@ -247,9 +249,7 @@ int ext4_sync_files(struct file **files, unsigned int *flags, unsigned int nr_fi
 	}
 
 	/* Ext4 specific stuff starts here */
-	if (!journal) {
-		 return -ENOTSUPP;
-	} else if (force_commit) {
+	if (force_commit) {
 		/* data=journal:
 		 *  filemap_fdatawrite won't do anything (the buffers are clean).
 		 *  ext4_force_commit will write the file data into the journal and
-- 
2.43.0



More information about the Devel mailing list