]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
f2fs: add sysfs entry for effective lookup mode
authorDaniel Lee <chullee@google.com>
Tue, 5 Aug 2025 06:52:27 +0000 (23:52 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 11 Aug 2025 17:03:53 +0000 (17:03 +0000)
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>
Documentation/ABI/testing/sysfs-fs-f2fs
fs/f2fs/sysfs.c

index bc0e7fefc39d562bae413f0e28f0cfc32be4f4aa..ce189acd1908530aec979208e57ed7dba1081669 100644 (file)
@@ -883,3 +883,18 @@ Date:              June 2025
 Contact:       "Daeho Jeong" <daehojeong@google.com>
 Description:   Control GC algorithm for boost GC. 0: cost benefit, 1: greedy
                Default: 1
+
+What:          /sys/fs/f2fs/<disk>/effective_lookup_mode
+Date:          August 2025
+Contact:       "Daniel Lee" <chullee@google.com>
+Description:
+               This is a read-only entry to show the effective directory lookup mode
+               F2FS is currently using for casefolded directories.
+               This considers both the "lookup_mode" mount option and the on-disk
+               encoding flag, SB_ENC_NO_COMPAT_FALLBACK_FL.
+
+               Possible values are:
+               - "perf": Hash-only lookup.
+               - "compat": Hash-based lookup with a linear search fallback enabled
+               - "auto:perf": lookup_mode is auto and fallback is disabled on-disk
+               - "auto:compat": lookup_mode is auto and fallback is enabled on-disk
index f736052dea50acecea8ac0effce17e7510024614..82489c78aeda581535b8def05750db4c12c86098 100644 (file)
@@ -281,6 +281,22 @@ static ssize_t encoding_flags_show(struct f2fs_attr *a,
                le16_to_cpu(F2FS_RAW_SUPER(sbi)->s_encoding_flags));
 }
 
+static ssize_t effective_lookup_mode_show(struct f2fs_attr *a,
+               struct f2fs_sb_info *sbi, char *buf)
+{
+       switch (F2FS_OPTION(sbi).lookup_mode) {
+       case LOOKUP_PERF:
+               return sysfs_emit(buf, "perf\n");
+       case LOOKUP_COMPAT:
+               return sysfs_emit(buf, "compat\n");
+       case LOOKUP_AUTO:
+               if (sb_no_casefold_compat_fallback(sbi->sb))
+                       return sysfs_emit(buf, "auto:perf\n");
+               return sysfs_emit(buf, "auto:compat\n");
+       }
+       return 0;
+}
+
 static ssize_t mounted_time_sec_show(struct f2fs_attr *a,
                struct f2fs_sb_info *sbi, char *buf)
 {
@@ -1211,6 +1227,7 @@ F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
 F2FS_GENERAL_RO_ATTR(unusable);
 F2FS_GENERAL_RO_ATTR(encoding);
 F2FS_GENERAL_RO_ATTR(encoding_flags);
+F2FS_GENERAL_RO_ATTR(effective_lookup_mode);
 F2FS_GENERAL_RO_ATTR(mounted_time_sec);
 F2FS_GENERAL_RO_ATTR(main_blkaddr);
 F2FS_GENERAL_RO_ATTR(pending_discard);
@@ -1329,6 +1346,7 @@ static struct attribute *f2fs_attrs[] = {
        ATTR_LIST(current_reserved_blocks),
        ATTR_LIST(encoding),
        ATTR_LIST(encoding_flags),
+       ATTR_LIST(effective_lookup_mode),
        ATTR_LIST(mounted_time_sec),
 #ifdef CONFIG_F2FS_STAT_FS
        ATTR_LIST(cp_foreground_calls),