Skip to content

Commit

Permalink
ext4: fix mmap data corruption when blocksize < pagesize
Browse files Browse the repository at this point in the history
Use truncate_isize_extended() when hole is being created in a file so that
->page_mkwrite() will get called for the partial tail page if it is
mmaped (see the first patch in the series for details).

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
  • Loading branch information
Jan Kara authored and Theodore Ts'o committed Oct 2, 2014
1 parent 90a8020 commit d6320cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4514,8 +4514,12 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
ext4_orphan_del(NULL, inode);
goto err_out;
}
} else
} else {
loff_t oldsize = inode->i_size;

i_size_write(inode, attr->ia_size);
pagecache_isize_extended(inode, oldsize, inode->i_size);
}

/*
* Blocks are going to be removed from the inode. Wait
Expand Down

0 comments on commit d6320cb

Please sign in to comment.