Whamcloud - gitweb
LU-9019 obdclass: migrate jobstats to 64 bit time 11/27911/3
authorJames Simmons <uja.ornl@yahoo.com>
Sat, 8 Jul 2017 21:23:13 +0000 (17:23 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 29 Jul 2017 00:02:32 +0000 (00:02 +0000)
Change all time_t fields for jobstats to time64_t.
Replace cfs_time_current_sec() to avoid the overflow
issues in 2038 with ktime_get_real_seconds().

Change-Id: Icf3af60b9b373acbf5d921add9b4c4d33c77aa61
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/27911
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lprocfs_status.h
lustre/obdclass/lprocfs_jobstats.c

index 8f78a84..c40604b 100644 (file)
@@ -375,7 +375,7 @@ struct obd_job_stats {
        struct list_head        ojs_list;       /* list of job_stat structs */
        rwlock_t                ojs_lock;       /* protect ojs_list/js_list */
        unsigned int            ojs_cleanup_interval;/* seconds before expiry */
        struct list_head        ojs_list;       /* list of job_stat structs */
        rwlock_t                ojs_lock;       /* protect ojs_list/js_list */
        unsigned int            ojs_cleanup_interval;/* seconds before expiry */
-       time_t                  ojs_last_cleanup; /* previous cleanup time */
+       time64_t                ojs_last_cleanup; /* previous cleanup time */
        cntr_init_callback      ojs_cntr_init_fn;/* lprocfs_stats initializer */
        unsigned short          ojs_cntr_num;   /* number of stats in struct */
        bool                    ojs_cleaning;   /* currently expiring stats */
        cntr_init_callback      ojs_cntr_init_fn;/* lprocfs_stats initializer */
        unsigned short          ojs_cntr_num;   /* number of stats in struct */
        bool                    ojs_cleaning;   /* currently expiring stats */
index a341794..dc1f6b2 100644 (file)
@@ -68,7 +68,7 @@ struct job_stat {
        struct list_head        js_list;        /* on ojs_list, with ojs_lock */
        atomic_t                js_refcount;    /* num users of this struct */
        char                    js_jobid[LUSTRE_JOBID_SIZE]; /* job name */
        struct list_head        js_list;        /* on ojs_list, with ojs_lock */
        atomic_t                js_refcount;    /* num users of this struct */
        char                    js_jobid[LUSTRE_JOBID_SIZE]; /* job name */
-       time_t                  js_timestamp;   /* seconds of most recent stat*/
+       time64_t                js_timestamp;   /* seconds of most recent stat*/
        struct lprocfs_stats    *js_stats;      /* per-job statistics */
        struct obd_job_stats    *js_jobstats;   /* for accessing ojs_lock */
 };
        struct lprocfs_stats    *js_stats;      /* per-job statistics */
        struct obd_job_stats    *js_jobstats;   /* for accessing ojs_lock */
 };
@@ -164,7 +164,7 @@ static int job_cleanup_iter_callback(struct cfs_hash *hs,
                                     struct cfs_hash_bd *bd,
                                     struct hlist_node *hnode, void *data)
 {
                                     struct cfs_hash_bd *bd,
                                     struct hlist_node *hnode, void *data)
 {
-       time_t oldest_time = *((time_t *)data);
+       time64_t oldest_time = *((time64_t *)data);
        struct job_stat *job;
 
        job = hlist_entry(hnode, struct job_stat, js_hash);
        struct job_stat *job;
 
        job = hlist_entry(hnode, struct job_stat, js_hash);
@@ -193,8 +193,8 @@ static int job_cleanup_iter_callback(struct cfs_hash *hs,
  */
 static void lprocfs_job_cleanup(struct obd_job_stats *stats, int before)
 {
  */
 static void lprocfs_job_cleanup(struct obd_job_stats *stats, int before)
 {
-       time_t now = cfs_time_current_sec();
-       time_t oldest;
+       time64_t now = ktime_get_real_seconds();
+       time64_t oldest;
 
        if (likely(before >= 0)) {
                unsigned int cleanup_interval = stats->ojs_cleanup_interval;
 
        if (likely(before >= 0)) {
                unsigned int cleanup_interval = stats->ojs_cleanup_interval;
@@ -234,7 +234,7 @@ static void lprocfs_job_cleanup(struct obd_job_stats *stats, int before)
 
        write_lock(&stats->ojs_lock);
        stats->ojs_cleaning = false;
 
        write_lock(&stats->ojs_lock);
        stats->ojs_cleaning = false;
-       stats->ojs_last_cleanup = cfs_time_current_sec();
+       stats->ojs_last_cleanup = ktime_get_real_seconds();
        write_unlock(&stats->ojs_lock);
 }
 
        write_unlock(&stats->ojs_lock);
 }
 
@@ -255,7 +255,7 @@ static struct job_stat *job_alloc(char *jobid, struct obd_job_stats *jobs)
        jobs->ojs_cntr_init_fn(job->js_stats);
 
        memcpy(job->js_jobid, jobid, LUSTRE_JOBID_SIZE);
        jobs->ojs_cntr_init_fn(job->js_stats);
 
        memcpy(job->js_jobid, jobid, LUSTRE_JOBID_SIZE);
-       job->js_timestamp = cfs_time_current_sec();
+       job->js_timestamp = ktime_get_real_seconds();
        job->js_jobstats = jobs;
        INIT_HLIST_NODE(&job->js_hash);
        INIT_LIST_HEAD(&job->js_list);
        job->js_jobstats = jobs;
        INIT_HLIST_NODE(&job->js_hash);
        INIT_LIST_HEAD(&job->js_list);
@@ -315,7 +315,7 @@ int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
 
 found:
        LASSERT(stats == job->js_jobstats);
 
 found:
        LASSERT(stats == job->js_jobstats);
-       job->js_timestamp = cfs_time_current_sec();
+       job->js_timestamp = ktime_get_real_seconds();
        lprocfs_counter_add(job->js_stats, event, amount);
 
        job_putref(job);
        lprocfs_counter_add(job->js_stats, event, amount);
 
        job_putref(job);
@@ -444,7 +444,7 @@ static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v)
        }
        seq_putc(p, '\n');
 
        }
        seq_putc(p, '\n');
 
-       seq_printf(p, "  %-16s %ld\n", "snapshot_time:", job->js_timestamp);
+       seq_printf(p, "  %-16s %lld\n", "snapshot_time:", job->js_timestamp);
 
        s = job->js_stats;
        for (i = 0; i < s->ls_num; i++) {
 
        s = job->js_stats;
        for (i = 0; i < s->ls_num; i++) {
@@ -615,7 +615,7 @@ int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
        stats->ojs_cntr_num = cntr_num;
        stats->ojs_cntr_init_fn = init_fn;
        stats->ojs_cleanup_interval = 600; /* 10 mins by default */
        stats->ojs_cntr_num = cntr_num;
        stats->ojs_cntr_init_fn = init_fn;
        stats->ojs_cleanup_interval = 600; /* 10 mins by default */
-       stats->ojs_last_cleanup = cfs_time_current_sec();
+       stats->ojs_last_cleanup = ktime_get_real_seconds();
 
        entry = lprocfs_add_simple(obd->obd_proc_entry, "job_stats", stats,
                                   &lprocfs_jobstats_seq_fops);
 
        entry = lprocfs_add_simple(obd->obd_proc_entry, "job_stats", stats,
                                   &lprocfs_jobstats_seq_fops);