Skip to content

Commit

Permalink
fs/fat/file.c: issue flush after the writeback of FAT
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Hou Tao <[email protected]>
Acked-by: OGAWA Hirofumi <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Jan Kara <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Hou Tao authored and torvalds committed May 15, 2019
1 parent 672cdd5 commit bd8309d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fs/fat/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,17 @@ static int fat_file_release(struct inode *inode, struct file *filp)
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);
}


Expand Down

0 comments on commit bd8309d

Please sign in to comment.