mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
ext4: fix mmap data corruption in nodelalloc mode when blocksize < pagesize
Since commit 90a8020 and d6320cb, Jan Kara has fixed this issue partially. This mmap data corruption still exists in nodelalloc mode, fix this. Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
2cb5cc8b09
commit
0572639ff6
@ -1007,6 +1007,7 @@ static int ext4_write_end(struct file *file,
|
|||||||
{
|
{
|
||||||
handle_t *handle = ext4_journal_current_handle();
|
handle_t *handle = ext4_journal_current_handle();
|
||||||
struct inode *inode = mapping->host;
|
struct inode *inode = mapping->host;
|
||||||
|
loff_t old_size = inode->i_size;
|
||||||
int ret = 0, ret2;
|
int ret = 0, ret2;
|
||||||
int i_size_changed = 0;
|
int i_size_changed = 0;
|
||||||
|
|
||||||
@ -1037,6 +1038,8 @@ static int ext4_write_end(struct file *file,
|
|||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
page_cache_release(page);
|
page_cache_release(page);
|
||||||
|
|
||||||
|
if (old_size < pos)
|
||||||
|
pagecache_isize_extended(inode, old_size, pos);
|
||||||
/*
|
/*
|
||||||
* Don't mark the inode dirty under page lock. First, it unnecessarily
|
* Don't mark the inode dirty under page lock. First, it unnecessarily
|
||||||
* makes the holding time of page lock longer. Second, it forces lock
|
* makes the holding time of page lock longer. Second, it forces lock
|
||||||
@ -1078,6 +1081,7 @@ static int ext4_journalled_write_end(struct file *file,
|
|||||||
{
|
{
|
||||||
handle_t *handle = ext4_journal_current_handle();
|
handle_t *handle = ext4_journal_current_handle();
|
||||||
struct inode *inode = mapping->host;
|
struct inode *inode = mapping->host;
|
||||||
|
loff_t old_size = inode->i_size;
|
||||||
int ret = 0, ret2;
|
int ret = 0, ret2;
|
||||||
int partial = 0;
|
int partial = 0;
|
||||||
unsigned from, to;
|
unsigned from, to;
|
||||||
@ -1110,6 +1114,9 @@ static int ext4_journalled_write_end(struct file *file,
|
|||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
page_cache_release(page);
|
page_cache_release(page);
|
||||||
|
|
||||||
|
if (old_size < pos)
|
||||||
|
pagecache_isize_extended(inode, old_size, pos);
|
||||||
|
|
||||||
if (size_changed) {
|
if (size_changed) {
|
||||||
ret2 = ext4_mark_inode_dirty(handle, inode);
|
ret2 = ext4_mark_inode_dirty(handle, inode);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user