Whamcloud - gitweb
LU-9019 lfsck: migrate to 64 bit time 66/26466/7
authorJames Simmons <uja.ornl@yahoo.com>
Wed, 19 Jul 2017 04:49:42 +0000 (00:49 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 29 Jul 2017 00:02:23 +0000 (00:02 +0000)
Replace cfs_time_current_sec() to avoid the overflow
issues in 2038 with ktime_get_real_seconds(). The
reset of the lfsck code can move to time64_t as
well. Handle older lfsck on disk data formats that
contain 32 bit time formats. Newly generated on disk
data will always be 64 bit timestamps.

Change-Id: I1db47af3b9f462c31375f53a6216a095ab4767ad
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/26466
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lfsck/lfsck_engine.c
lustre/lfsck/lfsck_internal.h
lustre/lfsck/lfsck_layout.c
lustre/lfsck/lfsck_lib.c
lustre/lfsck/lfsck_namespace.c

index 0af5e95..ab0e6ff 100644 (file)
@@ -395,8 +395,7 @@ static int lfsck_checkpoint(const struct lu_env *env,
        int                     rc  = 0;
        int                     rc1 = 0;
 
        int                     rc  = 0;
        int                     rc1 = 0;
 
-       if (likely(cfs_time_beforeq(cfs_time_current(),
-                                   lfsck->li_time_next_checkpoint)))
+       if (likely(ktime_get_seconds() <= lfsck->li_time_next_checkpoint))
                return 0;
 
        lfsck_pos_fill(env, lfsck, &lfsck->li_pos_checkpoint, false);
                return 0;
 
        lfsck_pos_fill(env, lfsck, &lfsck->li_pos_checkpoint, false);
@@ -406,9 +405,9 @@ static int lfsck_checkpoint(const struct lu_env *env,
                        rc1 = rc;
        }
 
                        rc1 = rc;
        }
 
-       lfsck->li_time_last_checkpoint = cfs_time_current();
+       lfsck->li_time_last_checkpoint = ktime_get_seconds();
        lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
        lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
-                               cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+                                        LFSCK_CHECKPOINT_INTERVAL;
        return rc1 != 0 ? rc1 : rc;
 }
 
        return rc1 != 0 ? rc1 : rc;
 }
 
@@ -509,9 +508,9 @@ out:
                        break;
        }
 
                        break;
        }
 
-       lfsck->li_time_last_checkpoint = cfs_time_current();
+       lfsck->li_time_last_checkpoint = ktime_get_seconds();
        lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
        lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
-                               cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+                                        LFSCK_CHECKPOINT_INTERVAL;
        return rc;
 }
 
        return rc;
 }
 
@@ -608,9 +607,9 @@ static int lfsck_post(const struct lu_env *env, struct lfsck_instance *lfsck,
                               (__u32)com->lc_type, rc);
        }
 
                               (__u32)com->lc_type, rc);
        }
 
-       lfsck->li_time_last_checkpoint = cfs_time_current();
+       lfsck->li_time_last_checkpoint = ktime_get_seconds();
        lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
        lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
-                               cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+                                        LFSCK_CHECKPOINT_INTERVAL;
 
        /* Ignore some component post failure to make other can go ahead. */
        return result;
 
        /* Ignore some component post failure to make other can go ahead. */
        return result;
@@ -1672,10 +1671,10 @@ int lfsck_assistant_engine(void *args)
 
                        com->lc_new_checked = 0;
                        com->lc_new_scanned = 0;
 
                        com->lc_new_checked = 0;
                        com->lc_new_scanned = 0;
-                       com->lc_time_last_checkpoint = cfs_time_current();
+                       com->lc_time_last_checkpoint = ktime_get_seconds();
                        com->lc_time_next_checkpoint =
                                com->lc_time_last_checkpoint +
                        com->lc_time_next_checkpoint =
                                com->lc_time_last_checkpoint +
-                               cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+                               LFSCK_CHECKPOINT_INTERVAL;
 
                        CDEBUG(D_LFSCK, "%s: LFSCK assistant sync before "
                               "the second-stage scaning\n",
 
                        CDEBUG(D_LFSCK, "%s: LFSCK assistant sync before "
                               "the second-stage scaning\n",
index 3ab2472..942b247 100644 (file)
@@ -47,7 +47,6 @@
 #include <md_object.h>
 #include <lustre_linkea.h>
 
 #include <md_object.h>
 #include <lustre_linkea.h>
 
-#define HALF_SEC                       msecs_to_jiffies(MSEC_PER_SEC >> 1)
 #define LFSCK_CHECKPOINT_INTERVAL      60
 
 enum lfsck_flags {
 #define LFSCK_CHECKPOINT_INTERVAL      60
 
 enum lfsck_flags {
@@ -141,19 +140,19 @@ struct lfsck_namespace {
        __u32   ln_success_count;
 
        /*  How long the LFSCK phase1 has run in seconds. */
        __u32   ln_success_count;
 
        /*  How long the LFSCK phase1 has run in seconds. */
-       __u32   ln_run_time_phase1;
+       time64_t ln_run_time_phase1;
 
        /*  How long the LFSCK phase2 has run in seconds. */
 
        /*  How long the LFSCK phase2 has run in seconds. */
-       __u32   ln_run_time_phase2;
+       time64_t ln_run_time_phase2;
 
        /* Time for the last LFSCK completed in seconds since epoch. */
 
        /* Time for the last LFSCK completed in seconds since epoch. */
-       __u64   ln_time_last_complete;
+       time64_t ln_time_last_complete;
 
        /* Time for the latest LFSCK ran in seconds since epoch. */
 
        /* Time for the latest LFSCK ran in seconds since epoch. */
-       __u64   ln_time_latest_start;
+       time64_t ln_time_latest_start;
 
        /* Time for the last LFSCK checkpoint in seconds since epoch. */
 
        /* Time for the last LFSCK checkpoint in seconds since epoch. */
-       __u64   ln_time_last_checkpoint;
+       time64_t ln_time_last_checkpoint;
 
        /* Position for the latest LFSCK started from. */
        struct lfsck_position   ln_pos_latest_start;
 
        /* Position for the latest LFSCK started from. */
        struct lfsck_position   ln_pos_latest_start;
@@ -273,14 +272,17 @@ struct lfsck_namespace {
         * the MDTs that contain non-verified MDT-objects. */
        __u32   ln_bitmap_size;
 
         * the MDTs that contain non-verified MDT-objects. */
        __u32   ln_bitmap_size;
 
+       /* For further using. 256-bytes aligned now. */
+       __u32   ln_reserved_1;
+
        /* Time for the latest LFSCK scan in seconds from the beginning. */
        /* Time for the latest LFSCK scan in seconds from the beginning. */
-       __u32   ln_time_latest_reset;
+       time64_t ln_time_latest_reset;
 
        /* How many linkEA overflow timestamp have been cleared. */
        __u64   ln_linkea_overflow_cleared;
 
        /* For further using. 256-bytes aligned now. */
 
        /* How many linkEA overflow timestamp have been cleared. */
        __u64   ln_linkea_overflow_cleared;
 
        /* For further using. 256-bytes aligned now. */
-       __u64   ln_reserved[14];
+       __u64   ln_reserved[12];
 };
 
 enum lfsck_layout_inconsistency_type {
 };
 
 enum lfsck_layout_inconsistency_type {
@@ -308,19 +310,19 @@ struct lfsck_layout {
        __u32   ll_success_count;
 
        /*  How long the LFSCK phase1 has run in seconds. */
        __u32   ll_success_count;
 
        /*  How long the LFSCK phase1 has run in seconds. */
-       __u32   ll_run_time_phase1;
+       time64_t ll_run_time_phase1;
 
        /*  How long the LFSCK phase2 has run in seconds. */
 
        /*  How long the LFSCK phase2 has run in seconds. */
-       __u32   ll_run_time_phase2;
+       time64_t ll_run_time_phase2;
 
        /* Time for the last LFSCK completed in seconds since epoch. */
 
        /* Time for the last LFSCK completed in seconds since epoch. */
-       __u64   ll_time_last_complete;
+       time64_t ll_time_last_complete;
 
        /* Time for the latest LFSCK ran in seconds since epoch. */
 
        /* Time for the latest LFSCK ran in seconds since epoch. */
-       __u64   ll_time_latest_start;
+       time64_t ll_time_latest_start;
 
        /* Time for the last LFSCK checkpoint in seconds since epoch. */
 
        /* Time for the last LFSCK checkpoint in seconds since epoch. */
-       __u64   ll_time_last_checkpoint;
+       time64_t ll_time_last_checkpoint;
 
        /* Position for the latest LFSCK started from. */
        __u64   ll_pos_latest_start;
 
        /* Position for the latest LFSCK started from. */
        __u64   ll_pos_latest_start;
@@ -361,7 +363,8 @@ struct lfsck_layout {
        /* The latest object has been processed (failed) during double scan. */
        struct lfsck_layout_dangling_key ll_lldk_latest_scanned_phase2;
 
        /* The latest object has been processed (failed) during double scan. */
        struct lfsck_layout_dangling_key ll_lldk_latest_scanned_phase2;
 
-       __u64   ll_reserved_2[8];
+       /* For further using */
+       u64     ll_reserved_2[7];
 
        /* The OST targets bitmap to record the OSTs that contain
         * non-verified OST-objects. */
 
        /* The OST targets bitmap to record the OSTs that contain
         * non-verified OST-objects. */
@@ -556,11 +559,11 @@ struct lfsck_component {
        void                    *lc_data;
        struct lu_fid            lc_fid_latest_scanned_phase2;
 
        void                    *lc_data;
        struct lu_fid            lc_fid_latest_scanned_phase2;
 
-       /* The time for last checkpoint, jiffies */
-       cfs_time_t               lc_time_last_checkpoint;
+       /* The time for last checkpoint, seconds */
+       time64_t                 lc_time_last_checkpoint;
 
 
-       /* The time for next checkpoint, jiffies */
-       cfs_time_t               lc_time_next_checkpoint;
+       /* The time for next checkpoint, seconds */
+       time64_t                 lc_time_next_checkpoint;
 
        __u32                    lc_file_size;
 
 
        __u32                    lc_file_size;
 
@@ -670,11 +673,11 @@ struct lfsck_instance {
        atomic_t                  li_double_scan_count;
        struct ptlrpc_thread      li_thread;
 
        atomic_t                  li_double_scan_count;
        struct ptlrpc_thread      li_thread;
 
-       /* The time for last checkpoint, jiffies */
-       cfs_time_t                li_time_last_checkpoint;
+       /* The time for last checkpoint, seconds */
+       time64_t                  li_time_last_checkpoint;
 
 
-       /* The time for next checkpoint, jiffies */
-       cfs_time_t                li_time_next_checkpoint;
+       /* The time for next checkpoint, seconds */
+       time64_t                  li_time_next_checkpoint;
 
        lfsck_out_notify          li_out_notify;
        void                     *li_out_notify_data;
 
        lfsck_out_notify          li_out_notify;
        void                     *li_out_notify_data;
@@ -933,7 +936,7 @@ void lfsck_instance_cleanup(const struct lu_env *env,
                            struct lfsck_instance *lfsck);
 void lfsck_bits_dump(struct seq_file *m, int bits, const char *names[],
                     const char *prefix);
                            struct lfsck_instance *lfsck);
 void lfsck_bits_dump(struct seq_file *m, int bits, const char *names[],
                     const char *prefix);
-void lfsck_time_dump(struct seq_file *m, __u64 time, const char *name);
+void lfsck_time_dump(struct seq_file *m, time64_t time, const char *name);
 void lfsck_pos_dump(struct seq_file *m, struct lfsck_position *pos,
                    const char *prefix);
 void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck,
 void lfsck_pos_dump(struct seq_file *m, struct lfsck_position *pos,
                    const char *prefix);
 void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck,
index c445303..d31c74a 100644 (file)
@@ -51,8 +51,9 @@
 #define LFSCK_LAYOUT_MAGIC_V1          0xB173AE14
 #define LFSCK_LAYOUT_MAGIC_V2          0xB1734D76
 #define LFSCK_LAYOUT_MAGIC_V3          0xB17371B9
 #define LFSCK_LAYOUT_MAGIC_V1          0xB173AE14
 #define LFSCK_LAYOUT_MAGIC_V2          0xB1734D76
 #define LFSCK_LAYOUT_MAGIC_V3          0xB17371B9
+#define LFSCK_LAYOUT_MAGIC_V4          0xB1732FED
 
 
-#define LFSCK_LAYOUT_MAGIC             LFSCK_LAYOUT_MAGIC_V3
+#define LFSCK_LAYOUT_MAGIC             LFSCK_LAYOUT_MAGIC_V4
 
 struct lfsck_layout_seq {
        struct list_head         lls_list;
 
 struct lfsck_layout_seq {
        struct list_head         lls_list;
@@ -795,8 +796,8 @@ static void lfsck_layout_le_to_cpu(struct lfsck_layout *des,
        des->ll_status = le32_to_cpu(src->ll_status);
        des->ll_flags = le32_to_cpu(src->ll_flags);
        des->ll_success_count = le32_to_cpu(src->ll_success_count);
        des->ll_status = le32_to_cpu(src->ll_status);
        des->ll_flags = le32_to_cpu(src->ll_flags);
        des->ll_success_count = le32_to_cpu(src->ll_success_count);
-       des->ll_run_time_phase1 = le32_to_cpu(src->ll_run_time_phase1);
-       des->ll_run_time_phase2 = le32_to_cpu(src->ll_run_time_phase2);
+       des->ll_run_time_phase1 = le64_to_cpu(src->ll_run_time_phase1);
+       des->ll_run_time_phase2 = le64_to_cpu(src->ll_run_time_phase2);
        des->ll_time_last_complete = le64_to_cpu(src->ll_time_last_complete);
        des->ll_time_latest_start = le64_to_cpu(src->ll_time_latest_start);
        des->ll_time_last_checkpoint =
        des->ll_time_last_complete = le64_to_cpu(src->ll_time_last_complete);
        des->ll_time_latest_start = le64_to_cpu(src->ll_time_latest_start);
        des->ll_time_last_checkpoint =
@@ -827,8 +828,8 @@ static void lfsck_layout_cpu_to_le(struct lfsck_layout *des,
        des->ll_status = cpu_to_le32(src->ll_status);
        des->ll_flags = cpu_to_le32(src->ll_flags);
        des->ll_success_count = cpu_to_le32(src->ll_success_count);
        des->ll_status = cpu_to_le32(src->ll_status);
        des->ll_flags = cpu_to_le32(src->ll_flags);
        des->ll_success_count = cpu_to_le32(src->ll_success_count);
-       des->ll_run_time_phase1 = cpu_to_le32(src->ll_run_time_phase1);
-       des->ll_run_time_phase2 = cpu_to_le32(src->ll_run_time_phase2);
+       des->ll_run_time_phase1 = cpu_to_le64(src->ll_run_time_phase1);
+       des->ll_run_time_phase2 = cpu_to_le64(src->ll_run_time_phase2);
        des->ll_time_last_complete = cpu_to_le64(src->ll_time_last_complete);
        des->ll_time_latest_start = cpu_to_le64(src->ll_time_latest_start);
        des->ll_time_last_checkpoint =
        des->ll_time_last_complete = cpu_to_le64(src->ll_time_last_complete);
        des->ll_time_latest_start = cpu_to_le64(src->ll_time_latest_start);
        des->ll_time_last_checkpoint =
@@ -1442,9 +1443,9 @@ static int lfsck_layout_double_scan_result(const struct lu_env *env,
        struct lfsck_layout     *lo    = com->lc_file_ram;
 
        down_write(&com->lc_sem);
        struct lfsck_layout     *lo    = com->lc_file_ram;
 
        down_write(&com->lc_sem);
-       lo->ll_run_time_phase2 += cfs_duration_sec(cfs_time_current() +
-                                 HALF_SEC - com->lc_time_last_checkpoint);
-       lo->ll_time_last_checkpoint = cfs_time_current_sec();
+       lo->ll_run_time_phase2 += ktime_get_seconds() -
+                                 com->lc_time_last_checkpoint;
+       lo->ll_time_last_checkpoint = ktime_get_real_seconds();
        lo->ll_objs_checked_phase2 += com->lc_new_checked;
 
        if (rc > 0) {
        lo->ll_objs_checked_phase2 += com->lc_new_checked;
 
        if (rc > 0) {
@@ -4330,23 +4331,22 @@ checkpoint:
                if (rc < 0 && bk->lb_param & LPF_FAILOUT)
                        GOTO(put, rc);
 
                if (rc < 0 && bk->lb_param & LPF_FAILOUT)
                        GOTO(put, rc);
 
-               if (unlikely(cfs_time_beforeq(com->lc_time_next_checkpoint,
-                                             cfs_time_current())) &&
+               if (unlikely(com->lc_time_next_checkpoint <=
+                            ktime_get_seconds()) &&
                    com->lc_new_checked != 0) {
                        down_write(&com->lc_sem);
                    com->lc_new_checked != 0) {
                        down_write(&com->lc_sem);
-                       lo->ll_run_time_phase2 +=
-                               cfs_duration_sec(cfs_time_current() +
-                               HALF_SEC - com->lc_time_last_checkpoint);
-                       lo->ll_time_last_checkpoint = cfs_time_current_sec();
+                       lo->ll_run_time_phase2 += ktime_get_seconds() -
+                                                 com->lc_time_last_checkpoint;
+                       lo->ll_time_last_checkpoint = ktime_get_real_seconds();
                        lo->ll_objs_checked_phase2 += com->lc_new_checked;
                        com->lc_new_checked = 0;
                        lfsck_layout_store(env, com);
                        up_write(&com->lc_sem);
 
                        lo->ll_objs_checked_phase2 += com->lc_new_checked;
                        com->lc_new_checked = 0;
                        lfsck_layout_store(env, com);
                        up_write(&com->lc_sem);
 
-                       com->lc_time_last_checkpoint = cfs_time_current();
+                       com->lc_time_last_checkpoint = ktime_get_seconds();
                        com->lc_time_next_checkpoint =
                                com->lc_time_last_checkpoint +
                        com->lc_time_next_checkpoint =
                                com->lc_time_last_checkpoint +
-                               cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+                               LFSCK_CHECKPOINT_INTERVAL;
                }
 
                lfsck_control_speed_by_self(com);
                }
 
                lfsck_control_speed_by_self(com);
@@ -4412,9 +4412,9 @@ static int lfsck_layout_assistant_handler_p2(const struct lu_env *env,
 
                com->lc_new_checked = 0;
                com->lc_new_scanned = 0;
 
                com->lc_new_checked = 0;
                com->lc_new_scanned = 0;
-               com->lc_time_last_checkpoint = cfs_time_current();
+               com->lc_time_last_checkpoint = ktime_get_seconds();
                com->lc_time_next_checkpoint = com->lc_time_last_checkpoint +
                com->lc_time_next_checkpoint = com->lc_time_last_checkpoint +
-                               cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+                                              LFSCK_CHECKPOINT_INTERVAL;
 
                i = lfsck_sub_trace_file_fid2idx(
                                &lo->ll_lldk_latest_scanned_phase2.lldk_fid);
 
                i = lfsck_sub_trace_file_fid2idx(
                                &lo->ll_lldk_latest_scanned_phase2.lldk_fid);
@@ -4926,7 +4926,7 @@ static int lfsck_layout_reset(const struct lu_env *env,
                memset(lo, 0, com->lc_file_size);
        } else {
                __u32 count = lo->ll_success_count;
                memset(lo, 0, com->lc_file_size);
        } else {
                __u32 count = lo->ll_success_count;
-               __u64 last_time = lo->ll_time_last_complete;
+               time64_t last_time = lo->ll_time_last_complete;
 
                memset(lo, 0, com->lc_file_size);
                lo->ll_success_count = count;
 
                memset(lo, 0, com->lc_file_size);
                lo->ll_success_count = count;
@@ -4987,9 +4987,9 @@ static int lfsck_layout_master_checkpoint(const struct lu_env *env,
        } else {
                lo->ll_pos_last_checkpoint =
                                lfsck->li_pos_checkpoint.lp_oit_cookie;
        } else {
                lo->ll_pos_last_checkpoint =
                                lfsck->li_pos_checkpoint.lp_oit_cookie;
-               lo->ll_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
-                               HALF_SEC - lfsck->li_time_last_checkpoint);
-               lo->ll_time_last_checkpoint = cfs_time_current_sec();
+               lo->ll_run_time_phase1 += ktime_get_seconds() -
+                                         lfsck->li_time_last_checkpoint;
+               lo->ll_time_last_checkpoint = ktime_get_real_seconds();
                lo->ll_objs_checked_phase1 += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
                lo->ll_objs_checked_phase1 += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
@@ -5021,9 +5021,9 @@ static int lfsck_layout_slave_checkpoint(const struct lu_env *env,
        } else {
                lo->ll_pos_last_checkpoint =
                                lfsck->li_pos_checkpoint.lp_oit_cookie;
        } else {
                lo->ll_pos_last_checkpoint =
                                lfsck->li_pos_checkpoint.lp_oit_cookie;
-               lo->ll_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
-                               HALF_SEC - lfsck->li_time_last_checkpoint);
-               lo->ll_time_last_checkpoint = cfs_time_current_sec();
+               lo->ll_run_time_phase1 += ktime_get_seconds() -
+                                         lfsck->li_time_last_checkpoint;
+               lo->ll_time_last_checkpoint = ktime_get_real_seconds();
                lo->ll_objs_checked_phase1 += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
                lo->ll_objs_checked_phase1 += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
@@ -5067,7 +5067,7 @@ static int lfsck_layout_prep(const struct lu_env *env,
        }
 
        down_write(&com->lc_sem);
        }
 
        down_write(&com->lc_sem);
-       lo->ll_time_latest_start = cfs_time_current_sec();
+       lo->ll_time_latest_start = ktime_get_real_seconds();
        spin_lock(&lfsck->li_lock);
        if (lo->ll_flags & LF_SCANNED_ONCE) {
                if (!lfsck->li_drop_dryrun ||
        spin_lock(&lfsck->li_lock);
        if (lo->ll_flags & LF_SCANNED_ONCE) {
                if (!lfsck->li_drop_dryrun ||
@@ -5724,9 +5724,9 @@ static int lfsck_layout_master_post(const struct lu_env *env,
        spin_unlock(&lfsck->li_lock);
 
        if (!init) {
        spin_unlock(&lfsck->li_lock);
 
        if (!init) {
-               lo->ll_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
-                               HALF_SEC - lfsck->li_time_last_checkpoint);
-               lo->ll_time_last_checkpoint = cfs_time_current_sec();
+               lo->ll_run_time_phase1 += ktime_get_seconds() -
+                                         lfsck->li_time_last_checkpoint;
+               lo->ll_time_last_checkpoint = ktime_get_real_seconds();
                lo->ll_objs_checked_phase1 += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
                lo->ll_objs_checked_phase1 += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
@@ -5792,9 +5792,9 @@ static int lfsck_layout_slave_post(const struct lu_env *env,
                                     LE_LASTID_REBUILT);
 
        if (!init) {
                                     LE_LASTID_REBUILT);
 
        if (!init) {
-               lo->ll_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
-                               HALF_SEC - lfsck->li_time_last_checkpoint);
-               lo->ll_time_last_checkpoint = cfs_time_current_sec();
+               lo->ll_run_time_phase1 += ktime_get_seconds() -
+                                         lfsck->li_time_last_checkpoint;
+               lo->ll_time_last_checkpoint = ktime_get_real_seconds();
                lo->ll_objs_checked_phase1 += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
                lo->ll_objs_checked_phase1 += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
@@ -5871,25 +5871,23 @@ static void lfsck_layout_dump(const struct lu_env *env,
                   lo->ll_objs_failed_phase2);
 
        if (lo->ll_status == LS_SCANNING_PHASE1) {
                   lo->ll_objs_failed_phase2);
 
        if (lo->ll_status == LS_SCANNING_PHASE1) {
-               __u64 pos;
-               cfs_duration_t duration = cfs_time_current() -
-                                         lfsck->li_time_last_checkpoint;
-               __u64 checked = lo->ll_objs_checked_phase1 +
-                               com->lc_new_checked;
-               __u64 speed = checked;
-               __u64 new_checked = com->lc_new_checked *
-                                   msecs_to_jiffies(MSEC_PER_SEC);
-               __u32 rtime = lo->ll_run_time_phase1 +
-                             cfs_duration_sec(duration + HALF_SEC);
+               time64_t duration = ktime_get_seconds() -
+                                   lfsck->li_time_last_checkpoint;
+               u64 checked = lo->ll_objs_checked_phase1 +
+                             com->lc_new_checked;
+               u64 speed = checked;
+               u64 new_checked = com->lc_new_checked;
+               time64_t rtime = lo->ll_run_time_phase1 + duration;
+               u64 pos;
 
                if (duration != 0)
 
                if (duration != 0)
-                       do_div(new_checked, duration);
+                       div_u64(new_checked, duration);
                if (rtime != 0)
                if (rtime != 0)
-                       do_div(speed, rtime);
+                       div_u64(speed, rtime);
                seq_printf(m, "checked_phase1: %llu\n"
                           "checked_phase2: %llu\n"
                seq_printf(m, "checked_phase1: %llu\n"
                           "checked_phase2: %llu\n"
-                          "run_time_phase1: %u seconds\n"
-                          "run_time_phase2: %u seconds\n"
+                          "run_time_phase1: %lld seconds\n"
+                          "run_time_phase2: %lld seconds\n"
                           "average_speed_phase1: %llu items/sec\n"
                           "average_speed_phase2: N/A\n"
                           "real-time_speed_phase1: %llu items/sec\n"
                           "average_speed_phase1: %llu items/sec\n"
                           "average_speed_phase2: N/A\n"
                           "real-time_speed_phase1: %llu items/sec\n"
@@ -5918,27 +5916,25 @@ static void lfsck_layout_dump(const struct lu_env *env,
 
                seq_printf(m, "current_position: %llu\n", pos);
        } else if (lo->ll_status == LS_SCANNING_PHASE2) {
 
                seq_printf(m, "current_position: %llu\n", pos);
        } else if (lo->ll_status == LS_SCANNING_PHASE2) {
-               cfs_duration_t duration = cfs_time_current() -
-                                         com->lc_time_last_checkpoint;
-               __u64 checked = lo->ll_objs_checked_phase2 +
-                               com->lc_new_checked;
-               __u64 speed1 = lo->ll_objs_checked_phase1;
-               __u64 speed2 = checked;
-               __u64 new_checked = com->lc_new_checked *
-                                   msecs_to_jiffies(MSEC_PER_SEC);
-               __u32 rtime = lo->ll_run_time_phase2 +
-                             cfs_duration_sec(duration + HALF_SEC);
+               time64_t duration = ktime_get_seconds() -
+                                   com->lc_time_last_checkpoint;
+               u64 checked = lo->ll_objs_checked_phase2 +
+                             com->lc_new_checked;
+               u64 speed1 = lo->ll_objs_checked_phase1;
+               u64 speed2 = checked;
+               u64 new_checked = com->lc_new_checked;
+               time64_t rtime = lo->ll_run_time_phase2 + duration;
 
                if (duration != 0)
 
                if (duration != 0)
-                       do_div(new_checked, duration);
+                       div_u64(new_checked, duration);
                if (lo->ll_run_time_phase1 != 0)
                if (lo->ll_run_time_phase1 != 0)
-                       do_div(speed1, lo->ll_run_time_phase1);
+                       div_u64(speed1, lo->ll_run_time_phase1);
                if (rtime != 0)
                if (rtime != 0)
-                       do_div(speed2, rtime);
+                       div_u64(speed2, rtime);
                seq_printf(m, "checked_phase1: %llu\n"
                           "checked_phase2: %llu\n"
                seq_printf(m, "checked_phase1: %llu\n"
                           "checked_phase2: %llu\n"
-                          "run_time_phase1: %u seconds\n"
-                          "run_time_phase2: %u seconds\n"
+                          "run_time_phase1: %lld seconds\n"
+                          "run_time_phase2: %lld seconds\n"
                           "average_speed_phase1: %llu items/sec\n"
                           "average_speed_phase2: %llu items/sec\n"
                           "real-time_speed_phase1: N/A\n"
                           "average_speed_phase1: %llu items/sec\n"
                           "average_speed_phase2: %llu items/sec\n"
                           "real-time_speed_phase1: N/A\n"
@@ -5957,13 +5953,13 @@ static void lfsck_layout_dump(const struct lu_env *env,
                __u64 speed2 = lo->ll_objs_checked_phase2;
 
                if (lo->ll_run_time_phase1 != 0)
                __u64 speed2 = lo->ll_objs_checked_phase2;
 
                if (lo->ll_run_time_phase1 != 0)
-                       do_div(speed1, lo->ll_run_time_phase1);
+                       div_u64(speed1, lo->ll_run_time_phase1);
                if (lo->ll_run_time_phase2 != 0)
                if (lo->ll_run_time_phase2 != 0)
-                       do_div(speed2, lo->ll_run_time_phase2);
+                       div_u64(speed2, lo->ll_run_time_phase2);
                seq_printf(m, "checked_phase1: %llu\n"
                           "checked_phase2: %llu\n"
                seq_printf(m, "checked_phase1: %llu\n"
                           "checked_phase2: %llu\n"
-                          "run_time_phase1: %u seconds\n"
-                          "run_time_phase2: %u seconds\n"
+                          "run_time_phase1: %lld seconds\n"
+                          "run_time_phase2: %lld seconds\n"
                           "average_speed_phase1: %llu items/sec\n"
                           "average_speed_phase2: %llu objs/sec\n"
                           "real-time_speed_phase1: N/A\n"
                           "average_speed_phase1: %llu items/sec\n"
                           "average_speed_phase2: %llu objs/sec\n"
                           "real-time_speed_phase1: N/A\n"
@@ -6038,9 +6034,9 @@ static int lfsck_layout_slave_double_scan(const struct lu_env *env,
 
        com->lc_new_checked = 0;
        com->lc_new_scanned = 0;
 
        com->lc_new_checked = 0;
        com->lc_new_scanned = 0;
-       com->lc_time_last_checkpoint = cfs_time_current();
+       com->lc_time_last_checkpoint = ktime_get_seconds();
        com->lc_time_next_checkpoint = com->lc_time_last_checkpoint +
        com->lc_time_next_checkpoint = com->lc_time_last_checkpoint +
-                               cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+                                      LFSCK_CHECKPOINT_INTERVAL;
 
        while (1) {
                struct l_wait_info lwi = LWI_TIMEOUT(cfs_time_seconds(30),
 
        while (1) {
                struct l_wait_info lwi = LWI_TIMEOUT(cfs_time_seconds(30),
index 8316592..42b0c44 100644 (file)
@@ -1051,7 +1051,7 @@ static int lfsck_create_lpf(const struct lu_env *env,
        }
 
        memset(la, 0, sizeof(*la));
        }
 
        memset(la, 0, sizeof(*la));
-       la->la_atime = la->la_mtime = la->la_ctime = cfs_time_current_sec();
+       la->la_atime = la->la_mtime = la->la_ctime = ktime_get_real_seconds();
        la->la_mode = S_IFDIR | S_IRWXU;
        la->la_valid = LA_ATIME | LA_MTIME | LA_CTIME | LA_MODE |
                       LA_UID | LA_GID;
        la->la_mode = S_IFDIR | S_IRWXU;
        la->la_valid = LA_ATIME | LA_MTIME | LA_CTIME | LA_MODE |
                       LA_UID | LA_GID;
@@ -1767,15 +1767,15 @@ void lfsck_bits_dump(struct seq_file *m, int bits, const char *names[],
                seq_putc(m, '\n');
 }
 
                seq_putc(m, '\n');
 }
 
-void lfsck_time_dump(struct seq_file *m, __u64 time, const char *name)
+void lfsck_time_dump(struct seq_file *m, time64_t time, const char *name)
 {
        if (time == 0) {
                seq_printf(m, "%s_time: N/A\n", name);
                seq_printf(m, "time_since_%s: N/A\n", name);
        } else {
 {
        if (time == 0) {
                seq_printf(m, "%s_time: N/A\n", name);
                seq_printf(m, "time_since_%s: N/A\n", name);
        } else {
-               seq_printf(m, "%s_time: %llu\n", name, time);
-               seq_printf(m, "time_since_%s: %llu seconds\n",
-                          name, cfs_time_current_sec() - time);
+               seq_printf(m, "%s_time: %lld\n", name, time);
+               seq_printf(m, "time_since_%s: %lld seconds\n",
+                          name, ktime_get_real_seconds() - time);
        }
 }
 
        }
 }
 
index 5f0a6d4..b706833 100644 (file)
 
 #define LFSCK_NAMESPACE_MAGIC_V1       0xA0629D03
 #define LFSCK_NAMESPACE_MAGIC_V2       0xA0621A0B
 
 #define LFSCK_NAMESPACE_MAGIC_V1       0xA0629D03
 #define LFSCK_NAMESPACE_MAGIC_V2       0xA0621A0B
+#define LFSCK_NAMESPACE_MAGIC_V3       0xA06249FF
 
 /* For Lustre-2.x (x <= 6), the namespace LFSCK used LFSCK_NAMESPACE_MAGIC_V1
  * as the trace file magic. When downgrade to such old release, the old LFSCK
  * will not recognize the new LFSCK_NAMESPACE_MAGIC_V2 in the new trace file,
  * then it will reset the whole LFSCK, and will not cause start failure. The
  * similar case will happen when upgrade from such old release. */
 
 /* For Lustre-2.x (x <= 6), the namespace LFSCK used LFSCK_NAMESPACE_MAGIC_V1
  * as the trace file magic. When downgrade to such old release, the old LFSCK
  * will not recognize the new LFSCK_NAMESPACE_MAGIC_V2 in the new trace file,
  * then it will reset the whole LFSCK, and will not cause start failure. The
  * similar case will happen when upgrade from such old release. */
-#define LFSCK_NAMESPACE_MAGIC          LFSCK_NAMESPACE_MAGIC_V2
+#define LFSCK_NAMESPACE_MAGIC          LFSCK_NAMESPACE_MAGIC_V3
 
 enum lfsck_nameentry_check {
        LFSCK_NAMEENTRY_DEAD            = 1, /* The object has been unlinked. */
 
 enum lfsck_nameentry_check {
        LFSCK_NAMEENTRY_DEAD            = 1, /* The object has been unlinked. */
@@ -104,8 +105,8 @@ static void lfsck_namespace_le_to_cpu(struct lfsck_namespace *dst,
        dst->ln_status = le32_to_cpu(src->ln_status);
        dst->ln_flags = le32_to_cpu(src->ln_flags);
        dst->ln_success_count = le32_to_cpu(src->ln_success_count);
        dst->ln_status = le32_to_cpu(src->ln_status);
        dst->ln_flags = le32_to_cpu(src->ln_flags);
        dst->ln_success_count = le32_to_cpu(src->ln_success_count);
-       dst->ln_run_time_phase1 = le32_to_cpu(src->ln_run_time_phase1);
-       dst->ln_run_time_phase2 = le32_to_cpu(src->ln_run_time_phase2);
+       dst->ln_run_time_phase1 = le64_to_cpu(src->ln_run_time_phase1);
+       dst->ln_run_time_phase2 = le64_to_cpu(src->ln_run_time_phase2);
        dst->ln_time_last_complete = le64_to_cpu(src->ln_time_last_complete);
        dst->ln_time_latest_start = le64_to_cpu(src->ln_time_latest_start);
        dst->ln_time_last_checkpoint =
        dst->ln_time_last_complete = le64_to_cpu(src->ln_time_last_complete);
        dst->ln_time_latest_start = le64_to_cpu(src->ln_time_latest_start);
        dst->ln_time_last_checkpoint =
@@ -164,7 +165,7 @@ static void lfsck_namespace_le_to_cpu(struct lfsck_namespace *dst,
        dst->ln_local_lpf_skipped = le64_to_cpu(src->ln_local_lpf_skipped);
        dst->ln_local_lpf_failed = le64_to_cpu(src->ln_local_lpf_failed);
        dst->ln_bitmap_size = le32_to_cpu(src->ln_bitmap_size);
        dst->ln_local_lpf_skipped = le64_to_cpu(src->ln_local_lpf_skipped);
        dst->ln_local_lpf_failed = le64_to_cpu(src->ln_local_lpf_failed);
        dst->ln_bitmap_size = le32_to_cpu(src->ln_bitmap_size);
-       dst->ln_time_latest_reset = le32_to_cpu(src->ln_time_latest_reset);
+       dst->ln_time_latest_reset = le64_to_cpu(src->ln_time_latest_reset);
        dst->ln_linkea_overflow_cleared =
                                le64_to_cpu(src->ln_linkea_overflow_cleared);
 }
        dst->ln_linkea_overflow_cleared =
                                le64_to_cpu(src->ln_linkea_overflow_cleared);
 }
@@ -176,8 +177,8 @@ static void lfsck_namespace_cpu_to_le(struct lfsck_namespace *dst,
        dst->ln_status = cpu_to_le32(src->ln_status);
        dst->ln_flags = cpu_to_le32(src->ln_flags);
        dst->ln_success_count = cpu_to_le32(src->ln_success_count);
        dst->ln_status = cpu_to_le32(src->ln_status);
        dst->ln_flags = cpu_to_le32(src->ln_flags);
        dst->ln_success_count = cpu_to_le32(src->ln_success_count);
-       dst->ln_run_time_phase1 = cpu_to_le32(src->ln_run_time_phase1);
-       dst->ln_run_time_phase2 = cpu_to_le32(src->ln_run_time_phase2);
+       dst->ln_run_time_phase1 = cpu_to_le64(src->ln_run_time_phase1);
+       dst->ln_run_time_phase2 = cpu_to_le64(src->ln_run_time_phase2);
        dst->ln_time_last_complete = cpu_to_le64(src->ln_time_last_complete);
        dst->ln_time_latest_start = cpu_to_le64(src->ln_time_latest_start);
        dst->ln_time_last_checkpoint =
        dst->ln_time_last_complete = cpu_to_le64(src->ln_time_last_complete);
        dst->ln_time_latest_start = cpu_to_le64(src->ln_time_latest_start);
        dst->ln_time_last_checkpoint =
@@ -236,7 +237,7 @@ static void lfsck_namespace_cpu_to_le(struct lfsck_namespace *dst,
        dst->ln_local_lpf_skipped = cpu_to_le64(src->ln_local_lpf_skipped);
        dst->ln_local_lpf_failed = cpu_to_le64(src->ln_local_lpf_failed);
        dst->ln_bitmap_size = cpu_to_le32(src->ln_bitmap_size);
        dst->ln_local_lpf_skipped = cpu_to_le64(src->ln_local_lpf_skipped);
        dst->ln_local_lpf_failed = cpu_to_le64(src->ln_local_lpf_failed);
        dst->ln_bitmap_size = cpu_to_le32(src->ln_bitmap_size);
-       dst->ln_time_latest_reset = cpu_to_le32(src->ln_time_latest_reset);
+       dst->ln_time_latest_reset = cpu_to_le64(src->ln_time_latest_reset);
        dst->ln_linkea_overflow_cleared =
                                cpu_to_le64(src->ln_linkea_overflow_cleared);
 }
        dst->ln_linkea_overflow_cleared =
                                cpu_to_le64(src->ln_linkea_overflow_cleared);
 }
@@ -449,7 +450,7 @@ static int lfsck_namespace_init(const struct lu_env *env,
        memset(ns, 0, sizeof(*ns));
        ns->ln_magic = LFSCK_NAMESPACE_MAGIC;
        ns->ln_status = LS_INIT;
        memset(ns, 0, sizeof(*ns));
        ns->ln_magic = LFSCK_NAMESPACE_MAGIC;
        ns->ln_status = LS_INIT;
-       ns->ln_time_latest_reset = cfs_time_current_sec();
+       ns->ln_time_latest_reset = ktime_get_real_seconds();
        down_write(&com->lc_sem);
        rc = lfsck_namespace_store(env, com);
        if (rc == 0)
        down_write(&com->lc_sem);
        rc = lfsck_namespace_store(env, com);
        if (rc == 0)
@@ -1007,7 +1008,7 @@ again:
        }
 
        memset(la, 0, sizeof(*la));
        }
 
        memset(la, 0, sizeof(*la));
-       la->la_ctime = cfs_time_current_sec();
+       la->la_ctime = ktime_get_real_seconds();
        la->la_valid = LA_CTIME;
        rc = dt_declare_attr_set(env, orphan, la, th);
        if (rc != 0)
        la->la_valid = LA_CTIME;
        rc = dt_declare_attr_set(env, orphan, la, th);
        if (rc != 0)
@@ -1168,7 +1169,7 @@ static int lfsck_namespace_insert_normal(const struct lu_env *env,
        }
 
        memset(la, 0, sizeof(*la));
        }
 
        memset(la, 0, sizeof(*la));
-       la->la_ctime = cfs_time_current_sec();
+       la->la_ctime = ktime_get_real_seconds();
        la->la_valid = LA_CTIME;
        rc = dt_declare_attr_set(env, parent, la, th);
        if (rc != 0)
        la->la_valid = LA_CTIME;
        rc = dt_declare_attr_set(env, parent, la, th);
        if (rc != 0)
@@ -1195,7 +1196,7 @@ static int lfsck_namespace_insert_normal(const struct lu_env *env,
                        GOTO(stop, rc);
        }
 
                        GOTO(stop, rc);
        }
 
-       la->la_ctime = cfs_time_current_sec();
+       la->la_ctime = ktime_get_real_seconds();
        rc = dt_attr_set(env, parent, la, th);
        if (rc != 0)
                GOTO(stop, rc);
        rc = dt_attr_set(env, parent, la, th);
        if (rc != 0)
                GOTO(stop, rc);
@@ -3223,11 +3224,6 @@ out:
        return rc;
 }
 
        return rc;
 }
 
-#define lfsck_time_before(a, b)                \
-       (typecheck(__u32, a) &&         \
-        typecheck(__u32, b) &&         \
-        ((int)(a) - (int)(b) < 0))
-
 static inline bool
 lfsck_namespace_linkea_stale_overflow(struct linkea_data *ldata,
                                      struct lfsck_namespace *ns)
 static inline bool
 lfsck_namespace_linkea_stale_overflow(struct linkea_data *ldata,
                                      struct lfsck_namespace *ns)
@@ -3236,8 +3232,7 @@ lfsck_namespace_linkea_stale_overflow(struct linkea_data *ldata,
         * local time based, so need NOT to care about clock drift
         * among the servers. */
        return ldata->ld_leh->leh_overflow_time &&
         * local time based, so need NOT to care about clock drift
         * among the servers. */
        return ldata->ld_leh->leh_overflow_time &&
-              lfsck_time_before(ldata->ld_leh->leh_overflow_time,
-                                ns->ln_time_latest_reset);
+              ldata->ld_leh->leh_overflow_time < ns->ln_time_latest_reset;
 }
 
 /**
 }
 
 /**
@@ -3747,8 +3742,8 @@ static void lfsck_namespace_dump_statistics(struct seq_file *m,
                                            struct lfsck_namespace *ns,
                                            __u64 checked_phase1,
                                            __u64 checked_phase2,
                                            struct lfsck_namespace *ns,
                                            __u64 checked_phase1,
                                            __u64 checked_phase2,
-                                           __u32 time_phase1,
-                                           __u32 time_phase2, bool dryrun)
+                                           time64_t time_phase1,
+                                           time64_t time_phase2, bool dryrun)
 {
        const char *postfix = dryrun ? "inconsistent" : "repaired";
 
 {
        const char *postfix = dryrun ? "inconsistent" : "repaired";
 
@@ -3786,8 +3781,8 @@ static void lfsck_namespace_dump_statistics(struct seq_file *m,
                   "name_hash_%s: %llu\n"
                   "linkea_overflow_%s: %llu\n"
                   "success_count: %u\n"
                   "name_hash_%s: %llu\n"
                   "linkea_overflow_%s: %llu\n"
                   "success_count: %u\n"
-                  "run_time_phase1: %u seconds\n"
-                  "run_time_phase2: %u seconds\n",
+                  "run_time_phase1: %lld seconds\n"
+                  "run_time_phase2: %lld seconds\n",
                   checked_phase1,
                   checked_phase2,
                   dryrun ? "inconsistent" : "updated",
                   checked_phase1,
                   checked_phase2,
                   dryrun ? "inconsistent" : "updated",
@@ -3903,7 +3898,7 @@ static int lfsck_namespace_reset(const struct lu_env *env,
                memset(ns, 0, sizeof(*ns));
        } else {
                __u32 count = ns->ln_success_count;
                memset(ns, 0, sizeof(*ns));
        } else {
                __u32 count = ns->ln_success_count;
-               __u64 last_time = ns->ln_time_last_complete;
+               time64_t last_time = ns->ln_time_last_complete;
 
                memset(ns, 0, sizeof(*ns));
                ns->ln_success_count = count;
 
                memset(ns, 0, sizeof(*ns));
                ns->ln_success_count = count;
@@ -3911,7 +3906,7 @@ static int lfsck_namespace_reset(const struct lu_env *env,
        }
        ns->ln_magic = LFSCK_NAMESPACE_MAGIC;
        ns->ln_status = LS_INIT;
        }
        ns->ln_magic = LFSCK_NAMESPACE_MAGIC;
        ns->ln_status = LS_INIT;
-       ns->ln_time_latest_reset = cfs_time_current_sec();
+       ns->ln_time_latest_reset = ktime_get_real_seconds();
 
        rc = lfsck_load_one_trace_file(env, com, root, &com->lc_obj,
                                       &dt_lfsck_namespace_features,
 
        rc = lfsck_load_one_trace_file(env, com, root, &com->lc_obj,
                                       &dt_lfsck_namespace_features,
@@ -4065,9 +4060,9 @@ static int lfsck_namespace_checkpoint(const struct lu_env *env,
                ns->ln_pos_latest_start = lfsck->li_pos_checkpoint;
        } else {
                ns->ln_pos_last_checkpoint = lfsck->li_pos_checkpoint;
                ns->ln_pos_latest_start = lfsck->li_pos_checkpoint;
        } else {
                ns->ln_pos_last_checkpoint = lfsck->li_pos_checkpoint;
-               ns->ln_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
-                               HALF_SEC - lfsck->li_time_last_checkpoint);
-               ns->ln_time_last_checkpoint = cfs_time_current_sec();
+               ns->ln_run_time_phase1 += ktime_get_seconds() -
+                                         lfsck->li_time_last_checkpoint;
+               ns->ln_time_last_checkpoint = ktime_get_real_seconds();
                ns->ln_items_checked += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
                ns->ln_items_checked += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
@@ -4109,7 +4104,7 @@ static int lfsck_namespace_prep(const struct lu_env *env,
        }
 
        down_write(&com->lc_sem);
        }
 
        down_write(&com->lc_sem);
-       ns->ln_time_latest_start = cfs_time_current_sec();
+       ns->ln_time_latest_start = ktime_get_real_seconds();
        spin_lock(&lfsck->li_lock);
 
        if (ns->ln_flags & LF_SCANNED_ONCE) {
        spin_lock(&lfsck->li_lock);
 
        if (ns->ln_flags & LF_SCANNED_ONCE) {
@@ -4373,9 +4368,9 @@ static int lfsck_namespace_post(const struct lu_env *env,
        spin_unlock(&lfsck->li_lock);
 
        if (!init) {
        spin_unlock(&lfsck->li_lock);
 
        if (!init) {
-               ns->ln_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
-                               HALF_SEC - lfsck->li_time_last_checkpoint);
-               ns->ln_time_last_checkpoint = cfs_time_current_sec();
+               ns->ln_run_time_phase1 += ktime_get_seconds() -
+                                         lfsck->li_time_last_checkpoint;
+               ns->ln_time_last_checkpoint = ktime_get_real_seconds();
                ns->ln_items_checked += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
                ns->ln_items_checked += com->lc_new_checked;
                com->lc_new_checked = 0;
        }
@@ -4426,20 +4421,18 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
 
        if (ns->ln_status == LS_SCANNING_PHASE1) {
                struct lfsck_position pos;
 
        if (ns->ln_status == LS_SCANNING_PHASE1) {
                struct lfsck_position pos;
-               cfs_duration_t duration = cfs_time_current() -
-                                         lfsck->li_time_last_checkpoint;
-               __u64 checked = ns->ln_items_checked + com->lc_new_checked;
-               __u64 speed = checked;
-               __u64 new_checked = com->lc_new_checked *
-                                   msecs_to_jiffies(MSEC_PER_SEC);
-               __u32 rtime = ns->ln_run_time_phase1 +
-                             cfs_duration_sec(duration + HALF_SEC);
+               time64_t duration = ktime_get_seconds() -
+                                   lfsck->li_time_last_checkpoint;
+               u64 checked = ns->ln_items_checked + com->lc_new_checked;
+               u64 speed = checked;
+               u64 new_checked = com->lc_new_checked;
+               time64_t rtime = ns->ln_run_time_phase1 + duration;
 
                if (duration != 0)
 
                if (duration != 0)
-                       do_div(new_checked, duration);
+                       div_u64(new_checked, duration);
 
                if (rtime != 0)
 
                if (rtime != 0)
-                       do_div(speed, rtime);
+                       div_u64(speed, rtime);
 
                lfsck_namespace_dump_statistics(m, ns, checked, 0, rtime, 0,
                                                bk->lb_param & LPF_DRYRUN);
 
                lfsck_namespace_dump_statistics(m, ns, checked, 0, rtime, 0,
                                                bk->lb_param & LPF_DRYRUN);
@@ -4485,34 +4478,32 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
 
                lfsck_pos_dump(m, &pos, "current_position");
        } else if (ns->ln_status == LS_SCANNING_PHASE2) {
 
                lfsck_pos_dump(m, &pos, "current_position");
        } else if (ns->ln_status == LS_SCANNING_PHASE2) {
-               cfs_duration_t duration = cfs_time_current() -
-                                         com->lc_time_last_checkpoint;
+               time64_t duration = ktime_get_seconds() -
+                                   com->lc_time_last_checkpoint;
                __u64 checked = ns->ln_objs_checked_phase2 +
                                com->lc_new_checked;
                __u64 speed1 = ns->ln_items_checked;
                __u64 speed2 = checked;
                __u64 speed0 = speed1 + speed2;
                __u64 checked = ns->ln_objs_checked_phase2 +
                                com->lc_new_checked;
                __u64 speed1 = ns->ln_items_checked;
                __u64 speed2 = checked;
                __u64 speed0 = speed1 + speed2;
-               __u64 new_checked = com->lc_new_checked *
-                                   msecs_to_jiffies(MSEC_PER_SEC);
-               __u32 rtime = ns->ln_run_time_phase2 +
-                             cfs_duration_sec(duration + HALF_SEC);
-               __u32 time0 = ns->ln_run_time_phase1 + rtime;
+               __u64 new_checked = com->lc_new_checked;
+               time64_t rtime = ns->ln_run_time_phase2 + duration;
+               time64_t time0 = ns->ln_run_time_phase1 + rtime;
 
                if (duration != 0)
 
                if (duration != 0)
-                       do_div(new_checked, duration);
+                       div_u64(new_checked, duration);
 
                if (ns->ln_run_time_phase1 != 0)
 
                if (ns->ln_run_time_phase1 != 0)
-                       do_div(speed1, ns->ln_run_time_phase1);
+                       div_u64(speed1, ns->ln_run_time_phase1);
                else if (ns->ln_items_checked != 0)
                        time0++;
 
                if (rtime != 0)
                else if (ns->ln_items_checked != 0)
                        time0++;
 
                if (rtime != 0)
-                       do_div(speed2, rtime);
+                       div_u64(speed2, rtime);
                else if (checked != 0)
                        time0++;
 
                if (time0 != 0)
                else if (checked != 0)
                        time0++;
 
                if (time0 != 0)
-                       do_div(speed0, time0);
+                       div_u64(speed0, time0);
 
                lfsck_namespace_dump_statistics(m, ns, ns->ln_items_checked,
                                                checked,
 
                lfsck_namespace_dump_statistics(m, ns, ns->ln_items_checked,
                                                checked,
@@ -4533,20 +4524,20 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com,
                __u64 speed1 = ns->ln_items_checked;
                __u64 speed2 = ns->ln_objs_checked_phase2;
                __u64 speed0 = speed1 + speed2;
                __u64 speed1 = ns->ln_items_checked;
                __u64 speed2 = ns->ln_objs_checked_phase2;
                __u64 speed0 = speed1 + speed2;
-               __u32 time0 = ns->ln_run_time_phase1 + ns->ln_run_time_phase2;
+               time64_t time0 = ns->ln_run_time_phase1 + ns->ln_run_time_phase2;
 
                if (ns->ln_run_time_phase1 != 0)
 
                if (ns->ln_run_time_phase1 != 0)
-                       do_div(speed1, ns->ln_run_time_phase1);
+                       div_u64(speed1, ns->ln_run_time_phase1);
                else if (ns->ln_items_checked != 0)
                        time0++;
 
                if (ns->ln_run_time_phase2 != 0)
                else if (ns->ln_items_checked != 0)
                        time0++;
 
                if (ns->ln_run_time_phase2 != 0)
-                       do_div(speed2, ns->ln_run_time_phase2);
+                       div_u64(speed2, ns->ln_run_time_phase2);
                else if (ns->ln_objs_checked_phase2 != 0)
                        time0++;
 
                if (time0 != 0)
                else if (ns->ln_objs_checked_phase2 != 0)
                        time0++;
 
                if (time0 != 0)
-                       do_div(speed0, time0);
+                       div_u64(speed0, time0);
 
                lfsck_namespace_dump_statistics(m, ns, ns->ln_items_checked,
                                                ns->ln_objs_checked_phase2,
 
                lfsck_namespace_dump_statistics(m, ns, ns->ln_items_checked,
                                                ns->ln_objs_checked_phase2,
@@ -6155,23 +6146,22 @@ checkpoint:
                if (rc < 0 && bk->lb_param & LPF_FAILOUT)
                        GOTO(put, rc);
 
                if (rc < 0 && bk->lb_param & LPF_FAILOUT)
                        GOTO(put, rc);
 
-               if (unlikely(cfs_time_beforeq(com->lc_time_next_checkpoint,
-                                             cfs_time_current())) &&
+               if (unlikely(com->lc_time_next_checkpoint <=
+                            ktime_get_seconds()) &&
                    com->lc_new_checked != 0) {
                        down_write(&com->lc_sem);
                    com->lc_new_checked != 0) {
                        down_write(&com->lc_sem);
-                       ns->ln_run_time_phase2 +=
-                               cfs_duration_sec(cfs_time_current() +
-                               HALF_SEC - com->lc_time_last_checkpoint);
-                       ns->ln_time_last_checkpoint = cfs_time_current_sec();
+                       ns->ln_run_time_phase2 += ktime_get_seconds() -
+                                                 com->lc_time_last_checkpoint;
+                       ns->ln_time_last_checkpoint = ktime_get_real_seconds();
                        ns->ln_objs_checked_phase2 += com->lc_new_checked;
                        com->lc_new_checked = 0;
                        lfsck_namespace_store(env, com);
                        up_write(&com->lc_sem);
 
                        ns->ln_objs_checked_phase2 += com->lc_new_checked;
                        com->lc_new_checked = 0;
                        lfsck_namespace_store(env, com);
                        up_write(&com->lc_sem);
 
-                       com->lc_time_last_checkpoint = cfs_time_current();
+                       com->lc_time_last_checkpoint = ktime_get_seconds();
                        com->lc_time_next_checkpoint =
                                com->lc_time_last_checkpoint +
                        com->lc_time_next_checkpoint =
                                com->lc_time_last_checkpoint +
-                               cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+                               LFSCK_CHECKPOINT_INTERVAL;
                }
 
                lfsck_control_speed_by_self(com);
                }
 
                lfsck_control_speed_by_self(com);
@@ -6222,9 +6212,9 @@ static int lfsck_namespace_assistant_handler_p2(const struct lu_env *env,
 
        com->lc_new_checked = 0;
        com->lc_new_scanned = 0;
 
        com->lc_new_checked = 0;
        com->lc_new_scanned = 0;
-       com->lc_time_last_checkpoint = cfs_time_current();
+       com->lc_time_last_checkpoint = ktime_get_seconds();
        com->lc_time_next_checkpoint = com->lc_time_last_checkpoint +
        com->lc_time_next_checkpoint = com->lc_time_last_checkpoint +
-                               cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+                                      LFSCK_CHECKPOINT_INTERVAL;
 
        i = lfsck_sub_trace_file_fid2idx(&ns->ln_fid_latest_scanned_phase2);
        rc = lfsck_namespace_double_scan_one_trace_file(env, com,
 
        i = lfsck_sub_trace_file_fid2idx(&ns->ln_fid_latest_scanned_phase2);
        rc = lfsck_namespace_double_scan_one_trace_file(env, com,
@@ -6269,9 +6259,9 @@ static int lfsck_namespace_double_scan_result(const struct lu_env *env,
        struct lfsck_namespace  *ns     = com->lc_file_ram;
 
        down_write(&com->lc_sem);
        struct lfsck_namespace  *ns     = com->lc_file_ram;
 
        down_write(&com->lc_sem);
-       ns->ln_run_time_phase2 += cfs_duration_sec(cfs_time_current() +
-                                 HALF_SEC - com->lc_time_last_checkpoint);
-       ns->ln_time_last_checkpoint = cfs_time_current_sec();
+       ns->ln_run_time_phase2 += ktime_get_seconds() -
+                                 com->lc_time_last_checkpoint;
+       ns->ln_time_last_checkpoint = ktime_get_real_seconds();
        ns->ln_objs_checked_phase2 += com->lc_new_checked;
        com->lc_new_checked = 0;
 
        ns->ln_objs_checked_phase2 += com->lc_new_checked;
        com->lc_new_checked = 0;