提交 5d863c42 编写于 作者: D Darrick J. Wong 提交者: Zheng Zengkai

vfs: make sync_filesystem return errors from ->sync_fs

stable inclusion
from stable-v5.10.140
commit 76a51e49da9c9919b97225982d720da5315ebaa7
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I63FTT

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=76a51e49da9c9919b97225982d720da5315ebaa7

--------------------------------

commit 5679897e upstream.

[backport to 5.10 only differs in __sync_blockdev helper]

Strangely, sync_filesystem ignores the return code from the ->sync_fs
call, which means that syscalls like syncfs(2) never see the error.
This doesn't seem right, so fix that.
Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
Reviewed-by: NJan Kara <jack@suse.cz>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Acked-by: NChristian Brauner <brauner@kernel.org>
Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
Acked-by: NDarrick J. Wong <djwong@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 74626600
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
*/ */
int sync_filesystem(struct super_block *sb) int sync_filesystem(struct super_block *sb)
{ {
int ret; int ret = 0;
/* /*
* We need to be protected against the filesystem going from * We need to be protected against the filesystem going from
...@@ -51,15 +51,21 @@ int sync_filesystem(struct super_block *sb) ...@@ -51,15 +51,21 @@ int sync_filesystem(struct super_block *sb)
* at a time. * at a time.
*/ */
writeback_inodes_sb(sb, WB_REASON_SYNC); writeback_inodes_sb(sb, WB_REASON_SYNC);
if (sb->s_op->sync_fs) if (sb->s_op->sync_fs) {
sb->s_op->sync_fs(sb, 0); ret = sb->s_op->sync_fs(sb, 0);
if (ret)
return ret;
}
ret = __sync_blockdev(sb->s_bdev, 0); ret = __sync_blockdev(sb->s_bdev, 0);
if (ret < 0) if (ret)
return ret; return ret;
sync_inodes_sb(sb); sync_inodes_sb(sb);
if (sb->s_op->sync_fs) if (sb->s_op->sync_fs) {
sb->s_op->sync_fs(sb, 1); ret = sb->s_op->sync_fs(sb, 1);
if (ret)
return ret;
}
return __sync_blockdev(sb->s_bdev, 1); return __sync_blockdev(sb->s_bdev, 1);
} }
EXPORT_SYMBOL(sync_filesystem); EXPORT_SYMBOL(sync_filesystem);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册