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.

Signed-off-by: Weichao Guo <[email protected]>
Signed-off-by: Chao Yu <[email protected]>
---
 fsck/mount.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index e2caac0..a34308e 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -939,6 +939,7 @@ int sanity_check_raw_super(struct f2fs_super_block *sb, 
enum SB_ADDR sb_addr)
 int validate_super_block(struct f2fs_sb_info *sbi, enum SB_ADDR sb_addr)
 {
        char buf[F2FS_BLKSIZE];
+       struct f2fs_checkpoint *cp = F2FS_CKPT(sbi);
 
        sbi->raw_super = malloc(sizeof(struct f2fs_super_block));
        if (!sbi->raw_super)
@@ -980,14 +981,11 @@ int validate_super_block(struct f2fs_sb_info *sbi, enum 
SB_ADDR 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;
+                       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",
-- 
2.7.4



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to