Skip to contentSkip to conversation

fsck.f2fs: use elapsed_time in checkpoint for period check

PATCH Superseded Weichao Guo via Linux-f2fs-devel 2 participants 2 messages Aug 12, 2022 – Aug 15, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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 | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fsck/mount.c +2 -4
index e2caac0..a34308e 100644
@@ -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",
Signature · 8 lines
2.7.4



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Reviewed-by on v1 1/1
#1 lore raw
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_time in checkpoint as current time for period check.

Thanks,

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