mkfs.f2fs: support -C [no]hashonly to control linear lookup fallback
PATCH v3 1/1 mkfs.f2fs: support -C [no]hashonly to control linear lookup fallback
It provides a way to disable linear lookup fallback during mkfs.
Behavior summary:
Android Distro
By default disabled enabled
Android case:
1.1) Disable linear lookup:
- mkfs.f2fs -f -g android -O casefold -C utf8:hashonly /dev/vdb
- dump.f2fs -d3 /dev/vdb |grep s_encoding_flagss_encoding_flags [0x 2 : 2]
1.2) Enable linear lookup:
- mkfs.f2fs -f -g android -O casefold -C utf8:nohashonly /dev/vdb
- dump.f2fs -d3 /dev/vdb |grep s_encoding_flagss_encoding_flags [0x 0 : 0]
1.3) By default:
- mkfs.f2fs -f -g android -O casefold -C utf8 /dev/vdb
Info: set default linear_lookup option: disable
- dump.f2fs -d3 /dev/vdb |grep s_encoding_flagss_encoding_flags [0x 2 : 2]
Distro case:
2.1) Disable linear lookup:
- mkfs.f2fs -f -O casefold -C utf8:hashonly /dev/vdb
- dump.f2fs -d3 /dev/vdb |grep s_encoding_flagss_encoding_flags [0x 2 : 2]
2.2) Enable linear lookup:
- mkfs.f2fs -f -O casefold -C utf8:nohashonly /dev/vdb
- dump.f2fs -d3 /dev/vdb |grep s_encoding_flagss_encoding_flags [0x 0 : 0]
2.3) By default:
- mkfs.f2fs -f -O casefold -C utf8 /dev/vdb
- dump.f2fs -d3 /dev/vdb |grep s_encoding_flagss_encoding_flags [0x 0 : 0]
---
v3:
- honor [no]hashonly flag for Android case
- update testcase and output
include/f2fs_fs.h | 3 ++- lib/libf2fs.c | 6 ++++++ man/mkfs.f2fs.8 | 9 ++++++++- mkfs/f2fs_format.c | 11 +++++++++++ mkfs/f2fs_format_main.c | 3 ++- 5 files changed, 29 insertions(+), 3 deletions(-)
include/f2fs_fs.h +2 -1
@@ -1478,7 +1478,8 @@ enum {/* feature list in Android */ enum { -F2FS_FEATURE_NAT_BITS =0x0001 , +F2FS_FEATURE_NAT_BITS =0x0001 , +F2FS_FEATURE_LINEAR_LOOKUP =0x0002 , };/* nolinear lookup tune */
lib/libf2fs.c +6 -0
@@ -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
@@ -1485,6 +1486,11 @@ int f2fs_str2encoding_flags(char **param, __u16 *flags) *flags |= fl->flag; } +if (fl->flag ==F2FS_ENC_NO_COMPAT_FALLBACK_FL ) + c.nolinear_lookup = neg ? +LINEAR_LOOKUP_ENABLE : +LINEAR_LOOKUP_DISABLE ; + goto next_flag; } }
man/mkfs.f2fs.8 +8 -1
@@ -232,10 +232,17 @@ 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 linear lookup fallback is off during lookup, to turn +off linear lookup fallback, use nohashonly flag. +For android case, it will disable linear lookup by default. +.RE .RE .TP .BI \-q
mkfs/f2fs_format.c +11 -0
@@ -671,6 +671,17 @@ static int f2fs_prepare_super_block(void)memcpy (sb->init_version, c.version,VERSION_LEN );if (c.feature &F2FS_FEATURE_CASEFOLD ) { +/* +* if [no]hashonly option is not assigned, let's disable +* linear lookup fallback by default for Android case. +*/ +if ((c.nolinear_lookup ==LINEAR_LOOKUP_DEFAULT ) && + (c.disabled_feature &F2FS_FEATURE_LINEAR_LOOKUP )) { + c.s_encoding_flags |=F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +MSG (0 ,"Info: set default linear_lookup option: %s\n" , + c.s_encoding_flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL ? +"disable" :"enable" ); + }set_sb (s_encoding, c.s_encoding);set_sb (s_encoding_flags, c.s_encoding_flags); }
mkfs/f2fs_format_main.c +2 -1
@@ -143,7 +143,8 @@ static void add_default_options(void) force_overwrite =1 ; c.wanted_sector_size =F2FS_BLKSIZE ; c.root_uid = c.root_gid =0 ; - c.disabled_feature |=F2FS_FEATURE_NAT_BITS ; + c.disabled_feature |=F2FS_FEATURE_NAT_BITS | +F2FS_FEATURE_LINEAR_LOOKUP ;/* RO doesn't need any other features */ if (c.feature &F2FS_FEATURE_RO )
Signature · 1 line
2.49.0
Hi Chao
Chao Yu via Linux-f2fs-devel <[email protected]>
Quoted 37 lines · 于2025年7月25日周五 13:51写道:
It provides a way to disable linear lookup fallback during mkfs.
Behavior summary:
Android Distro
By default disabled enabledAndroid case:
1.1) Disable linear lookup:
- mkfs.f2fs -f -g android -O casefold -C utf8:hashonly/dev/vdb
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 2 : 2]1.2) Enable linear lookup:
- mkfs.f2fs -f -g android -O casefold -C utf8:nohashonly/dev/vdb
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 0 : 0]1.3) By default:
- mkfs.f2fs -f -g android -O casefold -C utf8/dev/vdb
Info: set defaultlinear_lookupoption: disable
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 2 : 2]Distro case:
2.1) Disable linear lookup:
- mkfs.f2fs -f -O casefold -C utf8:hashonly/dev/vdb
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 2 : 2]2.2) Enable linear lookup:
- mkfs.f2fs -f -O casefold -C utf8:nohashonly/dev/vdb
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 0 : 0]
Quoted 5 lines
2.3) By default:
- mkfs.f2fs -f -O casefold -C utf8/dev/vdb
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 0 : 0]
It is very clear and easy to understand.
Quoted 58 lines
Signed-off-by Chao Yu <[email protected]>---
v3:
- honor [no]hashonly flag for Android case
- update testcase and outputinclude/f2fs_fs.h | 3 ++- lib/libf2fs.c | 6 ++++++ man/mkfs.f2fs.8 | 9 ++++++++- mkfs/f2fs_format.c | 11 +++++++++++ mkfs/f2fs_format_main.c | 3 ++- 5 files changed, 29 insertions(+), 3 deletions(-)include/f2fs_fs.h +2
-1@@ -1478,7 +1478,8 @@ enum {/* feature list in Android */ enum { -F2FS_FEATURE_NAT_BITS =0x0001 , +F2FS_FEATURE_NAT_BITS =0x0001 , +F2FS_FEATURE_LINEAR_LOOKUP =0x0002 , };/* nolinear lookup tune */ lib/libf2fs.c +6
-0@@ -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 @@ -1485,6 +1486,11 @@ int f2fs_str2encoding_flags(char **param, __u16 *flags) *flags |= fl->flag; } +if (fl->flag ==F2FS_ENC_NO_COMPAT_FALLBACK_FL ) + c.nolinear_lookup = neg ? +LINEAR_LOOKUP_ENABLE : +LINEAR_LOOKUP_DISABLE ; + goto next_flag; } }man/mkfs.f2fs.8 +0
-0@@ -232,10 +232,17 @@ Use UTF-8 for casefolding. .I flags: .RS 1.2i .TP 1.2i
man/mkfs.f2fs.8 Use UTF-8 for casefolding. · line 243
Quoted 10 lines
man/mkfs.f2fs.8 +6
-1-.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 linear lookup fallback is off during lookup, to turn +off linear lookup fallback, use nohashonly flag.
here should "to turn off linear lookup fallback, use hashonly flag"? or "to turn on linear lookup fallback, use nohashonly flag" 1.1) Disable linear lookup:
- mkfs.f2fs -f -g android -O casefold -C utf8:hashonly /dev/vdb
Quoted 32 lines
man/mkfs.f2fs.8 +2
-0+For android case, it will disable linear lookup by default. +.RE .RE .TP .BI \-qmkfs/f2fs_format.c +11
-0@@ -671,6 +671,17 @@ static int f2fs_prepare_super_block(void)memcpy (sb->init_version, c.version,VERSION_LEN );if (c.feature &F2FS_FEATURE_CASEFOLD ) { +/* +* if [no]hashonly option is not assigned, let's disable +* linear lookup fallback by default for Android case. +*/ +if ((c.nolinear_lookup ==LINEAR_LOOKUP_DEFAULT ) && + (c.disabled_feature &F2FS_FEATURE_LINEAR_LOOKUP )) { + c.s_encoding_flags |=F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +MSG (0 ,"Info: set default linear_lookup option: %s\n" , + c.s_encoding_flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL ? +"disable" :"enable" ); + }set_sb (s_encoding, c.s_encoding);set_sb (s_encoding_flags, c.s_encoding_flags); }mkfs/f2fs_format_main.c +0
-0
mkfs/f2fs_format_main.c static void add_default_options(void) · line 150
Quoted 9 lines
mkfs/f2fs_format_main.c +2
-1@@ -143,7 +143,8 @@ static void add_default_options(void) force_overwrite =1 ; c.wanted_sector_size =F2FS_BLKSIZE ; c.root_uid = c.root_gid =0 ; - c.disabled_feature |=F2FS_FEATURE_NAT_BITS ; + c.disabled_feature |=F2FS_FEATURE_NAT_BITS | +F2FS_FEATURE_LINEAR_LOOKUP ;/* RO doesn't need any other features */ if (c.feature &F2FS_FEATURE_RO )
others look OK to me,so
Quoted 9 lines
--
2.49.0_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 109 lines · Zhiguo Niu
Hi Chao
Chao Yu via Linux-f2fs-devel <[email protected]>
Quoted 37 lines · 于2025年7月25日周五 13:51写道:
It provides a way to disable linear lookup fallback during mkfs.
Behavior summary:
Android Distro
By default disabled enabledAndroid case:
1.1) Disable linear lookup:
- mkfs.f2fs -f -g android -O casefold -C utf8:hashonly/dev/vdb
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 2 : 2]1.2) Enable linear lookup:
- mkfs.f2fs -f -g android -O casefold -C utf8:nohashonly/dev/vdb
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 0 : 0]1.3) By default:
- mkfs.f2fs -f -g android -O casefold -C utf8/dev/vdb
Info: set defaultlinear_lookupoption: disable
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 2 : 2]Distro case:
2.1) Disable linear lookup:
- mkfs.f2fs -f -O casefold -C utf8:hashonly/dev/vdb
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 2 : 2]2.2) Enable linear lookup:
- mkfs.f2fs -f -O casefold -C utf8:nohashonly/dev/vdb
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 0 : 0]Quoted 5 lines
2.3) By default:
- mkfs.f2fs -f -O casefold -C utf8/dev/vdb
- dump.f2fs -d3/dev/vdb|greps_encoding_flagss_encoding_flags[0x 0 : 0]It is very clear and easy to understand.
Quoted 62 lines
Signed-off-by Chao Yu <[email protected]>---
v3:
- honor [no]hashonly flag for Android case
- update testcase and outputinclude/f2fs_fs.h | 3 ++- lib/libf2fs.c | 6 ++++++ man/mkfs.f2fs.8 | 9 ++++++++- mkfs/f2fs_format.c | 11 +++++++++++ mkfs/f2fs_format_main.c | 3 ++- 5 files changed, 29 insertions(+), 3 deletions(-)include/f2fs_fs.h +2
-1@@ -1478,7 +1478,8 @@ enum {/* feature list in Android */ enum { -F2FS_FEATURE_NAT_BITS =0x0001 , +F2FS_FEATURE_NAT_BITS =0x0001 , +F2FS_FEATURE_LINEAR_LOOKUP =0x0002 , };/* nolinear lookup tune */ lib/libf2fs.c +6
-0@@ -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 @@ -1485,6 +1486,11 @@ int f2fs_str2encoding_flags(char **param, __u16 *flags) *flags |= fl->flag; } +if (fl->flag ==F2FS_ENC_NO_COMPAT_FALLBACK_FL ) + c.nolinear_lookup = neg ? +LINEAR_LOOKUP_ENABLE : +LINEAR_LOOKUP_DISABLE ; + goto next_flag; } }man/mkfs.f2fs.8 +1
-1@@ -232,10 +232,17 @@ 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.
Quoted 8 lines
man/mkfs.f2fs.8 Use UTF-8 for casefolding. · line 243
Quoted 6 lines
man/mkfs.f2fs.8 +5
-0.RE +.RS 1.2i +.TP 1.2i +.B [no]hashonly +This flag specifies that linear lookup fallback is off during lookup, to turn +off linear lookup fallback, use nohashonly flag.here should "to turn off linear lookup fallback, use hashonly flag"? or "to turn on linear lookup fallback, use nohashonly flag"
Zhiguo,
Yes, it's typo, let me fix it, thanks for the review.
Thanks,
Quoted 55 lines
1.1) Disable linear lookup:
- mkfs.f2fs -f -g android -O casefold -C utf8:hashonly/dev/vdbQuoted 32 lines
man/mkfs.f2fs.8 +2
-0+For android case, it will disable linear lookup by default. +.RE .RE .TP .BI \-qmkfs/f2fs_format.c +11
-0@@ -671,6 +671,17 @@ static int f2fs_prepare_super_block(void)memcpy (sb->init_version, c.version,VERSION_LEN );if (c.feature &F2FS_FEATURE_CASEFOLD ) { +/* +* if [no]hashonly option is not assigned, let's disable +* linear lookup fallback by default for Android case. +*/ +if ((c.nolinear_lookup ==LINEAR_LOOKUP_DEFAULT ) && + (c.disabled_feature &F2FS_FEATURE_LINEAR_LOOKUP )) { + c.s_encoding_flags |=F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +MSG (0 ,"Info: set default linear_lookup option: %s\n" , + c.s_encoding_flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL ? +"disable" :"enable" ); + }set_sb (s_encoding, c.s_encoding);set_sb (s_encoding_flags, c.s_encoding_flags); }mkfs/f2fs_format_main.c +0
-0mkfs/f2fs_format_main.c static void add_default_options(void) · line 150
Quoted 9 lines
mkfs/f2fs_format_main.c +2
-1@@ -143,7 +143,8 @@ static void add_default_options(void) force_overwrite =1 ; c.wanted_sector_size =F2FS_BLKSIZE ; c.root_uid = c.root_gid =0 ; - c.disabled_feature |=F2FS_FEATURE_NAT_BITS ; + c.disabled_feature |=F2FS_FEATURE_NAT_BITS | +F2FS_FEATURE_LINEAR_LOOKUP ;/* RO doesn't need any other features */ if (c.feature &F2FS_FEATURE_RO )others look OK to me,so
Reviewed-by Zhiguo Niu <[email protected]>Quoted 9 lines
--
2.49.0_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel