Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+12 -6
+12 -6
fs/sync.c
··· 29 29 */ 30 30 int sync_filesystem(struct super_block *sb) 31 31 { 32 - int ret; 32 + int ret = 0; 33 33 34 34 /* 35 35 * We need to be protected against the filesystem going from ··· 52 52 * at a time. 53 53 */ 54 54 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 + } 57 60 ret = sync_blockdev_nowait(sb->s_bdev); 58 - if (ret < 0) 61 + if (ret) 59 62 return ret; 60 63 61 64 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 + } 64 70 return sync_blockdev(sb->s_bdev); 65 71 } 66 72 EXPORT_SYMBOL(sync_filesystem);