summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHou Tao <houtao1@huawei.com>2019-05-14 18:44:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-14 22:52:50 -0400
commitbd8309de0d60838eef6fb575b0c4c7e95841cf73 (patch)
treec086d652c070b17f5dadd47fc209648fd9a834d1
parent672cdd56f0ae95069e399db790dbf2e303ac72b7 (diff)
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@huawei.com Signed-off-by: Hou Tao <houtao1@huawei.com> Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/fat/file.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/fat/file.c b/fs/fat/file.c
index b3bed32946b1..0e3ed79fcc3f 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -193,12 +193,17 @@ static int fat_file_release(struct inode *inode, struct file *filp)
193int fat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync) 193int fat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
194{ 194{
195 struct inode *inode = filp->f_mapping->host; 195 struct inode *inode = filp->f_mapping->host;
196 int res, err; 196 int err;
197
198 err = __generic_file_fsync(filp, start, end, datasync);
199 if (err)
200 return err;
197 201
198 res = generic_file_fsync(filp, start, end, datasync);
199 err = sync_mapping_buffers(MSDOS_SB(inode->i_sb)->fat_inode->i_mapping); 202 err = sync_mapping_buffers(MSDOS_SB(inode->i_sb)->fat_inode->i_mapping);
203 if (err)
204 return err;
200 205
201 return res ? res : err; 206 return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
202} 207}
203 208
204 209