[Devel] [PATCH vz10 v3 11/11] ext4: improve formatting in ext4_sync_files
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Aug 22 22:14:17 MSK 2025
From: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Improve code formatting and readability:
- Remove excess braces from single-line if statement
- Fix pointer formatting (remove space before *)
- Add empty lines to improve code structure and readability
And move sb_rdonly(sb) check higher (before accessing s_journal)
to fit ext4_sync_file().
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 | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index 38f32d988ad4c..971830fbc6ff7 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -190,33 +190,35 @@ int ext4_sync_files(struct file **files, unsigned int *flags, unsigned int nr_fi
if (!nr_files)
return 0;
sb = files[0]->f_mapping->host->i_sb;
+
ret = ext4_emergency_state(sb);
if (unlikely(ret))
return ret;
ASSERT(ext4_journal_current_handle() == NULL);
+ if (sb_rdonly(sb))
+ return 0;
+
journal = EXT4_SB(sb)->s_journal;
if (!journal)
return -ENOTSUPP;
- if (sb_rdonly(sb)) {
- return 0;
- }
+
for (i = 0; i < nr_files; i++) {
- struct address_space * mapping = files[i]->f_mapping;
+ struct address_space *mapping = files[i]->f_mapping;
struct inode *inode = mapping->host;
if (sb != inode->i_sb) {
err = -EINVAL;
goto out;
}
+
if (!mapping->nrpages)
continue;
err = filemap_fdatawrite(mapping);
if (err)
break;
-
}
/*
* Even if the above returned error, the pages may be
@@ -228,7 +230,7 @@ int ext4_sync_files(struct file **files, unsigned int *flags, unsigned int nr_fi
goto out;
for (j = 0; j < i; j++) {
- struct address_space * mapping = files[j]->f_mapping;
+ struct address_space *mapping = files[j]->f_mapping;
struct inode *inode = mapping->host;
struct ext4_inode_info *ei = EXT4_I(inode);
unsigned int datasync = flags[j];
--
2.43.0
More information about the Devel
mailing list