diff options
author | Jan Kara <jack@suse.com> | 2015-12-07 14:34:49 -0500 |
---|---|---|
committer | Sasha Levin <sasha.levin@oracle.com> | 2016-03-23 10:20:24 -0400 |
commit | f2b132595b89d9236b386e1d6ed3fcf5e9edf4cb (patch) | |
tree | 38154cb60c0c2010f6113246b89764c4d5f5ecdc /fs/ext4/extents.c | |
parent | 181aaebde9360b8235df647ee36dafdc041d4964 (diff) |
ext4: fix races of writeback with punch hole and zero range
When doing delayed allocation, update of on-disk inode size is postponed
until IO submission time. However hole punch or zero range fallocate
calls can end up discarding the tail page cache page and thus on-disk
inode size would never be properly updated.
Make sure the on-disk inode size is updated before truncating page
cache.
Signed-off-by: Jan Kara <jack@suse.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Mingming Cao <mingming.cao@oracle.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 8d16a01a0bf0..ea12f565be24 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4824,6 +4824,11 @@ static long ext4_zero_range(struct file *file, loff_t offset, * released from page cache. */ down_write(&EXT4_I(inode)->i_mmap_sem); + ret = ext4_update_disksize_before_punch(inode, offset, len); + if (ret) { + up_write(&EXT4_I(inode)->i_mmap_sem); + goto out_dio; + } /* Now release the pages and zero block aligned part of pages */ truncate_pagecache_range(inode, start, end - 1); inode->i_mtime = inode->i_ctime = ext4_current_time(inode); |