All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] fsck.f2fs: use elapsed_time in checkpoint for period check
@ 2022-08-12  5:23 Weichao Guo via Linux-f2fs-devel
  2022-08-15  3:38 ` Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Weichao Guo via Linux-f2fs-devel @ 2022-08-12  5:23 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: zhangshiming, linux-f2fs-devel

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 <guoweichao@oppo.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
 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
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [f2fs-dev] [PATCH] fsck.f2fs: use elapsed_time in checkpoint for period check
  2022-08-12  5:23 [f2fs-dev] [PATCH] fsck.f2fs: use elapsed_time in checkpoint for period check Weichao Guo via Linux-f2fs-devel
@ 2022-08-15  3:38 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2022-08-15  3:38 UTC (permalink / raw)
  To: Weichao Guo, jaegeuk; +Cc: zhangshiming, linux-f2fs-devel

On 2022/8/12 13:23, Weichao Guo wrote:
> 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 <guoweichao@oppo.com>
> Signed-off-by: Chao Yu <chao@kernel.org>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-15  3:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12  5:23 [f2fs-dev] [PATCH] fsck.f2fs: use elapsed_time in checkpoint for period check Weichao Guo via Linux-f2fs-devel
2022-08-15  3:38 ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.