mkfs.f2fs: add -r (fake_seed) and -T flags
PATCH 1/1 mkfs.f2fs: add -r (fake_seed) and -T flags
r flag sets the checkpointing seed to 0 (initially used to remove randomness for apex generation).
T flag sets timestamps to a given value.
--- include/f2fs_fs.h | 3 ++- man/mkfs.f2fs.8 | 13 +++++++++++++ mkfs/f2fs_format.c | 26 ++++++++++++++------------ mkfs/f2fs_format_main.c | 10 +++++++++- 4 files changed, 38 insertions(+), 14 deletions(-)
include/f2fs_fs.h +2 -1
@@ -405,8 +405,10 @@ struct f2fs_configuration {int large_nat_bitmap;int fix_chksum;/* fix old cp.chksum position */ __le32 feature;/* defined features */ +time_t fixed_time;/* mkfs parameters */ +int fake_seed;u_int32_t next_free_nid;u_int32_t quota_inum;u_int32_t quota_dnum;
@@ -427,7 +429,6 @@ struct f2fs_configuration {char *mount_point;char *target_out_dir;char *fs_config_file; -time_t fixed_time;#ifdef HAVE_LIBSELINUX struct selinux_opt seopt_file[8 ];int nr_opt;
man/mkfs.f2fs.8 +13 -0
@@ -59,6 +59,9 @@ mkfs.f2fs \- create an F2FS file system .B \-q ] [ +.B \-r +] +[ .B \-R .I root_owner ]
@@ -74,6 +77,10 @@ mkfs.f2fs \- create an F2FS file system .I nodiscard/discard ] [ +.B \-T +.I timestamp +] +[ .B \-w .I wanted-sector-size ]
@@ -212,6 +219,9 @@ Default is disabled. Quiet mode. With it, mkfs.f2fs does not show any messages, including the basic messages. .TP +.BI \-r +Sets the checkpointing srand seed to 0. +.TP .BI \-R Give root_owner option for initial uid/gid assignment. Default is set by getuid()/getgid(), and assigned by "-R $uid:$gid".
@@ -228,6 +238,9 @@ Enable sparse mode. Specify 1 or 0 to enable or disable discard policy, respectively. The default value is 1. .TP +.BI \-T " timestamp" +Set inodes times to a given timestamp. +.TP .BI \-w " wanted-sector-size" Specify the sector size in bytes. Without it, the sectors will be calculated by device sector size.
mkfs/f2fs_format.c +14 -12
@@ -692,7 +692,7 @@ static int f2fs_write_check_point_pack(void) }/* 1. cp page 1 of checkpoint pack 1 */ -srand (time (NULL )); +srand ((c.fake_seed) ?0 :time (NULL )); cp->checkpoint_ver =cpu_to_le64 (rand () |0x1 );set_cp (cur_node_segno[0 ], c.cur_seg[CURSEG_HOT_NODE ]);set_cp (cur_node_segno[1 ], c.cur_seg[CURSEG_WARM_NODE ]);
@@ -1192,11 +1192,11 @@ static int f2fs_write_root_inode(void) raw_node->i.i_size =cpu_to_le64 (1 * blk_size_bytes);/* dentry */ raw_node->i.i_blocks =cpu_to_le64 (2 ); - raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;
@@ -1213,7 +1213,8 @@ static int f2fs_write_root_inode(void) raw_node->i.i_projid =cpu_to_le32 (F2FS_DEF_PROJID );if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CRTIME )) { - raw_node->i.i_crtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_crtime =cpu_to_le32 ( + (c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_crtime_nsec =0 ; }
@@ -1350,11 +1351,11 @@ static int f2fs_write_qf_inode(int qtype) raw_node->i.i_size =cpu_to_le64 (1024 *6 );/* Hard coded */ raw_node->i.i_blocks =cpu_to_le64 (1 +QUOTA_DATA (qtype)); - raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;
@@ -1545,11 +1546,11 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_size =cpu_to_le64 (1 * blk_size_bytes); raw_node->i.i_blocks =cpu_to_le64 (2 ); - raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;
@@ -1569,7 +1570,8 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_projid =cpu_to_le32 (F2FS_DEF_PROJID );if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CRTIME )) { - raw_node->i.i_crtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_crtime =cpu_to_le32 ( + (c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_crtime_nsec =0 ; }
mkfs/f2fs_format_main.c +9 -1
@@ -59,10 +59,12 @@ static void mkfs_usage()MSG (0 ," -C [encoding[:flag1,...]] Support casefolding with optional flags\n" );MSG (0 ," -p number of pinned segments (2MB) [default:0]\n" );MSG (0 ," -q quiet mode\n" ); +MSG (0 ," -r set checkpointing seed (srand()) to 0\n" );MSG (0 ," -R root_owner [default: 0:0]\n" );MSG (0 ," -s # of segments per section [default:1]\n" );MSG (0 ," -S sparse mode\n" );MSG (0 ," -t 0: nodiscard, 1: discard [default:1]\n" ); +MSG (0 ," -T timestamps\n" );MSG (0 ," -w wanted sector size\n" );MSG (0 ," -z # of sections per zone [default:1]\n" );MSG (0 ," -V print the version number and exit\n" );
@@ -124,7 +126,7 @@ static void add_default_options(void)static void f2fs_parse_options (int argc,char *argv[]) { -static const char *option_string ="qa:c:C:d:e:E:g:il:mo:O:p:R:s:S:z:t:U:Vfw:" ; +static const char *option_string ="qa:c:C:d:e:E:g:il:mo:O:p:rR:s:S:z:t:T:U:Vfw:" ;int32_t option=0 ;int val;char *token;
@@ -187,6 +189,9 @@ static void f2fs_parse_options(int argc, char *argv[])case 'p' : c.pinned_segments =atof (optarg);break ; +case 'r' : + c.fake_seed =1 ; +break ;case 'R' :if (parse_root_owner (optarg, &c.root_uid, &c.root_gid))mkfs_usage ();
@@ -205,6 +210,9 @@ static void f2fs_parse_options(int argc, char *argv[])case 't' : c.trim =atoi (optarg);break ; +case 'T' : + c.fixed_time =strtoul (optarg,NULL ,0 ); +break ;case 'U' : c.vol_uuid =strdup (optarg);break ;
Signature · 8 lines
2.28.0.236.gb10cc79966-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 3 lines · On 2020/8/13 16:42, Theotime Combes via Linux-f2fs-devel wrote:
r flag sets the checkpointing seed to 0 (initially used to remove randomness for apex generation).
T flag sets timestamps to a given value.
Normally, we introduce one feature in one patch...it helps review, merge or revert patches more easily, how about splitting this into two.
Quoted 68 lines
Signed-off-by Theotime Combes <[email protected]>--- include/f2fs_fs.h | 3 ++- man/mkfs.f2fs.8 | 13 +++++++++++++ mkfs/f2fs_format.c | 26 ++++++++++++++------------ mkfs/f2fs_format_main.c | 10 +++++++++- 4 files changed, 38 insertions(+), 14 deletions(-)include/f2fs_fs.h +2
-1@@ -405,8 +405,10 @@ struct f2fs_configuration {int large_nat_bitmap;int fix_chksum;/* fix old cp.chksum position */ __le32 feature;/* defined features */ +time_t fixed_time;/* mkfs parameters */ +int fake_seed;u_int32_t next_free_nid;u_int32_t quota_inum;u_int32_t quota_dnum;@@ -427,7 +429,6 @@ struct f2fs_configuration {char *mount_point;char *target_out_dir;char *fs_config_file; -time_t fixed_time;#ifdef HAVE_LIBSELINUX struct selinux_opt seopt_file[8 ];int nr_opt;man/mkfs.f2fs.8 +10
-0@@ -59,6 +59,9 @@ mkfs.f2fs \- create an F2FS file system .B \-q ] [ +.B \-r +] +[ .B \-R .I root_owner ]@@ -74,6 +77,10 @@ mkfs.f2fs \- create an F2FS file system .I nodiscard/discard ] [ +.B \-T +.I timestamp +] +[ .B \-w .I wanted-sector-size ]@@ -212,6 +219,9 @@ Default is disabled. Quiet mode. With it, mkfs.f2fs does not show any messages, including the basic messages. .TP +.BI \-r +Sets the checkpointing srand seed to 0. +.TP .BI \-R Give root_owner option for initial uid/gid assignment. Default is set by getuid()/getgid(), and assigned by "-R $uid:$gid".
man/mkfs.f2fs.8 Enable sparse mode. · line 242
Quoted 5 lines
man/mkfs.f2fs.8 +2
-0@@ -228,6 +238,9 @@ Enable sparse mode. Specify 1 or 0 to enable or disable discard policy, respectively. The default value is 1. .TP +.BI \-T " timestamp" +Set inodes times to a given timestamp.
Can we set this value to -1?
Quoted 18 lines
man/mkfs.f2fs.8 +1
-0+.TP .BI \-w " wanted-sector-size" Specify the sector size in bytes. Without it, the sectors will be calculated by device sector size.mkfs/f2fs_format.c +1
-1@@ -692,7 +692,7 @@ static int f2fs_write_check_point_pack(void) }/* 1. cp page 1 of checkpoint pack 1 */ -srand (time (NULL )); +srand ((c.fake_seed) ?0 :time (NULL )); cp->checkpoint_ver =cpu_to_le64 (rand () |0x1 );set_cp (cur_node_segno[0 ], c.cur_seg[CURSEG_HOT_NODE ]);set_cp (cur_node_segno[1 ], c.cur_seg[CURSEG_WARM_NODE ]);
mkfs/f2fs_format.c static int f2fs_write_root_inode(void) · line 1195
Quoted 5 lines
mkfs/f2fs_format.c +1
-1@@ -1192,11 +1192,11 @@ static int f2fs_write_root_inode(void) raw_node->i.i_size =cpu_to_le64 (1 * blk_size_bytes);/* dentry */ raw_node->i.i_blocks =cpu_to_le64 (2 ); - raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time);
How about wrapping
(c.fixed_time == -1) ? time(NULL) : c.fixed_time)
to inline function or macro?
Thanks,
Quoted 97 lines
mkfs/f2fs_format.c +12
-10raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;@@ -1213,7 +1213,8 @@ static int f2fs_write_root_inode(void) raw_node->i.i_projid =cpu_to_le32 (F2FS_DEF_PROJID );if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CRTIME )) { - raw_node->i.i_crtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_crtime =cpu_to_le32 ( + (c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_crtime_nsec =0 ; }@@ -1350,11 +1351,11 @@ static int f2fs_write_qf_inode(int qtype) raw_node->i.i_size =cpu_to_le64 (1024 *6 );/* Hard coded */ raw_node->i.i_blocks =cpu_to_le64 (1 +QUOTA_DATA (qtype)); - raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;@@ -1545,11 +1546,11 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_size =cpu_to_le64 (1 * blk_size_bytes); raw_node->i.i_blocks =cpu_to_le64 (2 ); - raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;@@ -1569,7 +1570,8 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_projid =cpu_to_le32 (F2FS_DEF_PROJID );if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CRTIME )) { - raw_node->i.i_crtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_crtime =cpu_to_le32 ( + (c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_crtime_nsec =0 ; }mkfs/f2fs_format_main.c +6
-1@@ -59,10 +59,12 @@ static void mkfs_usage()MSG (0 ," -C [encoding[:flag1,...]] Support casefolding with optional flags\n" );MSG (0 ," -p number of pinned segments (2MB) [default:0]\n" );MSG (0 ," -q quiet mode\n" ); +MSG (0 ," -r set checkpointing seed (srand()) to 0\n" );MSG (0 ," -R root_owner [default: 0:0]\n" );MSG (0 ," -s # of segments per section [default:1]\n" );MSG (0 ," -S sparse mode\n" );MSG (0 ," -t 0: nodiscard, 1: discard [default:1]\n" ); +MSG (0 ," -T timestamps\n" );MSG (0 ," -w wanted sector size\n" );MSG (0 ," -z # of sections per zone [default:1]\n" );MSG (0 ," -V print the version number and exit\n" );@@ -124,7 +126,7 @@ static void add_default_options(void)static void f2fs_parse_options (int argc,char *argv[]) { -static const char *option_string ="qa:c:C:d:e:E:g:il:mo:O:p:R:s:S:z:t:U:Vfw:" ; +static const char *option_string ="qa:c:C:d:e:E:g:il:mo:O:p:rR:s:S:z:t:T:U:Vfw:" ;int32_t option=0 ;int val;char *token;@@ -187,6 +189,9 @@ static void f2fs_parse_options(int argc, char *argv[])case 'p' : c.pinned_segments =atof (optarg);break ; +case 'r' : + c.fake_seed =1 ; +break ;case 'R' :if (parse_root_owner (optarg, &c.root_uid, &c.root_gid))mkfs_usage ();
mkfs/f2fs_format_main.c static void f2fs_parse_options(int argc, char *argv[]) · line 218
Quoted 9 lines
mkfs/f2fs_format_main.c +3
-0@@ -205,6 +210,9 @@ static void f2fs_parse_options(int argc, char *argv[])case 't' : c.trim =atoi (optarg);break ; +case 'T' : + c.fixed_time =strtoul (optarg,NULL ,0 ); +break ;case 'U' : c.vol_uuid =strdup (optarg);break ;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 8 lines · Chao Yu
Quoted 3 lines · On 2020/8/13 16:42, Theotime Combes via Linux-f2fs-devel wrote:
r flag sets the checkpointing seed to 0 (initially used to remove randomness for apex generation).
T flag sets timestamps to a given value.Normally, we introduce one feature in one patch...it helps review, merge or revert patches more easily, how about splitting this into two.
Sure, I'll split it into two.
Quoted 67 lines
Quoted 67 lines
Signed-off-by Theotime Combes <[email protected]>--- include/f2fs_fs.h | 3 ++- man/mkfs.f2fs.8 | 13 +++++++++++++ mkfs/f2fs_format.c | 26 ++++++++++++++------------ mkfs/f2fs_format_main.c | 10 +++++++++- 4 files changed, 38 insertions(+), 14 deletions(-)include/f2fs_fs.h +2
-1@@ -405,8 +405,10 @@ struct f2fs_configuration {int large_nat_bitmap;int fix_chksum;/* fix old cp.chksum position */ __le32 feature;/* defined features */ +time_t fixed_time;/* mkfs parameters */ +int fake_seed;u_int32_t next_free_nid;u_int32_t quota_inum;u_int32_t quota_dnum;@@ -427,7 +429,6 @@ struct f2fs_configuration {char *mount_point;char *target_out_dir;char *fs_config_file; -time_t fixed_time;#ifdef HAVE_LIBSELINUX struct selinux_opt seopt_file[8 ];int nr_opt;man/mkfs.f2fs.8 +10
-0@@ -59,6 +59,9 @@ mkfs.f2fs \- create an F2FS file system .B \-q ] [ +.B \-r +] +[ .B \-R .I root_owner ]@@ -74,6 +77,10 @@ mkfs.f2fs \- create an F2FS file system .I nodiscard/discard ] [ +.B \-T +.I timestamp +] +[ .B \-w .I wanted-sector-size ]@@ -212,6 +219,9 @@ Default is disabled. Quiet mode. With it, mkfs.f2fs does not show any messages, including the basic messages. .TP +.BI \-r +Sets the checkpointing srand seed to 0. +.TP .BI \-R Give root_owner option for initial uid/gid assignment. Default is set by getuid()/getgid(), and assigned by "-R $uid:$gid".
Quoted 9 lines
man/mkfs.f2fs.8 Enable sparse mode. · line 242
Quoted 6 lines
man/mkfs.f2fs.8 +2
-0@@ -228,6 +238,9 @@ Enable sparse mode. Specify 1 or 0 to enable or disable discard policy, respectively. The default value is 1. .TP +.BI \-T " timestamp" +Set inodes times to a given timestamp.Can we set this value to -1?
-1 is used as an init value, therefore setting this value to -1 will fall back to using the current time. Should I specify it here ?
Quoted 21 lines
Quoted 21 lines
man/mkfs.f2fs.8 +1
-0+.TP .BI \-w " wanted-sector-size" Specify the sector size in bytes. Without it, the sectors will be calculated by device sector size.mkfs/f2fs_format.c +1
-1@@ -692,7 +692,7 @@ static int f2fs_write_check_point_pack(void) }/* 1. cp page 1 of checkpoint pack 1 */ -srand (time (NULL )); +srand ((c.fake_seed) ?0 :time (NULL )); cp->checkpoint_ver =cpu_to_le64 (rand () |0x1 );set_cp (cur_node_segno[0 ], c.cur_seg[CURSEG_HOT_NODE ]);set_cp (cur_node_segno[1 ], c.cur_seg[CURSEG_WARM_NODE ]);@@ -1192,11 +1192,11 @@ static int f2fs_write_root_inode(void) raw_node->i.i_size =cpu_to_le64 (1 * blk_size_bytes);/* dentry */ raw_node->i.i_blocks =cpu_to_le64 (2 );
Quoted 8 lines
mkfs/f2fs_format.c static int f2fs_write_root_inode(void) · line 1195
Quoted 2 lines
mkfs/f2fs_format.c +1
-1- raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time);How about wrapping
(c.fixed_time == -1) ? time(NULL) : c.fixed_time)
to inline function or macro?
I'll replace it with a macro in the new patch (once split), Thanks for the review!
Quoted 101 lines
Thanks,
Quoted 98 lines
mkfs/f2fs_format.c +12
-10raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;@@ -1213,7 +1213,8 @@ static int f2fs_write_root_inode(void) raw_node->i.i_projid =cpu_to_le32 (F2FS_DEF_PROJID );if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CRTIME )) { - raw_node->i.i_crtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_crtime =cpu_to_le32 ( + (c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_crtime_nsec =0 ; }@@ -1350,11 +1351,11 @@ static int f2fs_write_qf_inode(int qtype) raw_node->i.i_size =cpu_to_le64 (1024 *6 );/* Hard coded */ raw_node->i.i_blocks =cpu_to_le64 (1 +QUOTA_DATA (qtype)); - raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;@@ -1545,11 +1546,11 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_size =cpu_to_le64 (1 * blk_size_bytes); raw_node->i.i_blocks =cpu_to_le64 (2 ); - raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;@@ -1569,7 +1570,8 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_projid =cpu_to_le32 (F2FS_DEF_PROJID );if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CRTIME )) { - raw_node->i.i_crtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_crtime =cpu_to_le32 ( + (c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_crtime_nsec =0 ; }mkfs/f2fs_format_main.c +6
-1@@ -59,10 +59,12 @@ static void mkfs_usage()MSG (0 ," -C [encoding[:flag1,...]] Support casefolding with optional flags\n" );MSG (0 ," -p number of pinned segments (2MB) [default:0]\n" );MSG (0 ," -q quiet mode\n" ); +MSG (0 ," -r set checkpointing seed (srand()) to 0\n" );MSG (0 ," -R root_owner [default: 0:0]\n" );MSG (0 ," -s # of segments per section [default:1]\n" );MSG (0 ," -S sparse mode\n" );MSG (0 ," -t 0: nodiscard, 1: discard [default:1]\n" ); +MSG (0 ," -T timestamps\n" );MSG (0 ," -w wanted sector size\n" );MSG (0 ," -z # of sections per zone [default:1]\n" );MSG (0 ," -V print the version number and exit\n" );@@ -124,7 +126,7 @@ static void add_default_options(void)static void f2fs_parse_options (int argc,char *argv[]) { -static const char *option_string ="qa:c:C:d:e:E:g:il:mo:O:p:R:s:S:z:t:U:Vfw:" ; +static const char *option_string ="qa:c:C:d:e:E:g:il:mo:O:p:rR:s:S:z:t:T:U:Vfw:" ;int32_t option=0 ;int val;char *token;@@ -187,6 +189,9 @@ static void f2fs_parse_options(int argc, char *argv[])case 'p' : c.pinned_segments =atof (optarg);break ; +case 'r' : + c.fake_seed =1 ; +break ;case 'R' :if (parse_root_owner (optarg, &c.root_uid, &c.root_gid))mkfs_usage ();@@ -205,6 +210,9 @@ static void f2fs_parse_options(int argc, char *argv[])case 't' : c.trim =atoi (optarg);
Quoted 8 lines
mkfs/f2fs_format_main.c static void f2fs_parse_options(int argc, char *argv[]) · line 218
Quoted 8 lines
mkfs/f2fs_format_main.c +3
-0break ; +case 'T' : + c.fixed_time =strtoul (optarg,NULL ,0 ); +break ;case 'U' : c.vol_uuid =strdup (optarg);break ;
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 89 lines · Theotime Combes
Quoted 8 lines · Chao Yu
Quoted 3 lines · On 2020/8/13 16:42, Theotime Combes via Linux-f2fs-devel wrote:
r flag sets the checkpointing seed to 0 (initially used to remove randomness for apex generation).
T flag sets timestamps to a given value.Normally, we introduce one feature in one patch...it helps review, merge or revert patches more easily, how about splitting this into two.
Sure, I'll split it into two.
Quoted 67 lines
Quoted 67 lines
Signed-off-by Theotime Combes <[email protected]>--- include/f2fs_fs.h | 3 ++- man/mkfs.f2fs.8 | 13 +++++++++++++ mkfs/f2fs_format.c | 26 ++++++++++++++------------ mkfs/f2fs_format_main.c | 10 +++++++++- 4 files changed, 38 insertions(+), 14 deletions(-)include/f2fs_fs.h +2
-1@@ -405,8 +405,10 @@ struct f2fs_configuration {int large_nat_bitmap;int fix_chksum;/* fix old cp.chksum position */ __le32 feature;/* defined features */ +time_t fixed_time;/* mkfs parameters */ +int fake_seed;u_int32_t next_free_nid;u_int32_t quota_inum;u_int32_t quota_dnum;@@ -427,7 +429,6 @@ struct f2fs_configuration {char *mount_point;char *target_out_dir;char *fs_config_file; -time_t fixed_time;#ifdef HAVE_LIBSELINUX struct selinux_opt seopt_file[8 ];int nr_opt;man/mkfs.f2fs.8 +10
-0@@ -59,6 +59,9 @@ mkfs.f2fs \- create an F2FS file system .B \-q ] [ +.B \-r +] +[ .B \-R .I root_owner ]@@ -74,6 +77,10 @@ mkfs.f2fs \- create an F2FS file system .I nodiscard/discard ] [ +.B \-T +.I timestamp +] +[ .B \-w .I wanted-sector-size ]@@ -212,6 +219,9 @@ Default is disabled. Quiet mode. With it, mkfs.f2fs does not show any messages, including the basic messages. .TP +.BI \-r +Sets the checkpointing srand seed to 0. +.TP .BI \-R Give root_owner option for initial uid/gid assignment. Default is set by getuid()/getgid(), and assigned by "-R $uid:$gid".Quoted 9 lines
man/mkfs.f2fs.8 Enable sparse mode. · line 242
Quoted 6 lines
man/mkfs.f2fs.8 +2
-0@@ -228,6 +238,9 @@ Enable sparse mode. Specify 1 or 0 to enable or disable discard policy, respectively. The default value is 1. .TP +.BI \-T " timestamp" +Set inodes times to a given timestamp.Can we set this value to -1?
Quoted 2 lines
-1 is used as an init value, therefore setting this value to -1 will fall back to using the current time. Should I specify it here ?
Yes, it's better to add it into manual, :)
Thanks,
Quoted 136 lines
Quoted 22 lines
Quoted 22 lines
man/mkfs.f2fs.8 +1
-0+.TP .BI \-w " wanted-sector-size" Specify the sector size in bytes. Without it, the sectors will be calculated by device sector size.mkfs/f2fs_format.c +1
-1@@ -692,7 +692,7 @@ static int f2fs_write_check_point_pack(void) }/* 1. cp page 1 of checkpoint pack 1 */ -srand (time (NULL )); +srand ((c.fake_seed) ?0 :time (NULL )); cp->checkpoint_ver =cpu_to_le64 (rand () |0x1 );set_cp (cur_node_segno[0 ], c.cur_seg[CURSEG_HOT_NODE ]);set_cp (cur_node_segno[1 ], c.cur_seg[CURSEG_WARM_NODE ]);@@ -1192,11 +1192,11 @@ static int f2fs_write_root_inode(void) raw_node->i.i_size =cpu_to_le64 (1 * blk_size_bytes);/* dentry */ raw_node->i.i_blocks =cpu_to_le64 (2 );Quoted 8 lines
mkfs/f2fs_format.c static int f2fs_write_root_inode(void) · line 1195
Quoted 2 lines
mkfs/f2fs_format.c +1
-1- raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time);How about wrapping
(c.fixed_time == -1) ? time(NULL) : c.fixed_time)
to inline function or macro?
I'll replace it with a macro in the new patch (once split), Thanks for the review!
Quoted 102 lines
Thanks,
Quoted 99 lines
mkfs/f2fs_format.c +12
-10raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;@@ -1213,7 +1213,8 @@ static int f2fs_write_root_inode(void) raw_node->i.i_projid =cpu_to_le32 (F2FS_DEF_PROJID );if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CRTIME )) { - raw_node->i.i_crtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_crtime =cpu_to_le32 ( + (c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_crtime_nsec =0 ; }@@ -1350,11 +1351,11 @@ static int f2fs_write_qf_inode(int qtype) raw_node->i.i_size =cpu_to_le64 (1024 *6 );/* Hard coded */ raw_node->i.i_blocks =cpu_to_le64 (1 +QUOTA_DATA (qtype)); - raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;@@ -1545,11 +1546,11 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_size =cpu_to_le64 (1 * blk_size_bytes); raw_node->i.i_blocks =cpu_to_le64 (2 ); - raw_node->i.i_atime =cpu_to_le32 (time (NULL )); + raw_node->i.i_atime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_atime_nsec =0 ; - raw_node->i.i_ctime =cpu_to_le32 (time (NULL )); + raw_node->i.i_ctime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_ctime_nsec =0 ; - raw_node->i.i_mtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_mtime =cpu_to_le32 ((c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_mtime_nsec =0 ; raw_node->i.i_generation =0 ; raw_node->i.i_xattr_nid =0 ;@@ -1569,7 +1570,8 @@ static int f2fs_write_lpf_inode(void) raw_node->i.i_projid =cpu_to_le32 (F2FS_DEF_PROJID );if (c.feature &cpu_to_le32 (F2FS_FEATURE_INODE_CRTIME )) { - raw_node->i.i_crtime =cpu_to_le32 (time (NULL )); + raw_node->i.i_crtime =cpu_to_le32 ( + (c.fixed_time ==-1 ) ?time (NULL ) : c.fixed_time); raw_node->i.i_crtime_nsec =0 ; }mkfs/f2fs_format_main.c +6
-1@@ -59,10 +59,12 @@ static void mkfs_usage()MSG (0 ," -C [encoding[:flag1,...]] Support casefolding with optional flags\n" );MSG (0 ," -p number of pinned segments (2MB) [default:0]\n" );MSG (0 ," -q quiet mode\n" ); +MSG (0 ," -r set checkpointing seed (srand()) to 0\n" );MSG (0 ," -R root_owner [default: 0:0]\n" );MSG (0 ," -s # of segments per section [default:1]\n" );MSG (0 ," -S sparse mode\n" );MSG (0 ," -t 0: nodiscard, 1: discard [default:1]\n" ); +MSG (0 ," -T timestamps\n" );MSG (0 ," -w wanted sector size\n" );MSG (0 ," -z # of sections per zone [default:1]\n" );MSG (0 ," -V print the version number and exit\n" );@@ -124,7 +126,7 @@ static void add_default_options(void)static void f2fs_parse_options (int argc,char *argv[]) { -static const char *option_string ="qa:c:C:d:e:E:g:il:mo:O:p:R:s:S:z:t:U:Vfw:" ; +static const char *option_string ="qa:c:C:d:e:E:g:il:mo:O:p:rR:s:S:z:t:T:U:Vfw:" ;int32_t option=0 ;int val;char *token;@@ -187,6 +189,9 @@ static void f2fs_parse_options(int argc, char *argv[])case 'p' : c.pinned_segments =atof (optarg);break ; +case 'r' : + c.fake_seed =1 ; +break ;case 'R' :if (parse_root_owner (optarg, &c.root_uid, &c.root_gid))mkfs_usage ();@@ -205,6 +210,9 @@ static void f2fs_parse_options(int argc, char *argv[])case 't' : c.trim =atoi (optarg);break ;
Quoted 9 lines
Quoted 7 lines
mkfs/f2fs_format_main.c static void f2fs_parse_options(int argc, char *argv[]) · line 218
Quoted 7 lines
mkfs/f2fs_format_main.c +3
-0+case 'T' : + c.fixed_time =strtoul (optarg,NULL ,0 ); +break ;case 'U' : c.vol_uuid =strdup (optarg);break ;.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel