Skip to contentSkip to conversation

f2fs: support to disable linear lookup fallback

PATCH Superseded Chao Yu 2 participants 3 messages Mar 31, 2025 – Apr 1, 2025 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH 1/1 f2fs: support to disable linear lookup fallback

After commit 91b587ba79e1 ("f2fs: Introduce linear search for dentries"), f2fs forced to use linear lookup whenever a hash-based lookup fails on casefolded directory, it may affect performance for scenarios: a) create a new file w/ filename it doesn't exist in directory, b) lookup a file which may be removed.

This patch supports to disable linear lookup fallback, so, once there is a solution for commit 5c26d2f1d3f5 ("unicode: Don't special case ignorable code points") to fix red heart unicode issue, then we can set an encodeing flag to disable the fallback for performance recovery.

The way is kept in line w/ ext4, refer to commit 9e28059d5664 ("ext4:
introduce linear search for dentries").

Cc Daniel Lee <[email protected]>
Cc Gabriel Krisman Bertazi <[email protected]>
---
 fs/f2fs/dir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/dir.c +2 -1
index 5a63ff0df03b..e12445afb95a 100644
@@ -366,7 +366,8 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir,
 
 out:
 #if IS_ENABLED(CONFIG_UNICODE)
-	if (IS_CASEFOLDED(dir) && !de && use_hash) {
+	if (IS_CASEFOLDED(dir) && !de && use_hash &&
+		!sb_no_casefold_compat_fallback(dir->i_sb)) {
 		use_hash = false;
 		goto start_find_entry;
 	}
Signature · 1 line
2.49.0
#1 lore raw
Quoted 27 lines · Chao Yu

After commit 91b587ba79e1 ("f2fs: Introduce linear search for dentries"), f2fs forced to use linear lookup whenever a hash-based lookup fails on casefolded directory, it may affect performance for scenarios: a) create a new file w/ filename it doesn't exist in directory, b) lookup a file which may be removed.

This patch supports to disable linear lookup fallback, so, once there is a solution for commit 5c26d2f1d3f5 ("unicode: Don't special case ignorable code points") to fix red heart unicode issue, then we can set an encodeing flag to disable the fallback for performance recovery.

The way is kept in line w/ ext4, refer to commit 9e28059d5664 ("ext4:
introduce linear search for dentries").

Cc Daniel Lee <[email protected]>
Cc Gabriel Krisman Bertazi <[email protected]>
---
 fs/f2fs/dir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/dir.c +0 -0
index 5a63ff0df03b..e12445afb95a 100644

fs/f2fs/dir.c struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, · line 370

Quoted 6 lines
fs/f2fs/dir.c +2 -1
@@ -366,7 +366,8 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir,
 
 out:
 #if IS_ENABLED(CONFIG_UNICODE)
-       if (IS_CASEFOLDED(dir) && !de && use_hash) {
+       if (IS_CASEFOLDED(dir) && !de && use_hash &&
+               !sb_no_casefold_compat_fallback(dir->i_sb)) {

Would it be beneficial to evaluate !sb_no_casefold_compat_fallback(dir->i_sb) first for short-circuiting?

Quoted 7 lines
fs/f2fs/dir.c +0 -1
                use_hash = false;
                goto start_find_entry;
        }
--

2.49.0

author maintainer
#2 lore raw
Quoted 29 lines · Daniel Lee
Quoted 28 lines · Chao Yu

After commit 91b587ba79e1 ("f2fs: Introduce linear search for dentries"), f2fs forced to use linear lookup whenever a hash-based lookup fails on casefolded directory, it may affect performance for scenarios: a) create a new file w/ filename it doesn't exist in directory, b) lookup a file which may be removed.

This patch supports to disable linear lookup fallback, so, once there is a solution for commit 5c26d2f1d3f5 ("unicode: Don't special case ignorable code points") to fix red heart unicode issue, then we can set an encodeing flag to disable the fallback for performance recovery.

The way is kept in line w/ ext4, refer to commit 9e28059d5664 ("ext4:
introduce linear search for dentries").

Cc Daniel Lee <[email protected]>
Cc Gabriel Krisman Bertazi <[email protected]>
---
 fs/f2fs/dir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/dir.c +0 -0
index 5a63ff0df03b..e12445afb95a 100644
@@ -366,7 +366,8 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir,
 
Quoted 9 lines

fs/f2fs/dir.c struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, · line 370

Quoted 5 lines
fs/f2fs/dir.c +2 -1
 out:
 #if IS_ENABLED(CONFIG_UNICODE)
-       if (IS_CASEFOLDED(dir) && !de && use_hash) {
+       if (IS_CASEFOLDED(dir) && !de && use_hash &&
+               !sb_no_casefold_compat_fallback(dir->i_sb)) {

Would it be beneficial to evaluate !sb_no_casefold_compat_fallback(dir->i_sb) first for short-circuiting?

Yeah, I guess it will when we disable the fallback by default, will update v2, thank you!

Thanks,

Quoted 9 lines
Quoted 9 lines
fs/f2fs/dir.c +0 -1
                use_hash = false;
                goto start_find_entry;
        }
--

2.49.0