diff options
author | Sungjong Seo <sj1557.seo@samsung.com> | 2020-06-18 20:43:26 +0900 |
---|---|---|
committer | Namjae Jeon <namjae.jeon@samsung.com> | 2020-06-29 17:11:18 +0900 |
commit | 5267456e953fd8c5abd8e278b1cc6a9f9027ac0a (patch) | |
tree | 65250c98c0c38be91b66c7a22bc7c3cd1e136fc3 /fs/exfat/file.c | |
parent | 3bcfb701099acf96b0e883bf5544f96af473aa1d (diff) | |
download | linux-stable-5267456e953fd8c5abd8e278b1cc6a9f9027ac0a.tar.gz linux-stable-5267456e953fd8c5abd8e278b1cc6a9f9027ac0a.tar.bz2 linux-stable-5267456e953fd8c5abd8e278b1cc6a9f9027ac0a.zip |
exfat: flush dirty metadata in fsync
generic_file_fsync() exfat used could not guarantee the consistency of
a file because it has flushed not dirty metadata but only dirty data pages
for a file.
Instead of that, use exfat_file_fsync() for files and directories so that
it guarantees to commit both the metadata and data pages for a file.
Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Diffstat (limited to 'fs/exfat/file.c')
-rw-r--r-- | fs/exfat/file.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/fs/exfat/file.c b/fs/exfat/file.c index fce03f318787..3b7fea465fd4 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -6,6 +6,7 @@ #include <linux/slab.h> #include <linux/cred.h> #include <linux/buffer_head.h> +#include <linux/blkdev.h> #include "exfat_raw.h" #include "exfat_fs.h" @@ -346,12 +347,28 @@ out: return error; } +int exfat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync) +{ + struct inode *inode = filp->f_mapping->host; + int err; + + err = __generic_file_fsync(filp, start, end, datasync); + if (err) + return err; + + err = sync_blockdev(inode->i_sb->s_bdev); + if (err) + return err; + + return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL); +} + const struct file_operations exfat_file_operations = { .llseek = generic_file_llseek, .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .fsync = generic_file_fsync, + .fsync = exfat_file_fsync, .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, }; |