Skip to content

Commit 1bd119d

Browse files
Daniel LeeJaegeuk Kim
authored andcommitted
f2fs: add sysfs entry for effective lookup mode
This commit introduces a new read-only sysfs entry at /sys/fs/f2fs/<device>/effective_lookup_mode. This entry displays the actual directory lookup mode F2FS is currently using. This is needed for debugging and verification, as the behavior is determined by both on-disk flags and mount options. Signed-off-by: Daniel Lee <chullee@google.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 632f0b6 commit 1bd119d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,3 +883,18 @@ Date: June 2025
883883
Contact: "Daeho Jeong" <daehojeong@google.com>
884884
Description: Control GC algorithm for boost GC. 0: cost benefit, 1: greedy
885885
Default: 1
886+
887+
What: /sys/fs/f2fs/<disk>/effective_lookup_mode
888+
Date: August 2025
889+
Contact: "Daniel Lee" <chullee@google.com>
890+
Description:
891+
This is a read-only entry to show the effective directory lookup mode
892+
F2FS is currently using for casefolded directories.
893+
This considers both the "lookup_mode" mount option and the on-disk
894+
encoding flag, SB_ENC_NO_COMPAT_FALLBACK_FL.
895+
896+
Possible values are:
897+
- "perf": Hash-only lookup.
898+
- "compat": Hash-based lookup with a linear search fallback enabled
899+
- "auto:perf": lookup_mode is auto and fallback is disabled on-disk
900+
- "auto:compat": lookup_mode is auto and fallback is enabled on-disk

fs/f2fs/sysfs.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,22 @@ static ssize_t encoding_flags_show(struct f2fs_attr *a,
281281
le16_to_cpu(F2FS_RAW_SUPER(sbi)->s_encoding_flags));
282282
}
283283

284+
static ssize_t effective_lookup_mode_show(struct f2fs_attr *a,
285+
struct f2fs_sb_info *sbi, char *buf)
286+
{
287+
switch (F2FS_OPTION(sbi).lookup_mode) {
288+
case LOOKUP_PERF:
289+
return sysfs_emit(buf, "perf\n");
290+
case LOOKUP_COMPAT:
291+
return sysfs_emit(buf, "compat\n");
292+
case LOOKUP_AUTO:
293+
if (sb_no_casefold_compat_fallback(sbi->sb))
294+
return sysfs_emit(buf, "auto:perf\n");
295+
return sysfs_emit(buf, "auto:compat\n");
296+
}
297+
return 0;
298+
}
299+
284300
static ssize_t mounted_time_sec_show(struct f2fs_attr *a,
285301
struct f2fs_sb_info *sbi, char *buf)
286302
{
@@ -1211,6 +1227,7 @@ F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
12111227
F2FS_GENERAL_RO_ATTR(unusable);
12121228
F2FS_GENERAL_RO_ATTR(encoding);
12131229
F2FS_GENERAL_RO_ATTR(encoding_flags);
1230+
F2FS_GENERAL_RO_ATTR(effective_lookup_mode);
12141231
F2FS_GENERAL_RO_ATTR(mounted_time_sec);
12151232
F2FS_GENERAL_RO_ATTR(main_blkaddr);
12161233
F2FS_GENERAL_RO_ATTR(pending_discard);
@@ -1329,6 +1346,7 @@ static struct attribute *f2fs_attrs[] = {
13291346
ATTR_LIST(current_reserved_blocks),
13301347
ATTR_LIST(encoding),
13311348
ATTR_LIST(encoding_flags),
1349+
ATTR_LIST(effective_lookup_mode),
13321350
ATTR_LIST(mounted_time_sec),
13331351
#ifdef CONFIG_F2FS_STAT_FS
13341352
ATTR_LIST(cp_foreground_calls),

0 commit comments

Comments
 (0)