fsck.f2fs: use elapsed_time in checkpoint for period check
PATCH v2 1/1 fsck.f2fs: use elapsed_time in checkpoint for period check
We now use walltime for monthly period check. However the walltime is:
* unstable(timestamp register reset) and settable(modified by user)
* unreasonable(e.g: device power-off for one month, no data changed)
When the walltime changes to the past before one month or the future after one month, the period check in next fsck will fail to skip or start a full scan. So, let's use the elapsed_time in checkpoint as current time for period check.
--- fsck/mount.c | 85 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 43 deletions(-)
fsck/mount.c +42 -43
@@ -969,49 +969,6 @@ int validate_super_block(struct f2fs_sb_info *sbi, enum SB_ADDR sb_addr)MSG (0 ,"Info: MKFS version\n \"%s\"\n" , c.init_version);MSG (0 ,"Info: FSCK version\n from \"%s\"\n to \"%s\"\n" , c.sb_version, c.version); -#if defined(__APPLE__) -if (!c.no_kernel_check && -memcmp (c.sb_version, c.version,VERSION_NAME_LEN )) { - c.auto_fix =0 ; - c.fix_on =1 ; -memcpy (sbi->raw_super->version, - c.version,VERSION_NAME_LEN ); -update_superblock (sbi->raw_super,SB_MASK (sb_addr)); - } -#else -if (!c.no_kernel_check) { -struct timespec t; -u32 prev_time, cur_time, time_diff; -__le32 *ver_ts_ptr = (__le32 *)(sbi->raw_super->version - +VERSION_NAME_LEN ); - - t.tv_sec = t.tv_nsec =0 ; -clock_gettime (CLOCK_REALTIME , &t); - cur_time = (u32 )t.tv_sec; - prev_time =le32_to_cpu (*ver_ts_ptr); - -MSG (0 ,"Info: version timestamp cur: %u, prev: %u\n" , - cur_time, prev_time); -if (!memcmp (c.sb_version, c.version, -VERSION_NAME_LEN )) { -/* valid prev_time */ -if (prev_time !=0 && cur_time > prev_time) { - time_diff = cur_time - prev_time; -if (time_diff <CHECK_PERIOD ) - goto out; - c.auto_fix =0 ; - c.fix_on =1 ; - } - }else { -memcpy (sbi->raw_super->version, - c.version,VERSION_NAME_LEN ); - } - - *ver_ts_ptr =cpu_to_le32 (cur_time); -update_superblock (sbi->raw_super,SB_MASK (sb_addr)); - } -out: -#endif print_sb_state (sbi->raw_super);return 0 ; }
@@ -3582,6 +3539,48 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi)return -1 ; } +if (c.func ==FSCK ) { +#if defined(__APPLE__) +if (!c.no_kernel_check && +memcmp (c.sb_version, c.version,VERSION_NAME_LEN )) { + c.auto_fix =0 ; + c.fix_on =1 ; +memcpy (sbi->raw_super->version, + c.version,VERSION_NAME_LEN ); +update_superblock (sbi->raw_super,SB_MASK_ALL ); + } +#else +if (!c.no_kernel_check) { +u32 prev_time, cur_time, time_diff; +__le32 *ver_ts_ptr = (__le32 *)(sbi->raw_super->version + +VERSION_NAME_LEN ); + + cur_time = (u32 )get_cp (elapsed_time); + prev_time =le32_to_cpu (*ver_ts_ptr); + +MSG (0 ,"Info: version timestamp cur: %u, prev: %u\n" , + cur_time, prev_time); +if (!memcmp (c.sb_version, c.version, +VERSION_NAME_LEN )) { +/* valid prev_time */ +if (prev_time !=0 && cur_time > prev_time) { + time_diff = cur_time - prev_time; +if (time_diff <CHECK_PERIOD ) + goto out; + c.auto_fix =0 ; + c.fix_on =1 ; + } + }else { +memcpy (sbi->raw_super->version, + c.version,VERSION_NAME_LEN ); + } + + *ver_ts_ptr =cpu_to_le32 (cur_time); +update_superblock (sbi->raw_super,SB_MASK_ALL ); + } +#endif + } +out:print_ckpt_info (sbi);if (c.quota_fix) {
Signature · 8 lines
2.7.4 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 11 lines · Weichao Guo
We now use walltime for monthly period check. However the walltime is:
* unstable(timestamp register reset) and settable(modified by user)
*unreasonable(e.g: device power-off for one month, no data changed)When the walltime changes to the past before one month or the future after one month, the period check in next fsck will fail to skip or start a full scan. So, let's use the
elapsed_timein checkpoint as current time for period check.Signed-off-by Weichao Guo <[email protected]>Signed-off-by Chao Yu <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel