1 ext4: fix mmap data corruption in nodelalloc mode when blocksize < pagesize
3 From: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
5 Since commit 90a8020 and d6320cb, Jan Kara has fixed this issue partially.
6 This mmap data corruption still exists in nodelalloc mode, fix this.
8 Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 Reviewed-by: Jan Kara <jack@suse.cz>
12 fs/ext4/inode.c | 7 +++++++
13 1 file changed, 7 insertions(+)
15 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
16 index 9193ea1..0390e41 100644
19 @@ -1007,6 +1007,7 @@ static int ext4_write_end(struct file *file,
21 handle_t *handle = ext4_journal_current_handle();
22 struct inode *inode = mapping->host;
23 + loff_t old_size = inode->i_size;
25 int i_size_changed = 0;
27 @@ -1037,6 +1038,8 @@ static int ext4_write_end(struct file *file,
29 page_cache_release(page);
32 + pagecache_isize_extended(inode, old_size, pos);
34 * Don't mark the inode dirty under page lock. First, it unnecessarily
35 * makes the holding time of page lock longer. Second, it forces lock
36 @@ -1078,6 +1081,7 @@ static int ext4_journalled_write_end(struct file *file,
38 handle_t *handle = ext4_journal_current_handle();
39 struct inode *inode = mapping->host;
40 + loff_t old_size = inode->i_size;
44 @@ -1110,6 +1114,9 @@ static int ext4_journalled_write_end(struct file *file,
46 page_cache_release(page);
49 + pagecache_isize_extended(inode, old_size, pos);
52 ret2 = ext4_mark_inode_dirty(handle, inode);