f2fs: fix remove page failed in invalidate compress pages
authorFengnan Chang <changfengnan@vivo.com>
Fri, 26 Nov 2021 10:19:19 +0000 (18:19 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:05:29 +0000 (11:05 +0100)
commit d1917865a7906baf6b687e15e8e6195a295a3992 upstream.

Since compress inode not a regular file, generic_error_remove_page in
f2fs_invalidate_compress_pages will always be failed, set compress
inode as a regular file to fix it.

Fixes: 6ce19aff0b8c ("f2fs: compress: add compress_inode to cache compressed blocks")
Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/f2fs/inode.c

index 1213f15ffd68c24c07a34862cb9f4ce5d084f56b..4557de37a91192c7ed14b2b3d76e6b01e350acaa 100644 (file)
@@ -516,6 +516,11 @@ make_now:
        } else if (ino == F2FS_COMPRESS_INO(sbi)) {
 #ifdef CONFIG_F2FS_FS_COMPRESSION
                inode->i_mapping->a_ops = &f2fs_compress_aops;
+               /*
+                * generic_error_remove_page only truncates pages of regular
+                * inode
+                */
+               inode->i_mode |= S_IFREG;
 #endif
                mapping_set_gfp_mask(inode->i_mapping,
                        GFP_NOFS | __GFP_HIGHMEM | __GFP_MOVABLE);