Skip to content

Commit 5679897

Browse files
author
Darrick J. Wong
committed
vfs: make sync_filesystem return errors from ->sync_fs
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: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Christian Brauner <brauner@kernel.org>
1 parent 2719c71 commit 5679897

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

fs/sync.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
int sync_filesystem(struct super_block *sb)
3131
{
32-
int ret;
32+
int ret = 0;
3333

3434
/*
3535
* We need to be protected against the filesystem going from
@@ -52,15 +52,21 @@ int sync_filesystem(struct super_block *sb)
5252
* at a time.
5353
*/
5454
writeback_inodes_sb(sb, WB_REASON_SYNC);
55-
if (sb->s_op->sync_fs)
56-
sb->s_op->sync_fs(sb, 0);
55+
if (sb->s_op->sync_fs) {
56+
ret = sb->s_op->sync_fs(sb, 0);
57+
if (ret)
58+
return ret;
59+
}
5760
ret = sync_blockdev_nowait(sb->s_bdev);
58-
if (ret < 0)
61+
if (ret)
5962
return ret;
6063

6164
sync_inodes_sb(sb);
62-
if (sb->s_op->sync_fs)
63-
sb->s_op->sync_fs(sb, 1);
65+
if (sb->s_op->sync_fs) {
66+
ret = sb->s_op->sync_fs(sb, 1);
67+
if (ret)
68+
return ret;
69+
}
6470
return sync_blockdev(sb->s_bdev);
6571
}
6672
EXPORT_SYMBOL(sync_filesystem);

0 commit comments

Comments
 (0)