X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Flprocfs_jobstats.c;h=dc1f6b2a02b84e8719edc990ef0f74e346d4e240;hb=5e36bc4fe3b9411f114e33ec71c47d2bccd5505a;hp=cc86ca2d7a2e2ae71efe53c1dfa6ef6b98612b9e;hpb=fb60c82405ba7f84dd9dd5411e9bdae3ecb8cf4a;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/lprocfs_jobstats.c b/lustre/obdclass/lprocfs_jobstats.c index cc86ca2..dc1f6b2a 100644 --- a/lustre/obdclass/lprocfs_jobstats.c +++ b/lustre/obdclass/lprocfs_jobstats.c @@ -14,12 +14,12 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ /* - * Copyright (c) 2012, 2014, Intel Corporation. + * Copyright (c) 2012, 2016, Intel Corporation. * Use is subject to license terms. * * Author: Niu Yawei @@ -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 */ - 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 */ }; @@ -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) { - 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); @@ -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) { - 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; @@ -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; - stats->ojs_last_cleanup = cfs_time_current_sec(); + stats->ojs_last_cleanup = ktime_get_real_seconds(); 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); - 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); @@ -315,7 +315,7 @@ int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, 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); @@ -444,14 +444,14 @@ static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v) } 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++) { cntr_header = &s->ls_cnt_header[i]; lprocfs_stats_collect(s, i, &ret); - seq_printf(p, " %s:%.*s { samples: %11"LPF64"u", + seq_printf(p, " %s:%.*s { samples: %11llu", cntr_header->lc_name, width(cntr_header->lc_name, 15), spaces, ret.lc_count); @@ -459,14 +459,14 @@ static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v) seq_printf(p, ", unit: %5s", cntr_header->lc_units); if (cntr_header->lc_config & LPROCFS_CNTR_AVGMINMAX) { - seq_printf(p, ", min:%8"LPF64"u, max:%8"LPF64"u," - " sum:%16"LPF64"u", + seq_printf(p, ", min:%8llu, max:%8llu," + " sum:%16llu", ret.lc_count ? ret.lc_min : 0, ret.lc_count ? ret.lc_max : 0, ret.lc_count ? ret.lc_sum : 0); } if (cntr_header->lc_config & LPROCFS_CNTR_STDDEV) { - seq_printf(p, ", sumsq: %18"LPF64"u", + seq_printf(p, ", sumsq: %18llu", ret.lc_count ? ret.lc_sumsquare : 0); } @@ -477,10 +477,10 @@ static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v) } static const struct seq_operations lprocfs_jobstats_seq_sops = { - start: lprocfs_jobstats_seq_start, - stop: lprocfs_jobstats_seq_stop, - next: lprocfs_jobstats_seq_next, - show: lprocfs_jobstats_seq_show, + .start = lprocfs_jobstats_seq_start, + .stop = lprocfs_jobstats_seq_stop, + .next = lprocfs_jobstats_seq_next, + .show = lprocfs_jobstats_seq_show, }; static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file) @@ -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_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); @@ -636,17 +636,19 @@ int lprocfs_job_interval_seq_show(struct seq_file *m, void *data) return -ENODEV; stats = &obd->u.obt.obt_jobstats; - return seq_printf(m, "%d\n", stats->ojs_cleanup_interval); + seq_printf(m, "%d\n", stats->ojs_cleanup_interval); + return 0; } EXPORT_SYMBOL(lprocfs_job_interval_seq_show); ssize_t -lprocfs_job_interval_seq_write(struct file *file, const char *buffer, +lprocfs_job_interval_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off) { struct obd_device *obd; struct obd_job_stats *stats; - int val, rc; + int rc; + __s64 val; obd = ((struct seq_file *)file->private_data)->private; if (obd == NULL) @@ -654,9 +656,11 @@ lprocfs_job_interval_seq_write(struct file *file, const char *buffer, stats = &obd->u.obt.obt_jobstats; - rc = lprocfs_write_helper(buffer, count, &val); + rc = lprocfs_str_to_s64(buffer, count, &val); if (rc) return rc; + if (val < 0 || val > UINT_MAX) + return -ERANGE; stats->ojs_cleanup_interval = val; lprocfs_job_cleanup(stats, stats->ojs_cleanup_interval);