All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] f2fs: fix to enable compress for newly created file if extension matches
@ 2022-11-11 10:08 ` Sheng Yong via Linux-f2fs-devel
  0 siblings, 0 replies; 50+ messages in thread
From: Sheng Yong @ 2022-11-11 10:08 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Sheng Yong

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.

This patch moves set_compress_inode(), which do extension check, in
f2fs_should_compress() to check extensions before setting inline
data flag.

Fixes: 7165841d578e ("f2fs: fix to check inline_data during compressed inode conversion")
Signed-off-by: Sheng Yong <shengyong@oppo.com>
---
 fs/f2fs/namei.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

---
v1->v2: add filename parameter for f2fs_new_inode, and move
        set_compress_inode into f2fs_new_inode

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index e104409c3a0e5..36e251f438568 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -22,8 +22,12 @@
 #include "acl.h"
 #include <trace/events/f2fs.h>
 
+static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,
+						const unsigned char *name);
+
 static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
-						struct inode *dir, umode_t mode)
+						struct inode *dir, umode_t mode,
+						const char *name)
 {
 	struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
 	nid_t ino;
@@ -119,6 +123,8 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
 		if ((F2FS_I(dir)->i_flags & F2FS_COMPR_FL) &&
 					f2fs_may_compress(inode))
 			set_compress_context(inode);
+		if (name)
+			set_compress_inode(sbi, inode, name);
 	}
 
 	/* Should enable inline_data after compression set */
@@ -293,8 +299,7 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,
 	unsigned char noext_cnt = F2FS_OPTION(sbi).nocompress_ext_cnt;
 	int i, cold_count, hot_count;
 
-	if (!f2fs_sb_has_compression(sbi) ||
-			F2FS_I(inode)->i_flags & F2FS_NOCOMP_FL ||
+	if (F2FS_I(inode)->i_flags & F2FS_NOCOMP_FL ||
 			!f2fs_may_compress(inode) ||
 			(!ext_cnt && !noext_cnt))
 		return;
@@ -326,10 +331,6 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,
 	for (i = 0; i < ext_cnt; i++) {
 		if (!is_extension_exist(name, ext[i], false))
 			continue;
-
-		/* Do not use inline_data with compression */
-		stat_dec_inline_inode(inode);
-		clear_inode_flag(inode, FI_INLINE_DATA);
 		set_compress_context(inode);
 		return;
 	}
@@ -352,15 +353,13 @@ static int f2fs_create(struct user_namespace *mnt_userns, struct inode *dir,
 	if (err)
 		return err;
 
-	inode = f2fs_new_inode(mnt_userns, dir, mode);
+	inode = f2fs_new_inode(mnt_userns, dir, mode, dentry->d_name.name);
 	if (IS_ERR(inode))
 		return PTR_ERR(inode);
 
 	if (!test_opt(sbi, DISABLE_EXT_IDENTIFY))
 		set_file_temperature(sbi, inode, dentry->d_name.name);
 
-	set_compress_inode(sbi, inode, dentry->d_name.name);
-
 	inode->i_op = &f2fs_file_inode_operations;
 	inode->i_fop = &f2fs_file_operations;
 	inode->i_mapping->a_ops = &f2fs_dblock_aops;
@@ -689,7 +688,7 @@ static int f2fs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
 	if (err)
 		return err;
 
-	inode = f2fs_new_inode(mnt_userns, dir, S_IFLNK | S_IRWXUGO);
+	inode = f2fs_new_inode(mnt_userns, dir, S_IFLNK | S_IRWXUGO, NULL);
 	if (IS_ERR(inode))
 		return PTR_ERR(inode);
 
@@ -760,7 +759,7 @@ static int f2fs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
 	if (err)
 		return err;
 
-	inode = f2fs_new_inode(mnt_userns, dir, S_IFDIR | mode);
+	inode = f2fs_new_inode(mnt_userns, dir, S_IFDIR | mode, NULL);
 	if (IS_ERR(inode))
 		return PTR_ERR(inode);
 
@@ -817,7 +816,7 @@ static int f2fs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
 	if (err)
 		return err;
 
-	inode = f2fs_new_inode(mnt_userns, dir, mode);
+	inode = f2fs_new_inode(mnt_userns, dir, mode, NULL);
 	if (IS_ERR(inode))
 		return PTR_ERR(inode);
 
@@ -856,7 +855,7 @@ static int __f2fs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
 	if (err)
 		return err;
 
-	inode = f2fs_new_inode(mnt_userns, dir, mode);
+	inode = f2fs_new_inode(mnt_userns, dir, mode, NULL);
 	if (IS_ERR(inode))
 		return PTR_ERR(inode);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2022-11-24 14:27 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11 10:08 [PATCH v2 1/2] f2fs: fix to enable compress for newly created file if extension matches Sheng Yong
2022-11-11 10:08 ` [f2fs-dev] " Sheng Yong via Linux-f2fs-devel
2022-11-11 10:08 ` [PATCH v2 2/2] f2fs: move set_file_temperature into f2fs_new_inode Sheng Yong
2022-11-11 10:08   ` [f2fs-dev] " Sheng Yong via Linux-f2fs-devel
2022-11-11 10:20   ` Chao Yu
2022-11-11 10:20     ` Chao Yu
2022-11-14 22:40   ` Jaegeuk Kim
2022-11-14 22:40     ` [f2fs-dev] " Jaegeuk Kim
2022-11-11 10:20 ` [f2fs-dev] [PATCH v2 1/2] f2fs: fix to enable compress for newly created file if extension matches Chao Yu
2022-11-11 10:20   ` Chao Yu
2022-11-12  1:27 ` Jaegeuk Kim
2022-11-12  1:27   ` [f2fs-dev] " Jaegeuk Kim
2022-11-14  1:42   ` Sheng Yong
2022-11-14  1:42     ` [f2fs-dev] " Sheng Yong via Linux-f2fs-devel
2022-11-14 16:05   ` Chao Yu
2022-11-14 16:05     ` [f2fs-dev] " Chao Yu
2022-11-14 22:39 ` Jaegeuk Kim
2022-11-14 22:39   ` [f2fs-dev] " Jaegeuk Kim
2022-11-15  0:20   ` Jaegeuk Kim
2022-11-15  0:20     ` Jaegeuk Kim
2022-11-15  1:49     ` Chao Yu
2022-11-15  1:49       ` Chao Yu
2022-11-15 16:01       ` [PATCH v3] " Sheng Yong
2022-11-15 16:01         ` [f2fs-dev] " Sheng Yong via Linux-f2fs-devel
2022-11-15 21:48         ` Jaegeuk Kim
2022-11-15 21:48           ` [f2fs-dev] " Jaegeuk Kim
2022-11-15 22:45         ` Jaegeuk Kim
2022-11-15 22:45           ` [f2fs-dev] " Jaegeuk Kim
2022-11-15 23:00         ` [PATCH v4] " Jaegeuk Kim
2022-11-15 23:00           ` [f2fs-dev] " Jaegeuk Kim
2022-11-16  2:21           ` Sheng Yong
2022-11-16  2:21             ` [f2fs-dev] " Sheng Yong via Linux-f2fs-devel
2022-11-17  1:13             ` Jaegeuk Kim
2022-11-17  1:13               ` Jaegeuk Kim
2022-11-23 21:46           ` [f2fs-dev] [PATCH v5] " Jaegeuk Kim
2022-11-23 21:46             ` Jaegeuk Kim
2022-11-24 14:27             ` Chao Yu
2022-11-24 14:27               ` Chao Yu
2022-11-17  1:12         ` [PATCH v4] " Jaegeuk Kim
2022-11-17  1:12           ` [f2fs-dev] " Jaegeuk Kim
2022-11-23 14:54           ` Chao Yu
2022-11-23 14:54             ` [f2fs-dev] " Chao Yu
2022-11-23 16:09             ` Sheng Yong
2022-11-23 16:09               ` [f2fs-dev] " Sheng Yong via Linux-f2fs-devel
2022-11-23 21:29             ` Jaegeuk Kim
2022-11-23 21:29               ` [f2fs-dev] " Jaegeuk Kim
2022-11-24  2:38               ` Chao Yu
2022-11-24  2:38                 ` [f2fs-dev] " Chao Yu
2022-11-15  1:34   ` [PATCH v2 1/2] " Chao Yu
2022-11-15  1:34     ` [f2fs-dev] " Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.