fsck.f2fs: add -O features to tune the bits
PATCH 1/1 fsck.f2fs: add -O features to tune the bits
This patch add -O features for fsck.f2fs in order to tune the feature bits. Currently, it supports -O encrypt only.
--- fsck/fsck.h | 1 + fsck/main.c | 9 ++++++++- fsck/mount.c | 39 ++++++++++++++++++++++++++++++++++++++- fsck/resize.c | 18 +----------------- 4 files changed, 48 insertions(+), 19 deletions(-)
fsck/fsck.h +1 -0
@@ -176,6 +176,7 @@ extern void move_curseg_info(struct f2fs_sb_info *, u64);extern void write_curseg_info (struct f2fs_sb_info *);extern int find_next_free_block (struct f2fs_sb_info *,u64 *,int ,int );extern void write_checkpoint (struct f2fs_sb_info *); +extern void write_superblock (struct f2fs_super_block *);extern void update_data_blkaddr (struct f2fs_sb_info *,nid_t ,u16 ,block_t );extern void update_nat_blkaddr (struct f2fs_sb_info *,nid_t ,nid_t ,block_t );
fsck/main.c +8 -1
@@ -28,6 +28,8 @@ struct f2fs_fsck gfsck;extern struct sparse_file *f2fs_sparse_file;#endif +INIT_FEATURE_TABLE ; +static char *absolute_path (const char *file) {char *ret;
@@ -54,6 +56,7 @@ void fsck_usage()MSG (0 ," -d debug level [default:0]\n" );MSG (0 ," -f check/fix entire partition\n" );MSG (0 ," -g add default options\n" ); +MSG (0 ," -O feature1[feature2,feature3,...] e.g. \"encrypt\"\n" );MSG (0 ," -p preen mode [default:0 the same as -a [0|1]]\n" );MSG (0 ," -S sparse_mode\n" );MSG (0 ," -t show directory tree\n" );
@@ -180,7 +183,7 @@ void f2fs_parse_options(int argc, char *argv[]) }if (!strcmp ("fsck.f2fs" , prog)) { -const char *option_string =":ad:fg:p:q:StyV" ; +const char *option_string =":ad:fg:O:p:q:StyV" ;int opt =0 ;struct option long_opt[] = { {"dry-run" , no_argument,0 ,1 },
@@ -203,6 +206,10 @@ void f2fs_parse_options(int argc, char *argv[])if (!strcmp (optarg,"android" )) c.defset =CONF_ANDROID ;break ; +case 'O' : +if (parse_feature (feature_table, optarg)) +fsck_usage (); +break ;case 'p' :/* preen mode has different levels: * 0: default level, the same as -a
fsck/mount.c +38 -1
@@ -2144,6 +2144,22 @@ void write_checkpoint(struct f2fs_sb_info *sbi)ASSERT (ret >=0 ); } +void write_superblock (struct f2fs_super_block *new_sb) +{ +int index, ret; +u_int8_t *buf; + + buf =calloc (BLOCK_SZ ,1 ); + +memcpy (buf +F2FS_SUPER_OFFSET , new_sb,sizeof (*new_sb)); +for (index =0 ; index <2 ; index++) { + ret =dev_write_block (buf, index); +ASSERT (ret >=0 ); + } +free (buf); +DBG (0 ,"Info: Done to rebuild superblock\n" ); +} +void build_nat_area_bitmap (struct f2fs_sb_info *sbi) {struct curseg_info *curseg =CURSEG_I (sbi,CURSEG_HOT_DATA );
@@ -2314,6 +2330,26 @@ static int check_sector_size(struct f2fs_super_block *sb)return 0 ; } +static void tune_sb_features (struct f2fs_sb_info *sbi) +{ +int sb_changed =0 ; +struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi); + +if (!(sb->feature &cpu_to_le32 (F2FS_FEATURE_ENCRYPT )) && + c.feature &cpu_to_le32 (F2FS_FEATURE_ENCRYPT )) { + sb->feature |=cpu_to_le32 (F2FS_FEATURE_ENCRYPT ); +MSG (0 ,"Info: Set Encryption feature\n" ); + sb_changed =1 ; + } +/* TODO: quota needs to allocate inode numbers */ + + c.feature = sb->feature; +if (!sb_changed) +return ; + +write_superblock (sb); +} +int f2fs_do_mount (struct f2fs_sb_info *sbi) {struct f2fs_checkpoint *cp =NULL ;
@@ -2365,7 +2401,8 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi) } c.bug_on =0 ; - c.feature = sb->feature; + +tune_sb_features (sbi);/* precompute checksum seed for metadata */ if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CHKSUM ))
fsck/resize.c +1 -17
@@ -569,22 +569,6 @@ static void rebuild_checkpoint(struct f2fs_sb_info *sbi,DBG (0 ,"Info: Done to rebuild checkpoint blocks\n" ); } -static void rebuild_superblock (struct f2fs_super_block *new_sb) -{ -int index, ret; -u_int8_t *buf; - - buf =calloc (BLOCK_SZ ,1 ); - -memcpy (buf +F2FS_SUPER_OFFSET , new_sb,sizeof (*new_sb)); -for (index =0 ; index <2 ; index++) { - ret =dev_write_block (buf, index); -ASSERT (ret >=0 ); - } -free (buf); -DBG (0 ,"Info: Done to rebuild superblock\n" ); -} -int f2fs_resize (struct f2fs_sb_info *sbi) {struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi);
@@ -636,6 +620,6 @@ int f2fs_resize(struct f2fs_sb_info *sbi)migrate_nat (sbi, new_sb);migrate_sit (sbi, new_sb, offset_seg);rebuild_checkpoint (sbi, new_sb, offset_seg); -rebuild_superblock (new_sb); +write_superblock (new_sb);return 0 ; }
Signature · 6 lines
2.17.0.484.g0c8726318c-goog ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Hi, Jaegeuk
Quoted 3 lines · Jaegeuk Kim
This patch add -O features for fsck.f2fs in order to tune the feature bits. Currently, it supports -O encrypt only.
Shall we introduce a new tool like tune.f2fs to tune the parameters of f2fs? Maybe we will tune others parameters in the future, not only features bits in sb :)
Quoted 154 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fsck/fsck.h | 1 + fsck/main.c | 9 ++++++++- fsck/mount.c | 39 ++++++++++++++++++++++++++++++++++++++- fsck/resize.c | 18 +----------------- 4 files changed, 48 insertions(+), 19 deletions(-)fsck/fsck.h +1
-0@@ -176,6 +176,7 @@ extern void move_curseg_info(struct f2fs_sb_info *, u64);extern void write_curseg_info (struct f2fs_sb_info *);extern int find_next_free_block (struct f2fs_sb_info *,u64 *,int ,int );extern void write_checkpoint (struct f2fs_sb_info *); +extern void write_superblock (struct f2fs_super_block *);extern void update_data_blkaddr (struct f2fs_sb_info *,nid_t ,u16 ,block_t );extern void update_nat_blkaddr (struct f2fs_sb_info *,nid_t ,nid_t ,block_t );fsck/main.c +8
-1@@ -28,6 +28,8 @@ struct f2fs_fsck gfsck;extern struct sparse_file *f2fs_sparse_file;#endif +INIT_FEATURE_TABLE ; +static char *absolute_path (const char *file) {char *ret;@@ -54,6 +56,7 @@ void fsck_usage()MSG (0 ," -d debug level [default:0]\n" );MSG (0 ," -f check/fix entire partition\n" );MSG (0 ," -g add default options\n" ); +MSG (0 ," -O feature1[feature2,feature3,...] e.g. \"encrypt\"\n" );MSG (0 ," -p preen mode [default:0 the same as -a [0|1]]\n" );MSG (0 ," -S sparse_mode\n" );MSG (0 ," -t show directory tree\n" );@@ -180,7 +183,7 @@ void f2fs_parse_options(int argc, char *argv[]) }if (!strcmp ("fsck.f2fs" , prog)) { -const char *option_string =":ad:fg:p:q:StyV" ; +const char *option_string =":ad:fg:O:p:q:StyV" ;int opt =0 ;struct option long_opt[] = { {"dry-run" , no_argument,0 ,1 },@@ -203,6 +206,10 @@ void f2fs_parse_options(int argc, char *argv[])if (!strcmp (optarg,"android" )) c.defset =CONF_ANDROID ;break ; +case 'O' : +if (parse_feature (feature_table, optarg)) +fsck_usage (); +break ;case 'p' :/* preen mode has different levels: * 0: default level, the same as -a fsck/mount.c +38
-1@@ -2144,6 +2144,22 @@ void write_checkpoint(struct f2fs_sb_info *sbi)ASSERT (ret >=0 ); } +void write_superblock (struct f2fs_super_block *new_sb) +{ +int index, ret; +u_int8_t *buf; + + buf =calloc (BLOCK_SZ ,1 ); + +memcpy (buf +F2FS_SUPER_OFFSET , new_sb,sizeof (*new_sb)); +for (index =0 ; index <2 ; index++) { + ret =dev_write_block (buf, index); +ASSERT (ret >=0 ); + } +free (buf); +DBG (0 ,"Info: Done to rebuild superblock\n" ); +} +void build_nat_area_bitmap (struct f2fs_sb_info *sbi) {struct curseg_info *curseg =CURSEG_I (sbi,CURSEG_HOT_DATA );@@ -2314,6 +2330,26 @@ static int check_sector_size(struct f2fs_super_block *sb)return 0 ; } +static void tune_sb_features (struct f2fs_sb_info *sbi) +{ +int sb_changed =0 ; +struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi); + +if (!(sb->feature &cpu_to_le32 (F2FS_FEATURE_ENCRYPT )) && + c.feature &cpu_to_le32 (F2FS_FEATURE_ENCRYPT )) { + sb->feature |=cpu_to_le32 (F2FS_FEATURE_ENCRYPT ); +MSG (0 ,"Info: Set Encryption feature\n" ); + sb_changed =1 ; + } +/* TODO: quota needs to allocate inode numbers */ + + c.feature = sb->feature; +if (!sb_changed) +return ; + +write_superblock (sb); +} +int f2fs_do_mount (struct f2fs_sb_info *sbi) {struct f2fs_checkpoint *cp =NULL ;@@ -2365,7 +2401,8 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi) } c.bug_on =0 ; - c.feature = sb->feature; + +tune_sb_features (sbi);/* precompute checksum seed for metadata */ if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CHKSUM ))fsck/resize.c +0
-16@@ -569,22 +569,6 @@ static void rebuild_checkpoint(struct f2fs_sb_info *sbi,DBG (0 ,"Info: Done to rebuild checkpoint blocks\n" ); } -static void rebuild_superblock (struct f2fs_super_block *new_sb) -{ -int index, ret; -u_int8_t *buf; - - buf =calloc (BLOCK_SZ ,1 ); - -memcpy (buf +F2FS_SUPER_OFFSET , new_sb,sizeof (*new_sb)); -for (index =0 ; index <2 ; index++) { - ret =dev_write_block (buf, index); -ASSERT (ret >=0 ); - } -free (buf); -DBG (0 ,"Info: Done to rebuild superblock\n" ); -} -int f2fs_resize (struct f2fs_sb_info *sbi) {struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi);
fsck/resize.c int f2fs_resize(struct f2fs_sb_info *sbi) · line 625
Quoted 7 lines
fsck/resize.c +1
-1@@ -636,6 +620,6 @@ int f2fs_resize(struct f2fs_sb_info *sbi)migrate_nat (sbi, new_sb);migrate_sit (sbi, new_sb, offset_seg);rebuild_checkpoint (sbi, new_sb, offset_seg); -rebuild_superblock (new_sb); +write_superblock (new_sb);return 0 ; }
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 9 lines · Junling Zheng
Hi, Jaegeuk
Quoted 3 lines · Jaegeuk Kim
This patch add -O features for fsck.f2fs in order to tune the feature bits. Currently, it supports -O encrypt only.
Shall we introduce a new tool like tune.f2fs to tune the parameters of f2fs? Maybe we will tune others parameters in the future, not only features bits in sb :)
Agreed, one concern is we'd better separate tune functionality from fsck, other is that it will be more comfortable to use misc tools for the user changed their fs from extx to f2fs.
Thanks,
Quoted 173 lines
Quoted 155 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fsck/fsck.h | 1 + fsck/main.c | 9 ++++++++- fsck/mount.c | 39 ++++++++++++++++++++++++++++++++++++++- fsck/resize.c | 18 +----------------- 4 files changed, 48 insertions(+), 19 deletions(-)fsck/fsck.h +1
-0@@ -176,6 +176,7 @@ extern void move_curseg_info(struct f2fs_sb_info *, u64);extern void write_curseg_info (struct f2fs_sb_info *);extern int find_next_free_block (struct f2fs_sb_info *,u64 *,int ,int );extern void write_checkpoint (struct f2fs_sb_info *); +extern void write_superblock (struct f2fs_super_block *);extern void update_data_blkaddr (struct f2fs_sb_info *,nid_t ,u16 ,block_t );extern void update_nat_blkaddr (struct f2fs_sb_info *,nid_t ,nid_t ,block_t );fsck/main.c +8
-1@@ -28,6 +28,8 @@ struct f2fs_fsck gfsck;extern struct sparse_file *f2fs_sparse_file;#endif +INIT_FEATURE_TABLE ; +static char *absolute_path (const char *file) {char *ret;@@ -54,6 +56,7 @@ void fsck_usage()MSG (0 ," -d debug level [default:0]\n" );MSG (0 ," -f check/fix entire partition\n" );MSG (0 ," -g add default options\n" ); +MSG (0 ," -O feature1[feature2,feature3,...] e.g. \"encrypt\"\n" );MSG (0 ," -p preen mode [default:0 the same as -a [0|1]]\n" );MSG (0 ," -S sparse_mode\n" );MSG (0 ," -t show directory tree\n" );@@ -180,7 +183,7 @@ void f2fs_parse_options(int argc, char *argv[]) }if (!strcmp ("fsck.f2fs" , prog)) { -const char *option_string =":ad:fg:p:q:StyV" ; +const char *option_string =":ad:fg:O:p:q:StyV" ;int opt =0 ;struct option long_opt[] = { {"dry-run" , no_argument,0 ,1 },@@ -203,6 +206,10 @@ void f2fs_parse_options(int argc, char *argv[])if (!strcmp (optarg,"android" )) c.defset =CONF_ANDROID ;break ; +case 'O' : +if (parse_feature (feature_table, optarg)) +fsck_usage (); +break ;case 'p' :/* preen mode has different levels: * 0: default level, the same as -a fsck/mount.c +38
-1@@ -2144,6 +2144,22 @@ void write_checkpoint(struct f2fs_sb_info *sbi)ASSERT (ret >=0 ); } +void write_superblock (struct f2fs_super_block *new_sb) +{ +int index, ret; +u_int8_t *buf; + + buf =calloc (BLOCK_SZ ,1 ); + +memcpy (buf +F2FS_SUPER_OFFSET , new_sb,sizeof (*new_sb)); +for (index =0 ; index <2 ; index++) { + ret =dev_write_block (buf, index); +ASSERT (ret >=0 ); + } +free (buf); +DBG (0 ,"Info: Done to rebuild superblock\n" ); +} +void build_nat_area_bitmap (struct f2fs_sb_info *sbi) {struct curseg_info *curseg =CURSEG_I (sbi,CURSEG_HOT_DATA );@@ -2314,6 +2330,26 @@ static int check_sector_size(struct f2fs_super_block *sb)return 0 ; } +static void tune_sb_features (struct f2fs_sb_info *sbi) +{ +int sb_changed =0 ; +struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi); + +if (!(sb->feature &cpu_to_le32 (F2FS_FEATURE_ENCRYPT )) && + c.feature &cpu_to_le32 (F2FS_FEATURE_ENCRYPT )) { + sb->feature |=cpu_to_le32 (F2FS_FEATURE_ENCRYPT ); +MSG (0 ,"Info: Set Encryption feature\n" ); + sb_changed =1 ; + } +/* TODO: quota needs to allocate inode numbers */ + + c.feature = sb->feature; +if (!sb_changed) +return ; + +write_superblock (sb); +} +int f2fs_do_mount (struct f2fs_sb_info *sbi) {struct f2fs_checkpoint *cp =NULL ;@@ -2365,7 +2401,8 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi) } c.bug_on =0 ; - c.feature = sb->feature; + +tune_sb_features (sbi);/* precompute checksum seed for metadata */ if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CHKSUM ))fsck/resize.c +0
-16@@ -569,22 +569,6 @@ static void rebuild_checkpoint(struct f2fs_sb_info *sbi,DBG (0 ,"Info: Done to rebuild checkpoint blocks\n" ); } -static void rebuild_superblock (struct f2fs_super_block *new_sb) -{ -int index, ret; -u_int8_t *buf; - - buf =calloc (BLOCK_SZ ,1 ); - -memcpy (buf +F2FS_SUPER_OFFSET , new_sb,sizeof (*new_sb)); -for (index =0 ; index <2 ; index++) { - ret =dev_write_block (buf, index); -ASSERT (ret >=0 ); - } -free (buf); -DBG (0 ,"Info: Done to rebuild superblock\n" ); -} -int f2fs_resize (struct f2fs_sb_info *sbi) {struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi);fsck/resize.c int f2fs_resize(struct f2fs_sb_info *sbi) · line 625
Quoted 7 lines
fsck/resize.c +1
-1@@ -636,6 +620,6 @@ int f2fs_resize(struct f2fs_sb_info *sbi)migrate_nat (sbi, new_sb);migrate_sit (sbi, new_sb, offset_seg);rebuild_checkpoint (sbi, new_sb, offset_seg); -rebuild_superblock (new_sb); +write_superblock (new_sb);return 0 ; }------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 2 lines
.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 10 lines · Chao Yu
Quoted 9 lines · Junling Zheng
Hi, Jaegeuk
Quoted 3 lines · Jaegeuk Kim
This patch add -O features for fsck.f2fs in order to tune the feature bits. Currently, it supports -O encrypt only.
Shall we introduce a new tool like tune.f2fs to tune the parameters of f2fs? Maybe we will tune others parameters in the future, not only features bits in sb :)
Of course, that'd be better. But, I don't have strong motivation to add it for now. In order to tune one feature flag, do we have to say we need another tool?
Quoted 4 lines
Agreed, one concern is we'd better separate tune functionality from fsck, other is that it will be more comfortable to use misc tools for the user changed their fs from extx to f2fs.
That's very likely to be a TODO item. ;)
Thanks,
Quoted 178 lines
Thanks,
Quoted 175 lines
Quoted 155 lines
Signed-off-by Jaegeuk Kim <[email protected]>--- fsck/fsck.h | 1 + fsck/main.c | 9 ++++++++- fsck/mount.c | 39 ++++++++++++++++++++++++++++++++++++++- fsck/resize.c | 18 +----------------- 4 files changed, 48 insertions(+), 19 deletions(-)fsck/fsck.h +1
-0@@ -176,6 +176,7 @@ extern void move_curseg_info(struct f2fs_sb_info *, u64);extern void write_curseg_info (struct f2fs_sb_info *);extern int find_next_free_block (struct f2fs_sb_info *,u64 *,int ,int );extern void write_checkpoint (struct f2fs_sb_info *); +extern void write_superblock (struct f2fs_super_block *);extern void update_data_blkaddr (struct f2fs_sb_info *,nid_t ,u16 ,block_t );extern void update_nat_blkaddr (struct f2fs_sb_info *,nid_t ,nid_t ,block_t );fsck/main.c +8
-1@@ -28,6 +28,8 @@ struct f2fs_fsck gfsck;extern struct sparse_file *f2fs_sparse_file;#endif +INIT_FEATURE_TABLE ; +static char *absolute_path (const char *file) {char *ret;@@ -54,6 +56,7 @@ void fsck_usage()MSG (0 ," -d debug level [default:0]\n" );MSG (0 ," -f check/fix entire partition\n" );MSG (0 ," -g add default options\n" ); +MSG (0 ," -O feature1[feature2,feature3,...] e.g. \"encrypt\"\n" );MSG (0 ," -p preen mode [default:0 the same as -a [0|1]]\n" );MSG (0 ," -S sparse_mode\n" );MSG (0 ," -t show directory tree\n" );@@ -180,7 +183,7 @@ void f2fs_parse_options(int argc, char *argv[]) }if (!strcmp ("fsck.f2fs" , prog)) { -const char *option_string =":ad:fg:p:q:StyV" ; +const char *option_string =":ad:fg:O:p:q:StyV" ;int opt =0 ;struct option long_opt[] = { {"dry-run" , no_argument,0 ,1 },@@ -203,6 +206,10 @@ void f2fs_parse_options(int argc, char *argv[])if (!strcmp (optarg,"android" )) c.defset =CONF_ANDROID ;break ; +case 'O' : +if (parse_feature (feature_table, optarg)) +fsck_usage (); +break ;case 'p' :/* preen mode has different levels: * 0: default level, the same as -a fsck/mount.c +38
-1@@ -2144,6 +2144,22 @@ void write_checkpoint(struct f2fs_sb_info *sbi)ASSERT (ret >=0 ); } +void write_superblock (struct f2fs_super_block *new_sb) +{ +int index, ret; +u_int8_t *buf; + + buf =calloc (BLOCK_SZ ,1 ); + +memcpy (buf +F2FS_SUPER_OFFSET , new_sb,sizeof (*new_sb)); +for (index =0 ; index <2 ; index++) { + ret =dev_write_block (buf, index); +ASSERT (ret >=0 ); + } +free (buf); +DBG (0 ,"Info: Done to rebuild superblock\n" ); +} +void build_nat_area_bitmap (struct f2fs_sb_info *sbi) {struct curseg_info *curseg =CURSEG_I (sbi,CURSEG_HOT_DATA );@@ -2314,6 +2330,26 @@ static int check_sector_size(struct f2fs_super_block *sb)return 0 ; } +static void tune_sb_features (struct f2fs_sb_info *sbi) +{ +int sb_changed =0 ; +struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi); + +if (!(sb->feature &cpu_to_le32 (F2FS_FEATURE_ENCRYPT )) && + c.feature &cpu_to_le32 (F2FS_FEATURE_ENCRYPT )) { + sb->feature |=cpu_to_le32 (F2FS_FEATURE_ENCRYPT ); +MSG (0 ,"Info: Set Encryption feature\n" ); + sb_changed =1 ; + } +/* TODO: quota needs to allocate inode numbers */ + + c.feature = sb->feature; +if (!sb_changed) +return ; + +write_superblock (sb); +} +int f2fs_do_mount (struct f2fs_sb_info *sbi) {struct f2fs_checkpoint *cp =NULL ;@@ -2365,7 +2401,8 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi) } c.bug_on =0 ; - c.feature = sb->feature; + +tune_sb_features (sbi);/* precompute checksum seed for metadata */ if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CHKSUM ))fsck/resize.c +0
-16@@ -569,22 +569,6 @@ static void rebuild_checkpoint(struct f2fs_sb_info *sbi,DBG (0 ,"Info: Done to rebuild checkpoint blocks\n" ); } -static void rebuild_superblock (struct f2fs_super_block *new_sb) -{ -int index, ret; -u_int8_t *buf; - - buf =calloc (BLOCK_SZ ,1 ); - -memcpy (buf +F2FS_SUPER_OFFSET , new_sb,sizeof (*new_sb)); -for (index =0 ; index <2 ; index++) { - ret =dev_write_block (buf, index); -ASSERT (ret >=0 ); - } -free (buf); -DBG (0 ,"Info: Done to rebuild superblock\n" ); -} -int f2fs_resize (struct f2fs_sb_info *sbi) {struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi);fsck/resize.c int f2fs_resize(struct f2fs_sb_info *sbi) · line 625
Quoted 7 lines
fsck/resize.c +1
-1@@ -636,6 +620,6 @@ int f2fs_resize(struct f2fs_sb_info *sbi)migrate_nat (sbi, new_sb);migrate_sit (sbi, new_sb, offset_seg);rebuild_checkpoint (sbi, new_sb, offset_seg); -rebuild_superblock (new_sb); +write_superblock (new_sb);return 0 ; }------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
RFC PATCH 1/1 f2fs-tools: introduce tune.f2fs
In reply to Chao YuIntroduce tune.f2fs tool to change the f2fs parameters. Currently this tool only supports adding or removing encrypt feature bit in superblock.
--- fsck/Makefile.am | 3 ++- fsck/fsck.h | 5 +++++ fsck/main.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fsck/tune.c | 46 +++++++++++++++++++++++++++++++++++++++++ include/f2fs_fs.h | 61 +++++++++++++++++++++++++++++++++++++++---------------- man/Makefile.am | 2 +- man/tune.f2fs.8 | 50 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 207 insertions(+), 20 deletions(-) create mode 100644 fsck/tune.c create mode 100644 man/tune.f2fs.8
fsck/Makefile.am +2 -1
@@ -5,7 +5,7 @@ AM_CFLAGS = -Wall sbin_PROGRAMS = fsck.f2fs noinst_HEADERS = common.h dict.h dqblk_v2.h f2fs.h fsck.h node.h quotaio.h quotaio_tree.h quotaio_v2.h xattr.h include_HEADERS = $(top_srcdir)/include/quota.h -fsck_f2fs_SOURCES = main.c fsck.c dump.c mount.c defrag.c resize.c \ +fsck_f2fs_SOURCES = main.c fsck.c dump.c mount.c defrag.c resize.c tune.c \ node.c segment.c dir.c sload.c xattr.c \ dict.c mkquota.c quotaio.c quotaio_tree.c quotaio_v2.c fsck_f2fs_LDADD = ${libselinux_LIBS} ${libuuid_LIBS} $(top_builddir)/lib/libf2fs.la
@@ -15,3 +15,4 @@ install-data-hook: ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/defrag.f2fs ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/resize.f2fs ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/sload.f2fs + ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/tune.f2fs
fsck/fsck.h +5 -0
@@ -180,6 +180,8 @@ extern void write_superblock(struct f2fs_super_block *);extern void update_data_blkaddr (struct f2fs_sb_info *,nid_t ,u16 ,block_t );extern void update_nat_blkaddr (struct f2fs_sb_info *,nid_t ,nid_t ,block_t ); +extern int validate_super_block (struct f2fs_sb_info *,int ); +extern void print_sb_state (struct f2fs_super_block *);extern void print_raw_sb_info (struct f2fs_super_block *);extern u32 get_free_segments (struct f2fs_sb_info *);
@@ -220,6 +222,9 @@ int f2fs_resize(struct f2fs_sb_info *);/* sload.c */ int f2fs_sload (struct f2fs_sb_info *); +/* tune.c */ +int f2fs_tune (struct f2fs_sb_info *); +/* segment.c */ void reserve_new_block (struct f2fs_sb_info *,block_t *,struct f2fs_summary *,int );
fsck/main.c +60 -0
102 lines not on this page · raw message
fsck/tune.c new file +46 -0
46 lines not on this page · raw message
include/f2fs_fs.h +43 -18
107 lines not on this page · raw message
man/Makefile.am +1 -1
@@ -1,3 +1,3 @@ ## Makefile.am -dist_man_MANS = mkfs.f2fs.8 fsck.f2fs.8 dump.f2fs.8 defrag.f2fs.8 resize.f2fs.8 sload.f2fs.8 +dist_man_MANS = mkfs.f2fs.8 fsck.f2fs.8 dump.f2fs.8 defrag.f2fs.8 resize.f2fs.8 sload.f2fs.8 tune.f2fs.8
man/tune.f2fs.8 new file +50 -0
50 lines not on this page · raw message
Signature · 6 lines
2.16.2 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [RFC PATCH] f2fs-tools: introduce tune.f2fs
Ping...
Quoted 397 lines · Junling Zheng
Introduce tune.f2fs tool to change the f2fs parameters. Currently this tool only supports adding or removing encrypt feature bit in superblock.
Signed-off-by Junling Zheng <[email protected]>--- fsck/Makefile.am | 3 ++- fsck/fsck.h | 5 +++++ fsck/main.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fsck/tune.c | 46 +++++++++++++++++++++++++++++++++++++++++ include/f2fs_fs.h | 61 +++++++++++++++++++++++++++++++++++++++---------------- man/Makefile.am | 2 +- man/tune.f2fs.8 | 50 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 207 insertions(+), 20 deletions(-) create mode 100644 fsck/tune.c create mode 100644 man/tune.f2fs.8fsck/Makefile.am +2
-1@@ -5,7 +5,7 @@ AM_CFLAGS = -Wall sbin_PROGRAMS = fsck.f2fs noinst_HEADERS = common.h dict.h dqblk_v2.h f2fs.h fsck.h node.h quotaio.h quotaio_tree.h quotaio_v2.h xattr.h include_HEADERS = $(top_srcdir)/include/quota.h -fsck_f2fs_SOURCES = main.c fsck.c dump.c mount.c defrag.c resize.c \ +fsck_f2fs_SOURCES = main.c fsck.c dump.c mount.c defrag.c resize.c tune.c \ node.c segment.c dir.c sload.c xattr.c \ dict.c mkquota.c quotaio.c quotaio_tree.c quotaio_v2.c fsck_f2fs_LDADD = ${libselinux_LIBS} ${libuuid_LIBS} $(top_builddir)/lib/libf2fs.la@@ -15,3 +15,4 @@ install-data-hook: ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/defrag.f2fs ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/resize.f2fs ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/sload.f2fs + ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/tune.f2fsfsck/fsck.h +5
-0@@ -180,6 +180,8 @@ extern void write_superblock(struct f2fs_super_block *);extern void update_data_blkaddr (struct f2fs_sb_info *,nid_t ,u16 ,block_t );extern void update_nat_blkaddr (struct f2fs_sb_info *,nid_t ,nid_t ,block_t ); +extern int validate_super_block (struct f2fs_sb_info *,int ); +extern void print_sb_state (struct f2fs_super_block *);extern void print_raw_sb_info (struct f2fs_super_block *);extern u32 get_free_segments (struct f2fs_sb_info *);@@ -220,6 +222,9 @@ int f2fs_resize(struct f2fs_sb_info *);/* sload.c */ int f2fs_sload (struct f2fs_sb_info *); +/* tune.c */ +int f2fs_tune (struct f2fs_sb_info *); +/* segment.c */ void reserve_new_block (struct f2fs_sb_info *,block_t *,struct f2fs_summary *,int );fsck/main.c +60
-0@@ -29,6 +29,7 @@ extern struct sparse_file *f2fs_sparse_file;#endif INIT_FEATURE_TABLE ; +INIT_TUNE_FEATURE_TABLE ;static char *absolute_path (const char *file) {@@ -123,6 +124,15 @@ void sload_usage()exit (1 ); } +void tune_usage () +{ +MSG (0 ,"\nUsage: tune.f2fs [options] device\n" ); +MSG (0 ,"[options]:\n" ); +MSG (0 ," -d debug level [default:0]\n" ); +MSG (0 ," -O [^]feature[,...]\n" ); +exit (1 ); +} +static int is_digits (char *optarg) {unsigned int i;@@ -145,6 +155,8 @@ static void error_out(char *prog)resize_usage (); else if (!strcmp("sload.f2fs", prog))sload_usage (); + else if (!strcmp("tune.f2fs", prog)) +tune_usage (); else MSG(0, "\nWrong program.\n"); }@@ -528,6 +540,32 @@ void f2fs_parse_options(int argc, char *argv[])if (err !=NOERROR )break ; } + }else if (!strcmp ("tune.f2fs" , prog)) { +const char *option_string ="d:O:" ; + + c.func =TUNE ; +while ((option =getopt (argc, argv, option_string)) !=EOF ) { +switch (option) { +case 'd' : +if (!is_digits (optarg)) { + err =EWRONG_OPT ; +break ; + } + c.dbg_lv =atoi (optarg); +MSG (0 ,"Info: Debug level = %d\n" , + c.dbg_lv); +break ; +case 'O' : +if (parse_feature (tune_feature_table, optarg)) +tune_usage (); +break ; +default : + err =EUNKNOWN_OPT ; +break ; + } +if (err !=NOERROR ) +break ; + } }add_default_options ();@@ -736,6 +774,13 @@ static int do_sload(struct f2fs_sb_info *sbi)return f2fs_sload (sbi); } +static int do_tune (struct f2fs_sb_info *sbi) +{ +// TODO: check global configuration + +return f2fs_tune (sbi); +} +int main (int argc,char **argv) {struct f2fs_sb_info *sbi;@@ -768,6 +813,18 @@ fsck_again: gfsck.sbi.fsck = &gfsck; sbi = &gfsck.sbi; +#ifdef WITH_TUNE +if (c.func ==TUNE ) { + ret =do_tune (sbi); +if (ret) + goto out_err; +/* If tune successfully, then call +* f2fs_finalize_device to fsync. +*/ + goto out; + } +#endif + ret =f2fs_do_mount (sbi);if (ret !=0 ) {if (ret ==1 ) {@@ -836,6 +893,9 @@ retry: goto fsck_again; } } +#ifdef WITH_TUNE +out: +#endif ret =f2fs_finalize_device ();if (ret <0 )return ret;fsck/tune.c new file +46
-0@@ -0,0 +1,46 @@ +/** +* tune.c +* +* Copyright (C) 2018 Huawei Ltd. +* Witten by: +* Junling Zheng <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#include "fsck.h" + +int f2fs_tune (struct f2fs_sb_info *sbi) +{ +int ret; + +/* Get and validate sbi->raw_super */ + ret =validate_super_block (sbi,0 ); +if (ret) { + ret =validate_super_block (sbi,1 ); +if (ret) +return -1 ; + } + +/* Tune features in sb */ +if (c.feature) + sbi->raw_super->feature |= c.feature; +if (c.nofeature) + sbi->raw_super->feature &= ~c.nofeature; + +MSG (0 ,"Info: Tune feature successfully!\n" ); +/* Print features in sb */ +print_sb_state (sbi->raw_super); + +/* Write raw_super back to both 1st and 2nd sb on disk */ + ret =dev_write (sbi->raw_super,F2FS_SUPER_OFFSET , +sizeof (struct f2fs_super_block )); +ASSERT (ret >=0 ); + ret =dev_write (sbi->raw_super,F2FS_SUPER_OFFSET +F2FS_BLKSIZE , +sizeof (struct f2fs_super_block )); +ASSERT (ret >=0 ); +MSG (0 ,"Info: Writeback successfully!\n" ); + +return ret; +}include/f2fs_fs.h +43
-18@@ -13,6 +13,7 @@#define __F2FS_FS_H__#include <stdio.h> +#include <ctype.h> #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -28,6 +29,7 @@#define WITH_DEFRAG #define WITH_RESIZE #define WITH_SLOAD +#define WITH_TUNE #endif #include <inttypes.h> @@ -309,6 +311,7 @@ enum f2fs_config_func {DEFRAG ,RESIZE ,SLOAD , + TUNE, }; enum default_set {@@ -381,7 +384,8 @@ struct f2fs_configuration {int ro;int preserve_limits;/* preserve quota limits */ int large_nat_bitmap; -__le32 feature;/* defined features */ +__le32 feature;/* defined features to enable */ +__le32 nofeature;/* defined features to disable */ /* mkfs parameters */ u_int32_t next_free_nid;@@ -1334,6 +1338,12 @@ struct feature feature_table[] = { \ { NULL, 0x0}, \ }; +#define INIT_TUNE_FEATURE_TABLE \ +struct feature tune_feature_table[] = { \ + { "encrypt", F2FS_FEATURE_ENCRYPT }, \ + { NULL, 0x0}, \ +}; +static inline u32 feature_map (struct feature *table,char *feature) {struct feature *p;@@ -1342,21 +1352,11 @@ static inline u32 feature_map(struct feature *table, char *feature)return p->mask; } -static inline int set_feature_bits (struct feature *table,char *features) -{ -u32 mask =feature_map (table, features); -if (mask) { - c.feature |=cpu_to_le32 (mask); - }else { -MSG (0 ,"Error: Wrong features %s\n" , features); -return -1 ; - } -return 0 ; -} -static inline int parse_feature (struct feature *table,const char *features) { -char *buf, *sub, *next; +char op, *buf, *sub, *next; +u32 feature_bit =0 ; +int ret =0 ; buf =calloc (strlen (features) +1 ,sizeof (char ));ASSERT (buf);@@ -1376,12 +1376,37 @@ static inline int parse_feature(struct feature *table, const char *features) else *next =0 ; -if (set_feature_bits (table, sub)) { -free (buf); -return -1 ; +if (!isalnum (*sub)) { + op = *sub; + sub++; + }else { + op ='+' ; + } + + feature_bit =feature_map (table, sub); +if (!feature_bit) { +ERR_MSG ("\tError: Not support feature %s\n" , sub); + ret =-1 ; + goto out; + } + +switch (op) { +case '+' : + c.feature |=cpu_to_le32 (feature_bit); +break ; +case '-' : +case '^' : + c.nofeature |=cpu_to_le32 (feature_bit); +break ; +default : +ERR_MSG ("\tError: Wrong operation %c\n" , op); + ret =-1 ; + goto out; } } + +out:free (buf); -return 0 ; +return ret; }#endif /*__F2FS_FS_H */ man/Makefile.am +1
-1@@ -1,3 +1,3 @@ ## Makefile.am -dist_man_MANS = mkfs.f2fs.8 fsck.f2fs.8 dump.f2fs.8 defrag.f2fs.8 resize.f2fs.8 sload.f2fs.8 +dist_man_MANS = mkfs.f2fs.8 fsck.f2fs.8 dump.f2fs.8 defrag.f2fs.8 resize.f2fs.8 sload.f2fs.8 tune.f2fs.8man/tune.f2fs.8 new file +40
-0@@ -0,0 +1,50 @@ +.\" Copyright (C) 2015 Huawei Ltd. +.\" +.TH TUNE.F2FS 8 +.SH NAME +tune.f2fs \- change the parameters of f2fs +.SH SYNOPSIS +.B tune.f2fs +[ +.B \-d +.I debugging-level +] +[ +.B \-O +.I features to change +] +.I device +.SH DESCRIPTION +.B tune.f2fs +is used to change the parameters of an f2fs file system (usually in a disk partition). +\fIdevice\fP is the special file corresponding to the device (e.g. +\fI/dev/sdXX\fP). + +Current version only supports enabling and disabling 'encrypt' feature. + +.PP +The exit code returned by +.B tune.f2fs +is 0 on success and -1 on failure. +.SH OPTIONS +.TP +.BI \-d " debug-level" +Specify the level of debugging options. +The default number is 0, which shows basic debugging messages. +.TP +.BI \-O " features" +Specify the features to enable or disable. Currently only support 'encrypt' feature. +.TP +.SH AUTHOR +This version of +.B tune.f2fs
man/tune.f2fs.8 line 50
Quoted 10 lines
man/tune.f2fs.8 new file +10
-0+has been written by Junling Zheng <[email protected]>. +.SH AVAILABILITY +.B tune.f2fs +is available from git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git. +.SH SEE ALSO +.BR mkfs.f2fs(8), +.BR fsck.f2fs(8), +.BR dump.f2fs(8), +.BR defrag.f2fs(8), +.BR sload.f2fs(8).
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [RFC PATCH] f2fs-tools: introduce tune.f2fs
Quoted 6 lines · Junling Zheng
Ping...
Quoted 3 lines · Junling Zheng
Introduce tune.f2fs tool to change the f2fs parameters. Currently this tool only supports adding or removing encrypt feature bit in superblock.
What is the purpose of this empty tune.f2fs? How can we say we have this tool to users? You have to design what kind of things to support first.
Thanks,
Quoted 396 lines
Quoted 396 lines
Signed-off-by Junling Zheng <[email protected]>--- fsck/Makefile.am | 3 ++- fsck/fsck.h | 5 +++++ fsck/main.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ fsck/tune.c | 46 +++++++++++++++++++++++++++++++++++++++++ include/f2fs_fs.h | 61 +++++++++++++++++++++++++++++++++++++++---------------- man/Makefile.am | 2 +- man/tune.f2fs.8 | 50 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 207 insertions(+), 20 deletions(-) create mode 100644 fsck/tune.c create mode 100644 man/tune.f2fs.8fsck/Makefile.am +2
-1@@ -5,7 +5,7 @@ AM_CFLAGS = -Wall sbin_PROGRAMS = fsck.f2fs noinst_HEADERS = common.h dict.h dqblk_v2.h f2fs.h fsck.h node.h quotaio.h quotaio_tree.h quotaio_v2.h xattr.h include_HEADERS = $(top_srcdir)/include/quota.h -fsck_f2fs_SOURCES = main.c fsck.c dump.c mount.c defrag.c resize.c \ +fsck_f2fs_SOURCES = main.c fsck.c dump.c mount.c defrag.c resize.c tune.c \ node.c segment.c dir.c sload.c xattr.c \ dict.c mkquota.c quotaio.c quotaio_tree.c quotaio_v2.c fsck_f2fs_LDADD = ${libselinux_LIBS} ${libuuid_LIBS} $(top_builddir)/lib/libf2fs.la@@ -15,3 +15,4 @@ install-data-hook: ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/defrag.f2fs ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/resize.f2fs ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/sload.f2fs + ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/tune.f2fsfsck/fsck.h +5
-0@@ -180,6 +180,8 @@ extern void write_superblock(struct f2fs_super_block *);extern void update_data_blkaddr (struct f2fs_sb_info *,nid_t ,u16 ,block_t );extern void update_nat_blkaddr (struct f2fs_sb_info *,nid_t ,nid_t ,block_t ); +extern int validate_super_block (struct f2fs_sb_info *,int ); +extern void print_sb_state (struct f2fs_super_block *);extern void print_raw_sb_info (struct f2fs_super_block *);extern u32 get_free_segments (struct f2fs_sb_info *);@@ -220,6 +222,9 @@ int f2fs_resize(struct f2fs_sb_info *);/* sload.c */ int f2fs_sload (struct f2fs_sb_info *); +/* tune.c */ +int f2fs_tune (struct f2fs_sb_info *); +/* segment.c */ void reserve_new_block (struct f2fs_sb_info *,block_t *,struct f2fs_summary *,int );fsck/main.c +60
-0@@ -29,6 +29,7 @@ extern struct sparse_file *f2fs_sparse_file;#endif INIT_FEATURE_TABLE ; +INIT_TUNE_FEATURE_TABLE ;static char *absolute_path (const char *file) {@@ -123,6 +124,15 @@ void sload_usage()exit (1 ); } +void tune_usage () +{ +MSG (0 ,"\nUsage: tune.f2fs [options] device\n" ); +MSG (0 ,"[options]:\n" ); +MSG (0 ," -d debug level [default:0]\n" ); +MSG (0 ," -O [^]feature[,...]\n" ); +exit (1 ); +} +static int is_digits (char *optarg) {unsigned int i;@@ -145,6 +155,8 @@ static void error_out(char *prog)resize_usage (); else if (!strcmp("sload.f2fs", prog))sload_usage (); + else if (!strcmp("tune.f2fs", prog)) +tune_usage (); else MSG(0, "\nWrong program.\n"); }@@ -528,6 +540,32 @@ void f2fs_parse_options(int argc, char *argv[])if (err !=NOERROR )break ; } + }else if (!strcmp ("tune.f2fs" , prog)) { +const char *option_string ="d:O:" ; + + c.func =TUNE ; +while ((option =getopt (argc, argv, option_string)) !=EOF ) { +switch (option) { +case 'd' : +if (!is_digits (optarg)) { + err =EWRONG_OPT ; +break ; + } + c.dbg_lv =atoi (optarg); +MSG (0 ,"Info: Debug level = %d\n" , + c.dbg_lv); +break ; +case 'O' : +if (parse_feature (tune_feature_table, optarg)) +tune_usage (); +break ; +default : + err =EUNKNOWN_OPT ; +break ; + } +if (err !=NOERROR ) +break ; + } }add_default_options ();@@ -736,6 +774,13 @@ static int do_sload(struct f2fs_sb_info *sbi)return f2fs_sload (sbi); } +static int do_tune (struct f2fs_sb_info *sbi) +{ +// TODO: check global configuration + +return f2fs_tune (sbi); +} +int main (int argc,char **argv) {struct f2fs_sb_info *sbi;@@ -768,6 +813,18 @@ fsck_again: gfsck.sbi.fsck = &gfsck; sbi = &gfsck.sbi; +#ifdef WITH_TUNE +if (c.func ==TUNE ) { + ret =do_tune (sbi); +if (ret) + goto out_err; +/* If tune successfully, then call +* f2fs_finalize_device to fsync. +*/ + goto out; + } +#endif + ret =f2fs_do_mount (sbi);if (ret !=0 ) {if (ret ==1 ) {@@ -836,6 +893,9 @@ retry: goto fsck_again; } } +#ifdef WITH_TUNE +out: +#endif ret =f2fs_finalize_device ();if (ret <0 )return ret;fsck/tune.c new file +46
-0@@ -0,0 +1,46 @@ +/** +* tune.c +* +* Copyright (C) 2018 Huawei Ltd. +* Witten by: +* Junling Zheng <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#include "fsck.h" + +int f2fs_tune (struct f2fs_sb_info *sbi) +{ +int ret; + +/* Get and validate sbi->raw_super */ + ret =validate_super_block (sbi,0 ); +if (ret) { + ret =validate_super_block (sbi,1 ); +if (ret) +return -1 ; + } + +/* Tune features in sb */ +if (c.feature) + sbi->raw_super->feature |= c.feature; +if (c.nofeature) + sbi->raw_super->feature &= ~c.nofeature; + +MSG (0 ,"Info: Tune feature successfully!\n" ); +/* Print features in sb */ +print_sb_state (sbi->raw_super); + +/* Write raw_super back to both 1st and 2nd sb on disk */ + ret =dev_write (sbi->raw_super,F2FS_SUPER_OFFSET , +sizeof (struct f2fs_super_block )); +ASSERT (ret >=0 ); + ret =dev_write (sbi->raw_super,F2FS_SUPER_OFFSET +F2FS_BLKSIZE , +sizeof (struct f2fs_super_block )); +ASSERT (ret >=0 ); +MSG (0 ,"Info: Writeback successfully!\n" ); + +return ret; +}include/f2fs_fs.h +43
-18@@ -13,6 +13,7 @@#define __F2FS_FS_H__#include <stdio.h> +#include <ctype.h> #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -28,6 +29,7 @@#define WITH_DEFRAG #define WITH_RESIZE #define WITH_SLOAD +#define WITH_TUNE #endif #include <inttypes.h> @@ -309,6 +311,7 @@ enum f2fs_config_func {DEFRAG ,RESIZE ,SLOAD , + TUNE, }; enum default_set {@@ -381,7 +384,8 @@ struct f2fs_configuration {int ro;int preserve_limits;/* preserve quota limits */ int large_nat_bitmap; -__le32 feature;/* defined features */ +__le32 feature;/* defined features to enable */ +__le32 nofeature;/* defined features to disable */ /* mkfs parameters */ u_int32_t next_free_nid;@@ -1334,6 +1338,12 @@ struct feature feature_table[] = { \ { NULL, 0x0}, \ }; +#define INIT_TUNE_FEATURE_TABLE \ +struct feature tune_feature_table[] = { \ + { "encrypt", F2FS_FEATURE_ENCRYPT }, \ + { NULL, 0x0}, \ +}; +static inline u32 feature_map (struct feature *table,char *feature) {struct feature *p;@@ -1342,21 +1352,11 @@ static inline u32 feature_map(struct feature *table, char *feature)return p->mask; } -static inline int set_feature_bits (struct feature *table,char *features) -{ -u32 mask =feature_map (table, features); -if (mask) { - c.feature |=cpu_to_le32 (mask); - }else { -MSG (0 ,"Error: Wrong features %s\n" , features); -return -1 ; - } -return 0 ; -} -static inline int parse_feature (struct feature *table,const char *features) { -char *buf, *sub, *next; +char op, *buf, *sub, *next; +u32 feature_bit =0 ; +int ret =0 ; buf =calloc (strlen (features) +1 ,sizeof (char ));ASSERT (buf);@@ -1376,12 +1376,37 @@ static inline int parse_feature(struct feature *table, const char *features) else *next =0 ; -if (set_feature_bits (table, sub)) { -free (buf); -return -1 ; +if (!isalnum (*sub)) { + op = *sub; + sub++; + }else { + op ='+' ; + } + + feature_bit =feature_map (table, sub); +if (!feature_bit) { +ERR_MSG ("\tError: Not support feature %s\n" , sub); + ret =-1 ; + goto out; + } + +switch (op) { +case '+' : + c.feature |=cpu_to_le32 (feature_bit); +break ; +case '-' : +case '^' : + c.nofeature |=cpu_to_le32 (feature_bit); +break ; +default : +ERR_MSG ("\tError: Wrong operation %c\n" , op); + ret =-1 ; + goto out; } } + +out:free (buf); -return 0 ; +return ret; }#endif /*__F2FS_FS_H */ man/Makefile.am +1
-1@@ -1,3 +1,3 @@ ## Makefile.am -dist_man_MANS = mkfs.f2fs.8 fsck.f2fs.8 dump.f2fs.8 defrag.f2fs.8 resize.f2fs.8 sload.f2fs.8 +dist_man_MANS = mkfs.f2fs.8 fsck.f2fs.8 dump.f2fs.8 defrag.f2fs.8 resize.f2fs.8 sload.f2fs.8 tune.f2fs.8man/tune.f2fs.8 new file +43
-0@@ -0,0 +1,50 @@ +.\" Copyright (C) 2015 Huawei Ltd. +.\" +.TH TUNE.F2FS 8 +.SH NAME +tune.f2fs \- change the parameters of f2fs +.SH SYNOPSIS +.B tune.f2fs +[ +.B \-d +.I debugging-level +] +[ +.B \-O +.I features to change +] +.I device +.SH DESCRIPTION +.B tune.f2fs +is used to change the parameters of an f2fs file system (usually in a disk partition). +\fIdevice\fP is the special file corresponding to the device (e.g. +\fI/dev/sdXX\fP). + +Current version only supports enabling and disabling 'encrypt' feature. + +.PP +The exit code returned by +.B tune.f2fs +is 0 on success and -1 on failure. +.SH OPTIONS +.TP +.BI \-d " debug-level" +Specify the level of debugging options. +The default number is 0, which shows basic debugging messages. +.TP +.BI \-O " features" +Specify the features to enable or disable. Currently only support 'encrypt' feature. +.TP +.SH AUTHOR +This version of +.B tune.f2fs +has been written by Junling Zheng <[email protected]>. +.SH AVAILABILITY +.B tune.f2fs
Quoted 9 lines
man/tune.f2fs.8 line 50
Quoted 8 lines
man/tune.f2fs.8 new file +7
-0+is available from git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git. +.SH SEE ALSO +.BR mkfs.f2fs(8), +.BR fsck.f2fs(8), +.BR dump.f2fs(8), +.BR defrag.f2fs(8), +.BR sload.f2fs(8).
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [RFC PATCH] f2fs-tools: introduce tune.f2fs
Quoted 10 lines · Jaegeuk Kim
Quoted 6 lines · Junling Zheng
Ping...
Quoted 3 lines · Junling Zheng
Introduce tune.f2fs tool to change the f2fs parameters. Currently this tool only supports adding or removing encrypt feature bit in superblock.
What is the purpose of this empty tune.f2fs? How can we say we have this tool to users? You have to design what kind of things to support first.
I checked very initial tune2fs.c, it only supports very few parameters tuning functionality, but, can not say that is a bad start to introduce the misc tool.
+ fprintf (stderr, "Usage: %s [-c max-mounts-count] [-e errors-behavior] "
+ "[-i interval[d|m]]\n"
+ "\t[-l] [-m reserved-blocks-percent] device\n", program_name);
Maybe tuning 1. extension list, 2. multi device name later? just guess.
Using fsck.f2fs to tune parameter, IMO, maybe a little confuse for user to understand the tool's functionality.
Thanks,
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [RFC PATCH] f2fs-tools: introduce tune.f2fs
Quoted 15 lines · Chao Yu
Quoted 10 lines · Jaegeuk Kim
Quoted 6 lines · Junling Zheng
Ping...
Quoted 3 lines · Junling Zheng
Introduce tune.f2fs tool to change the f2fs parameters. Currently this tool only supports adding or removing encrypt feature bit in superblock.
What is the purpose of this empty tune.f2fs? How can we say we have this tool to users? You have to design what kind of things to support first.
I checked very initial
tune2fs.c, it only supports very few parameters tuning functionality, but, can not say that is a bad start to introduce the misc tool.
Review
Quoted 3 lines
(quoted diff) +3
-0+ fprintf (stderr, "Usage: %s [-c max-mounts-count] [-e errors-behavior] " + "[-i interval[d|m]]\n" + "\t[-l] [-m reserved-blocks-percent] device\n", program_name);
I don't think We have to follow that.
Quoted 2 lines
Maybe tuning 1. extension list, 2. multi device name later? just guess.
First of all, does it make sense to unset feature bits? I don't think so.
Agreed to your suggestion where:
1. feature set
- enable system quota
2. extension list
3. multi device name -- which may be really big trial
Quoted 5 lines
Using fsck.f2fs to tune parameter, IMO, maybe a little confuse for user to understand the tool's functionality.
Thanks,
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [RFC PATCH] f2fs-tools: introduce tune.f2fs
Quoted 20 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Quoted 10 lines · Jaegeuk Kim
Quoted 6 lines · Junling Zheng
Ping...
Quoted 3 lines · Junling Zheng
Introduce tune.f2fs tool to change the f2fs parameters. Currently this tool only supports adding or removing encrypt feature bit in superblock.
What is the purpose of this empty tune.f2fs? How can we say we have this tool to users? You have to design what kind of things to support first.
I checked very initial
tune2fs.c, it only supports very few parameters tuning functionality, but, can not say that is a bad start to introduce the misc tool.Review
Quoted 3 lines
(quoted diff) +3
-0+ fprintf (stderr, "Usage: %s [-c max-mounts-count] [-e errors-behavior] " + "[-i interval[d|m]]\n" + "\t[-l] [-m reserved-blocks-percent] device\n", program_name);
Quoted 6 lines
I don't think We have to follow that.
Quoted 2 lines
Maybe tuning 1. extension list, 2. multi device name later? just guess.
First of all, does it make sense to unset feature bits? I don't think so.
Some features can be turned off in a initial image? like encrypted, extra_attr, checksum...?
Quoted 6 lines
Agreed to your suggestion where:
1. feature set
- enable system quota
2. extension list
3. multi device name -- which may be really big trial
So what's our plan now? fill those features into fsck when we need them?
Thanks,
Quoted 9 lines
Quoted 6 lines
Using fsck.f2fs to tune parameter, IMO, maybe a little confuse for user to understand the tool's functionality.
Thanks,
.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [RFC PATCH] f2fs-tools: introduce tune.f2fs
Quoted 24 lines · Chao Yu
Quoted 23 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Quoted 10 lines · Jaegeuk Kim
Quoted 6 lines · Junling Zheng
Ping...
Quoted 3 lines · Junling Zheng
Introduce tune.f2fs tool to change the f2fs parameters. Currently this tool only supports adding or removing encrypt feature bit in superblock.
What is the purpose of this empty tune.f2fs? How can we say we have this tool to users? You have to design what kind of things to support first.
I checked very initial
tune2fs.c, it only supports very few parameters tuning functionality, but, can not say that is a bad start to introduce the misc tool.Review
Quoted 3 lines
(quoted diff) +3
-0+ fprintf (stderr, "Usage: %s [-c max-mounts-count] [-e errors-behavior] " + "[-i interval[d|m]]\n" + "\t[-l] [-m reserved-blocks-percent] device\n", program_name);I don't think We have to follow that.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Maybe tuning 1. extension list, 2. multi device name later? just guess.
First of all, does it make sense to unset feature bits? I don't think so.
Some features can be turned off in a initial image? like encrypted,
extra_attr, checksum...?
Any reason to do thtat? And, we need to find all the files whether there is any encrypted file.
Quoted 9 lines
Quoted 7 lines
Agreed to your suggestion where:
1. feature set
- enable system quota
2. extension list
3. multi device name -- which may be really big trialSo what's our plan now? fill those features into fsck when we need them?
No. If you want to add tune.f2fs, I'd like to see some demand, or very useful features like this. I just want to avoid introducing an (almost) empty tool.
Thanks,
Quoted 12 lines
Thanks,
Quoted 9 lines
Quoted 6 lines
Using fsck.f2fs to tune parameter, IMO, maybe a little confuse for user to understand the tool's functionality.
Thanks,
.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Re: [RFC PATCH] f2fs-tools: introduce tune.f2fs
Quoted 25 lines · Jaegeuk Kim
Quoted 24 lines · Chao Yu
Quoted 23 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Quoted 10 lines · Jaegeuk Kim
Quoted 6 lines · Junling Zheng
Ping...
Quoted 3 lines · Junling Zheng
Introduce tune.f2fs tool to change the f2fs parameters. Currently this tool only supports adding or removing encrypt feature bit in superblock.
What is the purpose of this empty tune.f2fs? How can we say we have this tool to users? You have to design what kind of things to support first.
I checked very initial
tune2fs.c, it only supports very few parameters tuning functionality, but, can not say that is a bad start to introduce the misc tool.Review
Quoted 3 lines
(quoted diff) +3
-0+ fprintf (stderr, "Usage: %s [-c max-mounts-count] [-e errors-behavior] " + "[-i interval[d|m]]\n" + "\t[-l] [-m reserved-blocks-percent] device\n", program_name);I don't think We have to follow that.
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Maybe tuning 1. extension list, 2. multi device name later? just guess.
First of all, does it make sense to unset feature bits? I don't think so.
Some features can be turned off in a initial image? like encrypted,
extra_attr, checksum...?Any reason to do thtat? And, we need to find all the files whether there is
Not very sure, just checked tune2fs, and found them in manual, guessing that there came demand from user who want to disable some feature in a formatted partition?
Quoted 10 lines
any encrypted file.
Quoted 8 lines
Quoted 7 lines
Agreed to your suggestion where:
1. feature set
- enable system quota
2. extension list
3. multi device name -- which may be really big trial
Quoted 4 lines
Quoted 1 line
So what's our plan now? fill those features into fsck when we need them?
No. If you want to add tune.f2fs, I'd like to see some demand, or very useful features like this. I just want to avoid introducing an (almost) empty tool.
Yeah, I see.
Maybe we can support below options except feature/extension_list/device_name.
-Q quota-options set,clear user/group/prjquota sysfile inode.
-U UUID set,clear uuid
-L volume-label set,clear volume name
Thanks,
Quoted 11 lines
Thanks,
Quoted 8 lines
Thanks,
Quoted 5 lines
Quoted 5 lines
Using fsck.f2fs to tune parameter, IMO, maybe a little confuse for user to understand the tool's functionality.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Thanks,
.
.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 4 lines · Jaegeuk Kim
This patch add -O features for fsck.f2fs in order to tune the feature bits. Currently, it supports -O encrypt only.
Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot