Skip to contentSkip to conversation

mkfs.f2fs: support -C [no]hashonly to control linear lookup fallback

PATCH Superseded Chao Yu via Linux-f2fs-devel 1 participant 3 messages Jul 24, 2025 Library code

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.f2fs: support -C [no]hashonly to control linear lookup fallback

It provides a way to disable linear lookup fallback during mkfs.

Usage:

1. Disable linear lookup:
mkfs.f2fs -f -O casefold -C utf8:hashonly /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags
s_encoding_flags [0x 2 : 2]

2. Enable linear lookup:
mkfs.f2fs -f -O casefold -C utf8:nohashonly /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags
s_encoding_flags [0x 0 : 0]

mkfs.f2fs -f -O casefold -C utf8 /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags
s_encoding_flags [0x 0 : 0]

---
 lib/libf2fs.c   | 1 +
 man/mkfs.f2fs.8 | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +1 -0
index 2f012c8..0e3e62a 100644
@@ -1424,6 +1424,7 @@ static const struct enc_flags {
 	char *param;
 } encoding_flags[] = {
 	{ F2FS_ENC_STRICT_MODE_FL, "strict" },
+	{ F2FS_ENC_NO_COMPAT_FALLBACK_FL, "hashonly"}
 };
 
 /* Return a positive number < 0xff indicating the encoding magic number
man/mkfs.f2fs.8 +7 -1
index 8b3b0cc..b57f033 100644
@@ -232,10 +232,16 @@ Use UTF-8 for casefolding.
 .I flags:
 .RS 1.2i
 .TP 1.2i
-.B strict
+.B [no]strict
 This flag specifies that invalid strings should be rejected by the filesystem.
 Default is disabled.
 .RE
+.RS 1.2i
+.TP 1.2i
+.B [no]hashonly
+This flag specifies that there is no linear lookup fallback during lookup.
+By default, linear lookup fallback is enabled.
+.RE
 .RE
 .TP
 .BI \-q
Signature · 8 lines
2.49.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw

Can we disable linear lookup by default, but add an option to enable it?

Quoted 60 lines · Chao Yu

It provides a way to disable linear lookup fallback during mkfs.

Usage:

1. Disable linear lookup:
mkfs.f2fs -f -O casefold -C utf8:hashonly /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags
s_encoding_flags [0x 2 : 2]

2. Enable linear lookup:
mkfs.f2fs -f -O casefold -C utf8:nohashonly /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags
s_encoding_flags [0x 0 : 0]

mkfs.f2fs -f -O casefold -C utf8 /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags
s_encoding_flags [0x 0 : 0]

---
 lib/libf2fs.c   | 1 +
 man/mkfs.f2fs.8 | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +1 -0
index 2f012c8..0e3e62a 100644
@@ -1424,6 +1424,7 @@ static const struct enc_flags {
 	char *param;
 } encoding_flags[] = {
 	{ F2FS_ENC_STRICT_MODE_FL, "strict" },
+	{ F2FS_ENC_NO_COMPAT_FALLBACK_FL, "hashonly"}
 };
 
 /* Return a positive number < 0xff indicating the encoding magic number
man/mkfs.f2fs.8 +7 -1
index 8b3b0cc..b57f033 100644
@@ -232,10 +232,16 @@ Use UTF-8 for casefolding.
 .I flags:
 .RS 1.2i
 .TP 1.2i
-.B strict
+.B [no]strict
 This flag specifies that invalid strings should be rejected by the filesystem.
 Default is disabled.
 .RE
+.RS 1.2i
+.TP 1.2i
+.B [no]hashonly
+This flag specifies that there is no linear lookup fallback during lookup.
+By default, linear lookup fallback is enabled.
+.RE
 .RE
 .TP
 .BI \-q
Signature · 1 line
2.49.0

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#2 lore raw
Quoted 1 line · Jaegeuk Kim

Can we disable linear lookup by default, but add an option to enable it?

Sure.

Quoted 11 lines · Chao Yu
Quoted 9 lines

It provides a way to disable linear lookup fallback during mkfs.

Usage:

1. Disable linear lookup:
mkfs.f2fs -f -O casefold -C utf8:hashonly /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags
s_encoding_flags [0x 2 : 2]

Quoted 8 lines
Quoted 8 lines

2. Enable linear lookup:
mkfs.f2fs -f -O casefold -C utf8:nohashonly /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags
s_encoding_flags [0x 0 : 0]

mkfs.f2fs -f -O casefold -C utf8 /dev/vdb dump.f2fs -d3 /dev/vdb |grep s_encoding_flags
s_encoding_flags [0x 0 : 0]

Let me update the logic to disable linear lookup by default for case 2.2).

1) mkfs.f2fs -f -O casefold -C utf8:hashonly /dev/vdb 2.1) mkfs.f2fs -f -O casefold -C utf8:nohashonly /dev/vdb 2.2) mkfs.f2fs -f -O casefold -C utf8 /dev/vdb

Thanks,

Quoted 35 lines
Quoted 35 lines
---
  lib/libf2fs.c   | 1 +
  man/mkfs.f2fs.8 | 8 +++++++-
  2 files changed, 8 insertions(+), 1 deletion(-)
lib/libf2fs.c +1 -0
index 2f012c8..0e3e62a 100644
@@ -1424,6 +1424,7 @@ static const struct enc_flags {
  	char *param;
  } encoding_flags[] = {
  	{ F2FS_ENC_STRICT_MODE_FL, "strict" },
+	{ F2FS_ENC_NO_COMPAT_FALLBACK_FL, "hashonly"}
  };
 
  /* Return a positive number < 0xff indicating the encoding magic number
man/mkfs.f2fs.8 +4 -1
index 8b3b0cc..b57f033 100644
@@ -232,10 +232,16 @@ Use UTF-8 for casefolding.
  .I flags:
  .RS 1.2i
  .TP 1.2i
-.B strict
+.B [no]strict
  This flag specifies that invalid strings should be rejected by the filesystem.
  Default is disabled.
  .RE
+.RS 1.2i
+.TP 1.2i
+.B [no]hashonly
Quoted 8 lines
Quoted 8 lines
man/mkfs.f2fs.8 +3 -0
+This flag specifies that there is no linear lookup fallback during lookup.
+By default, linear lookup fallback is enabled.
+.RE
  .RE
  .TP
  .BI \-q
Signature · 1 line
2.49.0

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel