fs: f2fs: use ktime_get_real_seconds for sit_info times
authorDeepa Dinamani <deepa.kernel@gmail.com>
Mon, 8 May 2017 22:59:10 +0000 (15:59 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 May 2017 00:15:15 +0000 (17:15 -0700)
CURRENT_TIME_SEC is not y2038 safe.

Replace use of CURRENT_TIME_SEC with ktime_get_real_seconds in segment
timestamps used by GC algorithm including the segment mtime timestamps.

Link: http://lkml.kernel.org/r/1491613030-11599-2-git-send-email-deepa.kernel@gmail.com
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/f2fs/segment.c
fs/f2fs/segment.h

index 13806f642ab5d2e21bed61d4386e0924672633c1..87c962705550cde44af29155f5ce0ea083a33b7a 100644 (file)
@@ -2573,7 +2573,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
        sit_i->dirty_sentries = 0;
        sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
        sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time);
-       sit_i->mounted_time = CURRENT_TIME_SEC.tv_sec;
+       sit_i->mounted_time = ktime_get_real_seconds();
        mutex_init(&sit_i->sentry_lock);
        return 0;
 }
index 5e8ad4280a5016d293817115a31a94daaf8d2d49..313b99040aa622c1cae1afdc3a8d200ee6e0dcc9 100644 (file)
@@ -691,8 +691,9 @@ static inline void set_to_next_sit(struct sit_info *sit_i, unsigned int start)
 static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi)
 {
        struct sit_info *sit_i = SIT_I(sbi);
-       return sit_i->elapsed_time + CURRENT_TIME_SEC.tv_sec -
-                                               sit_i->mounted_time;
+       time64_t now = ktime_get_real_seconds();
+
+       return sit_i->elapsed_time + now - sit_i->mounted_time;
 }
 
 static inline void set_summary(struct f2fs_summary *sum, nid_t nid,