The patch titled Subject: fs/fat/file.c: issue flush after the writeback of FAT has been added to the -mm tree. Its filename is fat-issue-flush-after-the-writeback-of-fat.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/fat-issue-flush-after-the-writeback-of-fat.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/fat-issue-flush-after-the-writeback-of-fat.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Hou Tao <houtao1@xxxxxxxxxx> Subject: fs/fat/file.c: issue flush after the writeback of FAT fsync() needs to make sure the data & meta-data of file are persistent after the return of fsync(), even when a power-failure occurs later. In the case of fat-fs, the FAT belongs to the meta-data of file, so we need to issue a flush after the writeback of FAT instead before. Also bail out early when any stage of fsync fails. Link: http://lkml.kernel.org/r/20190409030158.136316-1-houtao1@xxxxxxxxxx Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx> Acked-by: OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Jan Kara <jack@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/fat/file.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/fs/fat/file.c~fat-issue-flush-after-the-writeback-of-fat +++ a/fs/fat/file.c @@ -193,12 +193,17 @@ static int fat_file_release(struct inode int fat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync) { struct inode *inode = filp->f_mapping->host; - int res, err; + int err; + + err = __generic_file_fsync(filp, start, end, datasync); + if (err) + return err; - res = generic_file_fsync(filp, start, end, datasync); err = sync_mapping_buffers(MSDOS_SB(inode->i_sb)->fat_inode->i_mapping); + if (err) + return err; - return res ? res : err; + return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL); } _ Patches currently in -mm which might be from houtao1@xxxxxxxxxx are fat-issue-flush-after-the-writeback-of-fat.patch