Skip to content

Commit

Permalink
f2fs: fix to unmap pages from userspace process in punch_hole()
Browse files Browse the repository at this point in the history
[ Upstream commit c8dc304 ]

We need to unmap pages from userspace process before removing pagecache
in punch_hole() like we did in f2fs_setattr().

Similar change:
commit 5e44f8c ("ext4: hole-punch use truncate_pagecache_range")

Fixes: fbfa2cc ("f2fs: add file operations")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
chaseyu authored and gregkh committed Sep 18, 2021
1 parent 1dfcf66 commit fb3e61f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions fs/f2fs/file.c
Expand Up @@ -1084,7 +1084,6 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
}

if (pg_start < pg_end) {
struct address_space *mapping = inode->i_mapping;
loff_t blk_start, blk_end;
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);

Expand All @@ -1096,8 +1095,7 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
down_write(&F2FS_I(inode)->i_mmap_sem);

truncate_inode_pages_range(mapping, blk_start,
blk_end - 1);
truncate_pagecache_range(inode, blk_start, blk_end - 1);

f2fs_lock_op(sbi);
ret = f2fs_truncate_hole(inode, pg_start, pg_end);
Expand Down

0 comments on commit fb3e61f

Please sign in to comment.