fsck.f2fs: support to tune linear lookup feature
PATCH v2 3/3 fsck.f2fs: support to tune linear lookup feature
Support a new option --nolinear-lookup=X for fsck.f2fs to tune linear lookup fallback conditionally, X=1: disable linear lookup, X=0: enable linear lookup.
This can help to 1) add a regression testcase to check kernel whether linear lookup fallback has fixed unicode red heart lookup issue, 2) once unicode bug has been fixed, we can use this option to disable linear lookup for performance recovery.
---
v2:
- add description in fsck manual
fsck/fsck.c | 26 +++++++++++++++++++++++++- fsck/fsck.h | 1 + fsck/main.c | 10 ++++++++++ include/f2fs_fs.h | 8 ++++++-- man/fsck.f2fs.8 | 3 +++ 5 files changed, 45 insertions(+), 3 deletions(-)
fsck/fsck.c +25 -1
@@ -2357,6 +2357,30 @@ int fsck_chk_quota_files(struct f2fs_sb_info *sbi)return ret; } +void fsck_update_sb_flags (struct f2fs_sb_info *sbi) +{ +struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi); +u16 flags =get_sb (s_encoding_flags); + +if (c.nolinear_lookup) { +if (!(flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL )) { + flags |=F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +set_sb (s_encoding_flags, flags); + c.fix_on =1 ; + c.invalid_sb |=SB_ENCODE_FLAG ; +DBG (0 ,"Casefold: enable nolinear lookup\n" ); + } + }else { +if (flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL ) { + flags &= ~F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +set_sb (s_encoding_flags, flags); + c.fix_on =1 ; + c.invalid_sb |=SB_ENCODE_FLAG ; +DBG (0 ,"Casefold: disable nolinear lookup\n" ); + } + } +} +int fsck_chk_meta (struct f2fs_sb_info *sbi) {struct f2fs_fsck *fsck =F2FS_FSCK (sbi);
@@ -3770,7 +3794,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)if (c.invalid_sb &SB_FS_ERRORS )memset (sb->s_errors,0 ,MAX_F2FS_ERRORS ); -if (c.invalid_sb &SB_NEED_FIX ) +if (c.invalid_sb & (SB_NEED_FIX |SB_ENCODE_FLAG ))update_superblock (sb,SB_MASK_ALL );/* to return FSCK_ERROR_CORRECTED */
fsck/fsck.h +1 -0
@@ -188,6 +188,7 @@ extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, int,int fsck_chk_inline_dentries (struct f2fs_sb_info *,struct f2fs_node *,struct child_info *);void fsck_chk_checkpoint (struct f2fs_sb_info *sbi); +void fsck_update_sb_flags (struct f2fs_sb_info *sbi);int fsck_chk_meta (struct f2fs_sb_info *sbi);void fsck_chk_and_fix_write_pointers (struct f2fs_sb_info *);int fsck_chk_curseg_info (struct f2fs_sb_info *);
fsck/main.c +10 -0
@@ -91,6 +91,7 @@ void fsck_usage()MSG (0 ," --no-kernel-check skips detecting kernel change\n" );MSG (0 ," --kernel-check checks kernel change\n" );MSG (0 ," --debug-cache to debug cache when -c is used\n" ); +MSG (0 ," --nolinear-lookup=X X=1: disable linear lookup, X=0: enable linear lookup\n" );exit (1 ); }
@@ -263,6 +264,7 @@ void f2fs_parse_options(int argc, char *argv[]) {"no-kernel-check", no_argument, 0, 2}, {"kernel-check", no_argument, 0, 3}, {"debug-cache", no_argument, 0, 4}, + {"nolinear-lookup", required_argument, 0, 5}, {0, 0, 0, 0} };
@@ -287,6 +289,12 @@ void f2fs_parse_options(int argc, char *argv[])case 4 : c.cache_config.dbg_en = true;break ; +case 5 : +if (!optarg || !strcmp (optarg,"0" )) + c.nolinear_lookup =0 ; +else + c.nolinear_lookup =1 ; +break ;case 'a' : c.auto_fix =1 ;MSG (0 ,"Info: Automatic fix mode enabled.\n" );
@@ -990,6 +998,8 @@ static int do_fsck(struct f2fs_sb_info *sbi) F2FS_FT_DIR, TYPE_INODE, &blk_cnt, &cbc, &child);fsck_chk_quota_files (sbi); +fsck_update_sb_flags (sbi); + ret =fsck_verify (sbi);fsck_free (sbi);
include/f2fs_fs.h +6 -2
@@ -682,7 +682,8 @@ enum {#define IS_DEVICE_ALIASING (fi) ((fi)->i_flags & cpu_to_le32(F2FS_DEVICE_ALIAS_FL))#define F2FS_ENC_UTF8_12_1 1 -#define F2FS_ENC_STRICT_MODE_FL (1 << 0) +#define F2FS_ENC_STRICT_MODE_FL (1 << 0) +#define F2FS_ENC_NO_COMPAT_FALLBACK_FL (1 << 1)/* This flag is used by node and meta inodes, and by recovery */ #define GFP_F2FS_ZERO (GFP_NOFS | __GFP_ZERO)
@@ -1467,7 +1468,9 @@ enum {#define SB_ABNORMAL_STOP 0x2/* s_stop_reason is set except shutdown */ #define SB_FS_ERRORS 0x4/* s_erros is set */ #define SB_INVALID 0x8/* sb is invalid */ -#define SB_NEED_FIX (SB_ABNORMAL_STOP | SB_FS_ERRORS | SB_INVALID) +#define SB_ENCODE_FLAG 0x16/* encode_flag */ +#define SB_NEED_FIX (SB_ABNORMAL_STOP | SB_FS_ERRORS | \ + SB_INVALID | SB_ENCODE_FLAG)#define MAX_CACHE_SUMS 8
@@ -1541,6 +1544,7 @@ struct f2fs_configuration {int preserve_limits;/* preserve quota limits */ int large_nat_bitmap;int fix_chksum;/* fix old cp.chksum position */ +int nolinear_lookup;/* disable linear lookup */ unsigned int feature;/* defined features */ unsigned int disabled_feature;/* disabled feature, used for Android only */ unsigned int quota_bits;/* quota bits */
man/fsck.f2fs.8 +3 -0
@@ -67,6 +67,9 @@ Enable to show every directory entries in the partition. Specify the level of debugging options. The default number is 0, which shows basic debugging messages. .TP +.BI \--nolinear-lookup +Tune linear lookup fallback, must specify an argument, 0: enable linear lookup, 1: disable linear lookup. +.TP .SH AUTHOR Initial checking code was written by Byoung Geun Kim <[email protected]>. Jaegeuk Kim <[email protected]> reworked most parts of the codes to support
Signature · 8 lines
2.49.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu via Linux-f2fs-devel <[email protected]>
Quoted 99 lines · 于2025年4月7日周一 10:11写道:
Support a new option --nolinear-lookup=X for fsck.f2fs to tune linear lookup fallback conditionally, X=1: disable linear lookup, X=0: enable linear lookup.
This can help to 1) add a regression testcase to check kernel whether linear lookup fallback has fixed unicode red heart lookup issue, 2) once unicode bug has been fixed, we can use this option to disable linear lookup for performance recovery.
Cc Daniel Lee <[email protected]>Signed-off-by Chao Yu <[email protected]>---
v2:
- add description in fsck manualfsck/fsck.c | 26 +++++++++++++++++++++++++- fsck/fsck.h | 1 + fsck/main.c | 10 ++++++++++ include/f2fs_fs.h | 8 ++++++-- man/fsck.f2fs.8 | 3 +++ 5 files changed, 45 insertions(+), 3 deletions(-)fsck/fsck.c +25
-1@@ -2357,6 +2357,30 @@ int fsck_chk_quota_files(struct f2fs_sb_info *sbi)return ret; } +void fsck_update_sb_flags (struct f2fs_sb_info *sbi) +{ +struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi); +u16 flags =get_sb (s_encoding_flags); + +if (c.nolinear_lookup) { +if (!(flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL )) { + flags |=F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +set_sb (s_encoding_flags, flags); + c.fix_on =1 ; + c.invalid_sb |=SB_ENCODE_FLAG ; +DBG (0 ,"Casefold: enable nolinear lookup\n" ); + } + }else { +if (flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL ) { + flags &= ~F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +set_sb (s_encoding_flags, flags); + c.fix_on =1 ; + c.invalid_sb |=SB_ENCODE_FLAG ; +DBG (0 ,"Casefold: disable nolinear lookup\n" ); + } + } +} +int fsck_chk_meta (struct f2fs_sb_info *sbi) {struct f2fs_fsck *fsck =F2FS_FSCK (sbi);@@ -3770,7 +3794,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)if (c.invalid_sb &SB_FS_ERRORS )memset (sb->s_errors,0 ,MAX_F2FS_ERRORS ); -if (c.invalid_sb &SB_NEED_FIX ) +if (c.invalid_sb & (SB_NEED_FIX |SB_ENCODE_FLAG ))update_superblock (sb,SB_MASK_ALL );/* to return FSCK_ERROR_CORRECTED */ fsck/fsck.h +1
-0@@ -188,6 +188,7 @@ extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, int,int fsck_chk_inline_dentries (struct f2fs_sb_info *,struct f2fs_node *,struct child_info *);void fsck_chk_checkpoint (struct f2fs_sb_info *sbi); +void fsck_update_sb_flags (struct f2fs_sb_info *sbi);int fsck_chk_meta (struct f2fs_sb_info *sbi);void fsck_chk_and_fix_write_pointers (struct f2fs_sb_info *);int fsck_chk_curseg_info (struct f2fs_sb_info *);fsck/main.c +2
-0@@ -91,6 +91,7 @@ void fsck_usage()MSG (0 ," --no-kernel-check skips detecting kernel change\n" );MSG (0 ," --kernel-check checks kernel change\n" );MSG (0 ," --debug-cache to debug cache when -c is used\n" ); +MSG (0 ," --nolinear-lookup=X X=1: disable linear lookup, X=0: enable linear lookup\n" );exit (1 ); }@@ -263,6 +264,7 @@ void f2fs_parse_options(int argc, char *argv[]) {"no-kernel-check", no_argument, 0, 2}, {"kernel-check", no_argument, 0, 3}, {"debug-cache", no_argument, 0, 4}, + {"nolinear-lookup", required_argument, 0, 5}, {0, 0, 0, 0} };
fsck/main.c void f2fs_parse_options(int argc, char *argv[]) · line 297
Quoted 9 lines
fsck/main.c +6
-0@@ -287,6 +289,12 @@ void f2fs_parse_options(int argc, char *argv[])case 4 : c.cache_config.dbg_en = true;break ; +case 5 : +if (!optarg || !strcmp (optarg,"0" )) + c.nolinear_lookup =0 ; +else + c.nolinear_lookup =1 ; +break ;
Hi Chao
I also encountered the same performance regression problem in Android device as kernel commit
51dc491a0855("f2fs: support to disable linear lookup fallback") shown.
so because we also need to update this commit about fsck to avoid performance regressions.
Is it appropriate to set this parameter disable linear_lookup by default (c.nolinear_lookup = 1)?
This also fits most of the scenarios.
If other users want to enable this feature, they can control it through parameters.
thanks!
Quoted 64 lines
fsck/main.c +2
-0case 'a' : c.auto_fix =1 ;MSG (0 ,"Info: Automatic fix mode enabled.\n" );@@ -990,6 +998,8 @@ static int do_fsck(struct f2fs_sb_info *sbi) F2FS_FT_DIR, TYPE_INODE, &blk_cnt, &cbc, &child);fsck_chk_quota_files (sbi); +fsck_update_sb_flags (sbi); + ret =fsck_verify (sbi);fsck_free (sbi);include/f2fs_fs.h +6
-2@@ -682,7 +682,8 @@ enum {#define IS_DEVICE_ALIASING (fi) ((fi)->i_flags & cpu_to_le32(F2FS_DEVICE_ALIAS_FL))#define F2FS_ENC_UTF8_12_1 1 -#define F2FS_ENC_STRICT_MODE_FL (1 << 0) +#define F2FS_ENC_STRICT_MODE_FL (1 << 0) +#define F2FS_ENC_NO_COMPAT_FALLBACK_FL (1 << 1)/* This flag is used by node and meta inodes, and by recovery */ #define GFP_F2FS_ZERO (GFP_NOFS | __GFP_ZERO)@@ -1467,7 +1468,9 @@ enum {#define SB_ABNORMAL_STOP 0x2/* s_stop_reason is set except shutdown */ #define SB_FS_ERRORS 0x4/* s_erros is set */ #define SB_INVALID 0x8/* sb is invalid */ -#define SB_NEED_FIX (SB_ABNORMAL_STOP | SB_FS_ERRORS | SB_INVALID) +#define SB_ENCODE_FLAG 0x16/* encode_flag */ +#define SB_NEED_FIX (SB_ABNORMAL_STOP | SB_FS_ERRORS | \ + SB_INVALID | SB_ENCODE_FLAG)#define MAX_CACHE_SUMS 8@@ -1541,6 +1544,7 @@ struct f2fs_configuration {int preserve_limits;/* preserve quota limits */ int large_nat_bitmap;int fix_chksum;/* fix old cp.chksum position */ +int nolinear_lookup;/* disable linear lookup */ unsigned int feature;/* defined features */ unsigned int disabled_feature;/* disabled feature, used for Android only */ unsigned int quota_bits;/* quota bits */ man/fsck.f2fs.8 +3
-1@@ -67,6 +67,9 @@ Enable to show every directory entries in the partition. Specify the level of debugging options. The default number is 0, which shows basic debugging messages. .TP +.BI \--nolinear-lookup +Tune linear lookup fallback, must specify an argument, 0: enable linear lookup, 1: disable linear lookup. +.TP .SH AUTHOR Initial checking code was written by Byoung Geun Kim <[email protected]>. Jaegeuk Kim <[email protected]> reworked most parts of the codes to support --2.49.0
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 115 lines · Zhiguo Niu
Chao Yu via Linux-f2fs-devel <[email protected]>
Quoted 99 lines · 于2025年4月7日周一 10:11写道:
Support a new option --nolinear-lookup=X for fsck.f2fs to tune linear lookup fallback conditionally, X=1: disable linear lookup, X=0: enable linear lookup.
This can help to 1) add a regression testcase to check kernel whether linear lookup fallback has fixed unicode red heart lookup issue, 2) once unicode bug has been fixed, we can use this option to disable linear lookup for performance recovery.
Cc Daniel Lee <[email protected]>Signed-off-by Chao Yu <[email protected]>---
v2:
- add description in fsck manualfsck/fsck.c | 26 +++++++++++++++++++++++++- fsck/fsck.h | 1 + fsck/main.c | 10 ++++++++++ include/f2fs_fs.h | 8 ++++++-- man/fsck.f2fs.8 | 3 +++ 5 files changed, 45 insertions(+), 3 deletions(-)fsck/fsck.c +25
-1@@ -2357,6 +2357,30 @@ int fsck_chk_quota_files(struct f2fs_sb_info *sbi)return ret; } +void fsck_update_sb_flags (struct f2fs_sb_info *sbi) +{ +struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi); +u16 flags =get_sb (s_encoding_flags); + +if (c.nolinear_lookup) { +if (!(flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL )) { + flags |=F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +set_sb (s_encoding_flags, flags); + c.fix_on =1 ; + c.invalid_sb |=SB_ENCODE_FLAG ; +DBG (0 ,"Casefold: enable nolinear lookup\n" ); + } + }else { +if (flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL ) { + flags &= ~F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +set_sb (s_encoding_flags, flags); + c.fix_on =1 ; + c.invalid_sb |=SB_ENCODE_FLAG ; +DBG (0 ,"Casefold: disable nolinear lookup\n" ); + } + } +} +int fsck_chk_meta (struct f2fs_sb_info *sbi) {struct f2fs_fsck *fsck =F2FS_FSCK (sbi);@@ -3770,7 +3794,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)if (c.invalid_sb &SB_FS_ERRORS )memset (sb->s_errors,0 ,MAX_F2FS_ERRORS ); -if (c.invalid_sb &SB_NEED_FIX ) +if (c.invalid_sb & (SB_NEED_FIX |SB_ENCODE_FLAG ))update_superblock (sb,SB_MASK_ALL );/* to return FSCK_ERROR_CORRECTED */ fsck/fsck.h +1
-0@@ -188,6 +188,7 @@ extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, int,int fsck_chk_inline_dentries (struct f2fs_sb_info *,struct f2fs_node *,struct child_info *);void fsck_chk_checkpoint (struct f2fs_sb_info *sbi); +void fsck_update_sb_flags (struct f2fs_sb_info *sbi);int fsck_chk_meta (struct f2fs_sb_info *sbi);void fsck_chk_and_fix_write_pointers (struct f2fs_sb_info *);int fsck_chk_curseg_info (struct f2fs_sb_info *);fsck/main.c +2
-0@@ -91,6 +91,7 @@ void fsck_usage()MSG (0 ," --no-kernel-check skips detecting kernel change\n" );MSG (0 ," --kernel-check checks kernel change\n" );MSG (0 ," --debug-cache to debug cache when -c is used\n" ); +MSG (0 ," --nolinear-lookup=X X=1: disable linear lookup, X=0: enable linear lookup\n" );exit (1 ); }@@ -263,6 +264,7 @@ void f2fs_parse_options(int argc, char *argv[]) {"no-kernel-check", no_argument, 0, 2}, {"kernel-check", no_argument, 0, 3}, {"debug-cache", no_argument, 0, 4}, + {"nolinear-lookup", required_argument, 0, 5}, {0, 0, 0, 0} };fsck/main.c void f2fs_parse_options(int argc, char *argv[]) · line 297
Quoted 9 lines
fsck/main.c +6
-0@@ -287,6 +289,12 @@ void f2fs_parse_options(int argc, char *argv[])case 4 : c.cache_config.dbg_en = true;break ; +case 5 : +if (!optarg || !strcmp (optarg,"0" )) + c.nolinear_lookup =0 ; +else + c.nolinear_lookup =1 ; +break ;Hi Chao
I also encountered the same performance regression problem in Android device as kernel commit
51dc491a0855("f2fs: support to disable linear lookup fallback") shown.
Quoted 7 lines
so because we also need to update this commit about fsck to avoid performance regressions.
Is it appropriate to set this parameter disablelinear_lookupby default (c.nolinear_lookup = 1)?
This also fits most of the scenarios.
If other users want to enable this feature, they can control it through parameters.
Zhiguo,
There are two conditions user will lost their file which has specified charactors, like red heart ❤️.
case #1
- create file named red_heart ❤️
- apply 5c26d2f1d3f5 ("unicode: Don't special case ignorable code points")
- stat red_heart ❤️ --> No such file or directory
case #2
- apply 5c26d2f1d3f5 ("unicode: Don't special case ignorable code points")
- create file named red_heart ❤️
- revert 5c26d2f1d3f5 ("unicode: Don't special case ignorable code points")
- stat red_heart ❤️ --> No such file or directory
If you does not matched any of above cases, I guess it's fine for you to disable linear fallback.
I prefer to wait for the formal fix for specified unicode charactor handling, and then disable linear fallback, as I don't know the condition of our user.
Quoted 65 lines
thanks!
Quoted 64 lines
fsck/main.c +2
-0case 'a' : c.auto_fix =1 ;MSG (0 ,"Info: Automatic fix mode enabled.\n" );@@ -990,6 +998,8 @@ static int do_fsck(struct f2fs_sb_info *sbi) F2FS_FT_DIR, TYPE_INODE, &blk_cnt, &cbc, &child);fsck_chk_quota_files (sbi); +fsck_update_sb_flags (sbi); + ret =fsck_verify (sbi);fsck_free (sbi);include/f2fs_fs.h +6
-2@@ -682,7 +682,8 @@ enum {#define IS_DEVICE_ALIASING (fi) ((fi)->i_flags & cpu_to_le32(F2FS_DEVICE_ALIAS_FL))#define F2FS_ENC_UTF8_12_1 1 -#define F2FS_ENC_STRICT_MODE_FL (1 << 0) +#define F2FS_ENC_STRICT_MODE_FL (1 << 0) +#define F2FS_ENC_NO_COMPAT_FALLBACK_FL (1 << 1)/* This flag is used by node and meta inodes, and by recovery */ #define GFP_F2FS_ZERO (GFP_NOFS | __GFP_ZERO)@@ -1467,7 +1468,9 @@ enum {#define SB_ABNORMAL_STOP 0x2/* s_stop_reason is set except shutdown */ #define SB_FS_ERRORS 0x4/* s_erros is set */ #define SB_INVALID 0x8/* sb is invalid */ -#define SB_NEED_FIX (SB_ABNORMAL_STOP | SB_FS_ERRORS | SB_INVALID) +#define SB_ENCODE_FLAG 0x16/* encode_flag */ +#define SB_NEED_FIX (SB_ABNORMAL_STOP | SB_FS_ERRORS | \ + SB_INVALID | SB_ENCODE_FLAG)#define MAX_CACHE_SUMS 8@@ -1541,6 +1544,7 @@ struct f2fs_configuration {int preserve_limits;/* preserve quota limits */ int large_nat_bitmap;int fix_chksum;/* fix old cp.chksum position */ +int nolinear_lookup;/* disable linear lookup */ unsigned int feature;/* defined features */ unsigned int disabled_feature;/* disabled feature, used for Android only */ unsigned int quota_bits;/* quota bits */ man/fsck.f2fs.8 +3
-1@@ -67,6 +67,9 @@ Enable to show every directory entries in the partition. Specify the level of debugging options. The default number is 0, which shows basic debugging messages. .TP +.BI \--nolinear-lookup +Tune linear lookup fallback, must specify an argument, 0: enable linear lookup, 1: disable linear lookup. +.TP .SH AUTHOR Initial checking code was written by Byoung Geun Kim <[email protected]>. Jaegeuk Kim <[email protected]> reworked most parts of the codes to support --2.49.0
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 135 lines · Chao Yu <[email protected]> 于2025年4月11日周五 18:32写道:
Quoted 115 lines · Zhiguo Niu
Chao Yu via Linux-f2fs-devel <[email protected]>
Quoted 99 lines · 于2025年4月7日周一 10:11写道:
Support a new option --nolinear-lookup=X for fsck.f2fs to tune linear lookup fallback conditionally, X=1: disable linear lookup, X=0: enable linear lookup.
This can help to 1) add a regression testcase to check kernel whether linear lookup fallback has fixed unicode red heart lookup issue, 2) once unicode bug has been fixed, we can use this option to disable linear lookup for performance recovery.
Cc Daniel Lee <[email protected]>Signed-off-by Chao Yu <[email protected]>---
v2:
- add description in fsck manualfsck/fsck.c | 26 +++++++++++++++++++++++++- fsck/fsck.h | 1 + fsck/main.c | 10 ++++++++++ include/f2fs_fs.h | 8 ++++++-- man/fsck.f2fs.8 | 3 +++ 5 files changed, 45 insertions(+), 3 deletions(-)fsck/fsck.c +25
-1@@ -2357,6 +2357,30 @@ int fsck_chk_quota_files(struct f2fs_sb_info *sbi)return ret; } +void fsck_update_sb_flags (struct f2fs_sb_info *sbi) +{ +struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi); +u16 flags =get_sb (s_encoding_flags); + +if (c.nolinear_lookup) { +if (!(flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL )) { + flags |=F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +set_sb (s_encoding_flags, flags); + c.fix_on =1 ; + c.invalid_sb |=SB_ENCODE_FLAG ; +DBG (0 ,"Casefold: enable nolinear lookup\n" ); + } + }else { +if (flags &F2FS_ENC_NO_COMPAT_FALLBACK_FL ) { + flags &= ~F2FS_ENC_NO_COMPAT_FALLBACK_FL ; +set_sb (s_encoding_flags, flags); + c.fix_on =1 ; + c.invalid_sb |=SB_ENCODE_FLAG ; +DBG (0 ,"Casefold: disable nolinear lookup\n" ); + } + } +} +int fsck_chk_meta (struct f2fs_sb_info *sbi) {struct f2fs_fsck *fsck =F2FS_FSCK (sbi);@@ -3770,7 +3794,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)if (c.invalid_sb &SB_FS_ERRORS )memset (sb->s_errors,0 ,MAX_F2FS_ERRORS ); -if (c.invalid_sb &SB_NEED_FIX ) +if (c.invalid_sb & (SB_NEED_FIX |SB_ENCODE_FLAG ))update_superblock (sb,SB_MASK_ALL );/* to return FSCK_ERROR_CORRECTED */ fsck/fsck.h +1
-0@@ -188,6 +188,7 @@ extern int fsck_chk_dentry_blk(struct f2fs_sb_info *, int,int fsck_chk_inline_dentries (struct f2fs_sb_info *,struct f2fs_node *,struct child_info *);void fsck_chk_checkpoint (struct f2fs_sb_info *sbi); +void fsck_update_sb_flags (struct f2fs_sb_info *sbi);int fsck_chk_meta (struct f2fs_sb_info *sbi);void fsck_chk_and_fix_write_pointers (struct f2fs_sb_info *);int fsck_chk_curseg_info (struct f2fs_sb_info *);fsck/main.c +2
-0@@ -91,6 +91,7 @@ void fsck_usage()MSG (0 ," --no-kernel-check skips detecting kernel change\n" );MSG (0 ," --kernel-check checks kernel change\n" );MSG (0 ," --debug-cache to debug cache when -c is used\n" ); +MSG (0 ," --nolinear-lookup=X X=1: disable linear lookup, X=0: enable linear lookup\n" );exit (1 ); }@@ -263,6 +264,7 @@ void f2fs_parse_options(int argc, char *argv[]) {"no-kernel-check", no_argument, 0, 2}, {"kernel-check", no_argument, 0, 3}, {"debug-cache", no_argument, 0, 4}, + {"nolinear-lookup", required_argument, 0, 5}, {0, 0, 0, 0} };fsck/main.c void f2fs_parse_options(int argc, char *argv[]) · line 297
Quoted 9 lines
fsck/main.c +6
-0@@ -287,6 +289,12 @@ void f2fs_parse_options(int argc, char *argv[])case 4 : c.cache_config.dbg_en = true;break ; +case 5 : +if (!optarg || !strcmp (optarg,"0" )) + c.nolinear_lookup =0 ; +else + c.nolinear_lookup =1 ; +break ;Hi Chao
I also encountered the same performance regression problem in Android device as kernel commit
51dc491a0855("f2fs: support to disable linear lookup fallback") shown.Quoted 7 lines
so because we also need to update this commit about fsck to avoid performance regressions.
Is it appropriate to set this parameter disablelinear_lookupby default (c.nolinear_lookup = 1)?
This also fits most of the scenarios.
If other users want to enable this feature, they can control it through parameters.Zhiguo,
There are two conditions user will lost their file which has specified charactors, like red heart ❤️.
case #1
- create file namedred_heart❤️
- apply5c26d2f1d3f5("unicode: Don't special case ignorable code points")
- statred_heart❤️ --> No such file or directory
Quoted 8 lines
case #2
- apply5c26d2f1d3f5("unicode: Don't special case ignorable code points")
- create file namedred_heart❤️
- revert5c26d2f1d3f5("unicode: Don't special case ignorable code points")
- statred_heart❤️ --> No such file or directoryIf you does not matched any of above cases, I guess it's fine for you to disable linear fallback.
Hi Chao,
Yes, I did not encounter any of above cases. Thank you for your detailed explanation
Quoted 4 lines
I prefer to wait for the formal fix for specified unicode charactor handling, and then disable linear fallback, as I don't know the condition of our user.
Got it. thanks!
Quoted 66 lines
Quoted 66 lines
thanks!
Quoted 64 lines
fsck/main.c +2
-0case 'a' : c.auto_fix =1 ;MSG (0 ,"Info: Automatic fix mode enabled.\n" );@@ -990,6 +998,8 @@ static int do_fsck(struct f2fs_sb_info *sbi) F2FS_FT_DIR, TYPE_INODE, &blk_cnt, &cbc, &child);fsck_chk_quota_files (sbi); +fsck_update_sb_flags (sbi); + ret =fsck_verify (sbi);fsck_free (sbi);include/f2fs_fs.h +6
-2@@ -682,7 +682,8 @@ enum {#define IS_DEVICE_ALIASING (fi) ((fi)->i_flags & cpu_to_le32(F2FS_DEVICE_ALIAS_FL))#define F2FS_ENC_UTF8_12_1 1 -#define F2FS_ENC_STRICT_MODE_FL (1 << 0) +#define F2FS_ENC_STRICT_MODE_FL (1 << 0) +#define F2FS_ENC_NO_COMPAT_FALLBACK_FL (1 << 1)/* This flag is used by node and meta inodes, and by recovery */ #define GFP_F2FS_ZERO (GFP_NOFS | __GFP_ZERO)@@ -1467,7 +1468,9 @@ enum {#define SB_ABNORMAL_STOP 0x2/* s_stop_reason is set except shutdown */ #define SB_FS_ERRORS 0x4/* s_erros is set */ #define SB_INVALID 0x8/* sb is invalid */ -#define SB_NEED_FIX (SB_ABNORMAL_STOP | SB_FS_ERRORS | SB_INVALID) +#define SB_ENCODE_FLAG 0x16/* encode_flag */ +#define SB_NEED_FIX (SB_ABNORMAL_STOP | SB_FS_ERRORS | \ + SB_INVALID | SB_ENCODE_FLAG)#define MAX_CACHE_SUMS 8@@ -1541,6 +1544,7 @@ struct f2fs_configuration {int preserve_limits;/* preserve quota limits */ int large_nat_bitmap;int fix_chksum;/* fix old cp.chksum position */ +int nolinear_lookup;/* disable linear lookup */ unsigned int feature;/* defined features */ unsigned int disabled_feature;/* disabled feature, used for Android only */ unsigned int quota_bits;/* quota bits */ man/fsck.f2fs.8 +3
-1@@ -67,6 +67,9 @@ Enable to show every directory entries in the partition. Specify the level of debugging options. The default number is 0, which shows basic debugging messages. .TP +.BI \--nolinear-lookup +Tune linear lookup fallback, must specify an argument, 0: enable linear lookup, 1: disable linear lookup. +.TP .SH AUTHOR Initial checking code was written by Byoung Geun Kim <[email protected]>. Jaegeuk Kim <[email protected]> reworked most parts of the codes to support --2.49.0
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel