[Devel] [PATCH vz10 v3 09/11] ext4: improve error handling in ext4_sync_files
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Aug 22 22:14:15 MSK 2025
From: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Add err3 variable and improve error handling in blkdev_issue_flush path.
This ensures that -EIO errors are properly propagated while preserving
other error conditions.
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 | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index b77cab6f12c61..aea460d805289 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -180,7 +180,8 @@ int ext4_sync_files(struct file **files, unsigned int *flags, unsigned int nr_fi
{
struct super_block *sb;
journal_t *journal;
- int err = 0, err2 = 0, i = 0, j = 0;
+ int err = 0, err2 = 0, err3 = 0;
+ int i = 0, j = 0;
int force_commit = 0;
tid_t commit_tid = 0;
int need_barrier = 0;
@@ -275,8 +276,11 @@ int ext4_sync_files(struct file **files, unsigned int *flags, unsigned int nr_fi
* it is already done, but not yet in state where we should
* not wait.
*/
- if (need_barrier)
- err2 = blkdev_issue_flush(sb->s_bdev);
+ if (need_barrier) {
+ err3 = blkdev_issue_flush(sb->s_bdev);
+ if (!err2 || err3 == -EIO)
+ err2 = err3;
+ }
}
out:
trace_ext4_sync_files_exit(files[0]->f_path.dentry, commit_tid, need_barrier);
--
2.43.0
More information about the Devel
mailing list