diff mbox

ext4: fix mmap data corruption in nodelalloc mode when blocksize < pagesize

Message ID 1423185183-3032-1-git-send-email-wangxg.fnst@cn.fujitsu.com
State Accepted, archived
Headers show

Commit Message

Xiaoguang Wang Feb. 6, 2015, 1:13 a.m. UTC
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>
Reviewed-by:   Jan Kara <jack@suse.cz>
---
 fs/ext4/inode.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Theodore Ts'o Feb. 13, 2015, 4:01 a.m. UTC | #1
On Fri, Feb 06, 2015 at 09:13:03AM +0800, Xiaoguang Wang wrote:
> 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>
> Reviewed-by:   Jan Kara <jack@suse.cz>

Applied, thanks.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 9193ea1..0390e41 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1007,6 +1007,7 @@  static int ext4_write_end(struct file *file,
 {
 	handle_t *handle = ext4_journal_current_handle();
 	struct inode *inode = mapping->host;
+	loff_t old_size = inode->i_size;
 	int ret = 0, ret2;
 	int i_size_changed = 0;
 
@@ -1037,6 +1038,8 @@  static int ext4_write_end(struct file *file,
 	unlock_page(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
 	 * 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();
 	struct inode *inode = mapping->host;
+	loff_t old_size = inode->i_size;
 	int ret = 0, ret2;
 	int partial = 0;
 	unsigned from, to;
@@ -1110,6 +1114,9 @@  static int ext4_journalled_write_end(struct file *file,
 	unlock_page(page);
 	page_cache_release(page);
 
+	if (old_size < pos)
+		pagecache_isize_extended(inode, old_size, pos);
+
 	if (size_changed) {
 		ret2 = ext4_mark_inode_dirty(handle, inode);
 		if (!ret)