f2fs: fix to propagate error from f2fs_sync_fs()

So that caller can detect any failure from f2fs_sync_fs().

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Chao Yu 2026-08-12 12:20:43 +00:00 committed by Jaegeuk Kim
parent a2c73a7a67
commit dafb84f092
2 changed files with 39 additions and 16 deletions

View File

@ -402,8 +402,11 @@ static int f2fs_create(struct mnt_idmap *idmap, struct inode *dir,
d_instantiate_new(dentry, inode);
if (IS_DIRSYNC(dir))
f2fs_sync_fs(sbi->sb, 1);
if (IS_DIRSYNC(dir)) {
err = f2fs_sync_fs(sbi->sb, 1);
if (err)
return err;
}
f2fs_balance_fs(sbi, true);
return 0;
@ -455,8 +458,11 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
d_instantiate(dentry, inode);
if (IS_DIRSYNC(dir))
f2fs_sync_fs(sbi->sb, 1);
if (IS_DIRSYNC(dir)) {
err = f2fs_sync_fs(sbi->sb, 1);
if (err)
return err;
}
return 0;
out:
clear_inode_flag(inode, FI_INC_LINK);
@ -626,8 +632,11 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir))
d_invalidate(dentry);
if (IS_DIRSYNC(dir))
f2fs_sync_fs(sbi->sb, 1);
if (IS_DIRSYNC(dir)) {
err = f2fs_sync_fs(sbi->sb, 1);
if (err)
goto out;
}
goto out;
corrupted:
@ -719,7 +728,7 @@ static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
disk_link.len - 1);
if (!err && IS_DIRSYNC(dir))
f2fs_sync_fs(sbi->sb, 1);
err = f2fs_sync_fs(sbi->sb, 1);
}
if (err)
@ -771,8 +780,11 @@ static struct dentry *f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
d_instantiate_new(dentry, inode);
if (IS_DIRSYNC(dir))
f2fs_sync_fs(sbi->sb, 1);
if (IS_DIRSYNC(dir)) {
err = f2fs_sync_fs(sbi->sb, 1);
if (err)
return ERR_PTR(err);
}
f2fs_balance_fs(sbi, true);
return NULL;
@ -826,8 +838,11 @@ static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir,
d_instantiate_new(dentry, inode);
if (IS_DIRSYNC(dir))
f2fs_sync_fs(sbi->sb, 1);
if (IS_DIRSYNC(dir)) {
err = f2fs_sync_fs(sbi->sb, 1);
if (err)
return err;
}
f2fs_balance_fs(sbi, true);
return 0;
@ -1126,8 +1141,11 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
f2fs_unlock_op(sbi, &lc);
if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir))
f2fs_sync_fs(sbi->sb, 1);
if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) {
err = f2fs_sync_fs(sbi->sb, 1);
if (err)
return err;
}
f2fs_update_time(sbi, REQ_TIME);
return 0;
@ -1293,8 +1311,11 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
f2fs_unlock_op(sbi, &lc);
if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir))
f2fs_sync_fs(sbi->sb, 1);
if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) {
err = f2fs_sync_fs(sbi->sb, 1);
if (err)
return err;
}
f2fs_update_time(sbi, REQ_TIME);
return 0;

View File

@ -2960,7 +2960,9 @@ static int __f2fs_remount(struct fs_context *fc, struct super_block *sb)
set_sbi_flag(sbi, SBI_IS_DIRTY);
set_sbi_flag(sbi, SBI_IS_CLOSE);
f2fs_sync_fs(sb, 1);
err = f2fs_sync_fs(sb, 1);
if (err)
goto restore_gc;
clear_sbi_flag(sbi, SBI_IS_CLOSE);
}