If compress_extension is set, and a newly created file matches the
extension, the file could be marked as compression file. However,
if inline_data is also enabled, there is no chance to check its
extension since f2fs_should_compress() always returns false.
So if a new file is created (its inode has I_NEW flag and must have
no pin/atomic/swap flag), instead of calling f2fs_should_compress(),
checking its file type is enough here.
Signed-off-by: Sheng Yong <shengyong@xxxxxxxx>
---
fs/f2fs/namei.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index e104409c3a0e5..99dbd051ae0ba 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -295,9 +295,14 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,
if (!f2fs_sb_has_compression(sbi) ||
F2FS_I(inode)->i_flags & F2FS_NOCOMP_FL ||
- !f2fs_may_compress(inode) ||
(!ext_cnt && !noext_cnt))
return;
+ if (inode->i_state & I_NEW) {
+ if (!S_ISREG(inode->i_mode))
+ return;
+ } else if (!f2fs_may_compress(inode)) {
+ return;
+ }
f2fs_down_read(&sbi->sb_lock);
--
2.25.1