aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorHou Tao <houtao1@huawei.com>2019-05-14 15:44:32 -0700
committerPaul Gortmaker <paul.gortmaker@windriver.com>2019-09-16 12:20:34 -0400
commit7a3acb5ee71e6029873be61ecc55c70acec5ffd3 (patch)
tree7d66f2aa06befc53c7e50044e37b2396fc313caf /fs
parentd690ad91d09d7aaf35e0dac8b7bb180eb8f494e8 (diff)
downloadlinux-yocto-7a3acb5ee71e6029873be61ecc55c70acec5ffd3.tar.gz
linux-yocto-7a3acb5ee71e6029873be61ecc55c70acec5ffd3.tar.bz2
linux-yocto-7a3acb5ee71e6029873be61ecc55c70acec5ffd3.zip
fs/fat/file.c: issue flush after the writeback of FAT
commit bd8309de0d60838eef6fb575b0c4c7e95841cf73 upstream. 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> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'fs')
-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 4724cc9ad650..62581de09bf1 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -160,12 +160,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);
}