]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
f2fs: fix to unmap pages from userspace process in punch_hole()
authorChao Yu <chao@kernel.org>
Wed, 25 Aug 2021 11:34:19 +0000 (19:34 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 09:48:02 +0000 (11:48 +0200)
[ Upstream commit c8dc3047c48540183744f959412d44b08c5435e1 ]

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

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

Fixes: fbfa2cc58d53 ("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>
fs/f2fs/file.c

index 95330dfdbb1aff3e48209855fbe88eb6cf743d28..2a7249496c57e9038052c5c2709ef5648e1a03ac 100644 (file)
@@ -957,7 +957,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);
 
@@ -969,8 +968,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);