From fdb5d3d508edb6d76b6fcc1f23d5d9649211ab64 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 12 Apr 2018 10:00:11 -0400 Subject: [PATCH] LU-9019 libcfs: remove the remaining cfs_time wrappers In the lustre code various small bits are left of the libcfs time wrappers. Remove all the remaining wrappers except for the inline function cfs_time_seconds(). For cfs_time_seconds() we have to move to nsec_to_jiffies() since msecs_to_jiffies() has become an inline function in jiffies.h which means HZ can be different on the installation node verses what the target node is configured for. Since nsec_to_jiffies() is a normal built in kernel function we can avoid the LU-5443 issues. For cfs_duration_secs() we use the internal kernel function jiffies_to_msec() since only the newest kernels have jiffies_to_nsec() and that function is just a wrapper around jiffies_to_msec(). All the reset of the libcfs time abstractions are gone. Change-Id: I166973071304f1d55a15b1e21fcfbe434ff58199 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/31068 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin --- contrib/scripts/spelling.txt | 6 +++ libcfs/include/libcfs/Makefile.am | 1 - libcfs/include/libcfs/libcfs.h | 7 +++- libcfs/include/libcfs/libcfs_time.h | 72 -------------------------------- libcfs/include/libcfs/linux/linux-time.h | 51 +--------------------- libcfs/libcfs/debug.c | 3 +- libcfs/libcfs/linux/linux-prim.c | 3 +- libcfs/libcfs/module.c | 1 - libcfs/libcfs/tracefile.c | 43 ++++++++++--------- lnet/include/lnet/lib-lnet.h | 1 - lnet/klnds/gnilnd/gnilnd.h | 5 +++ lnet/klnds/o2iblnd/o2iblnd.h | 2 +- lnet/lnet/router_proc.c | 1 - lustre/include/lprocfs_status.h | 3 +- lustre/include/lustre_dlm.h | 4 +- lustre/include/lustre_lib.h | 24 +++++------ lustre/include/lustre_net.h | 6 +-- lustre/ldlm/ldlm_lib.c | 8 ++-- lustre/ldlm/ldlm_lockd.c | 5 +-- lustre/ldlm/ldlm_pool.c | 18 ++++---- lustre/lod/lod_internal.h | 4 +- lustre/lod/lod_qos.c | 9 ++-- lustre/obdclass/jobid.c | 2 +- lustre/obdclass/linkea.c | 9 ++-- lustre/obdclass/upcall_cache.c | 1 - lustre/ptlrpc/import.c | 2 +- lustre/ptlrpc/service.c | 23 +++++----- 27 files changed, 103 insertions(+), 211 deletions(-) delete mode 100644 libcfs/include/libcfs/libcfs_time.h diff --git a/contrib/scripts/spelling.txt b/contrib/scripts/spelling.txt index 7c46e43..bab5813 100644 --- a/contrib/scripts/spelling.txt +++ b/contrib/scripts/spelling.txt @@ -66,11 +66,17 @@ cfs_list_splice_init||list_splice_init cfs_list_splice_tail||list_splice_tail cfs_list_t||struct list_head struct timeval||struct timespec64 +get_seconds||ktime_get_real_seconds cfs_time_current_sec||ktime_get_real_seconds cfs_time_current_64||ktime_get cfs_time_add_64||ktime_add +cfs_time_after|time_after +cfs_time_aftereq|time_after_eq +cfs_time_before|time_before +cfs_time_beforeeq|time_before_eq cfs_time_before_64||ktime_before cfs_time_beforeq_64||ktime_compare +cfs_time_current|jiffies CFS_PAGE_MASK||PAGE_MASK CFS_PAGE_SIZE||PAGE_SIZE PAGE_CACHE_MASK||PAGE_MASK diff --git a/libcfs/include/libcfs/Makefile.am b/libcfs/include/libcfs/Makefile.am index 7209f43..1819c11 100644 --- a/libcfs/include/libcfs/Makefile.am +++ b/libcfs/include/libcfs/Makefile.am @@ -16,6 +16,5 @@ EXTRA_DIST = \ libcfs_prim.h \ libcfs_private.h \ libcfs_string.h \ - libcfs_time.h \ libcfs_workitem.h \ libcfs_ptask.h diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index 73842eb..9b4395e 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -33,13 +33,18 @@ #ifndef __LIBCFS_LIBCFS_H__ #define __LIBCFS_LIBCFS_H__ +#include +#include + +#include +#include + #include #include #include #include #include #include -#include #include #include #include diff --git a/libcfs/include/libcfs/libcfs_time.h b/libcfs/include/libcfs/libcfs_time.h deleted file mode 100644 index e9ce49f..0000000 --- a/libcfs/include/libcfs/libcfs_time.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/include/libcfs/libcfs_time.h - * - * Time functions. - * - */ - -#ifndef __LIBCFS_TIME_H__ -#define __LIBCFS_TIME_H__ - -#include - -/* - * generic time manipulation functions. - */ - -static inline cfs_time_t cfs_time_add(cfs_time_t t, cfs_duration_t d) -{ - return (cfs_time_t)(t + d); -} - -static inline cfs_duration_t cfs_time_sub(cfs_time_t t1, cfs_time_t t2) -{ - return (cfs_time_t)(t1 - t2); -} - -static inline int cfs_time_after(cfs_time_t t1, cfs_time_t t2) -{ - return cfs_time_before(t2, t1); -} - -static inline int cfs_time_aftereq(cfs_time_t t1, cfs_time_t t2) -{ - return cfs_time_beforeq(t2, t1); -} - -static inline cfs_time_t cfs_time_shift(int seconds) -{ - return cfs_time_add(cfs_time_current(), cfs_time_seconds(seconds)); -} - -#define CFS_TICK 1 - -#endif diff --git a/libcfs/include/libcfs/linux/linux-time.h b/libcfs/include/libcfs/linux/linux-time.h index 67fb5c7..eeced6b 100644 --- a/libcfs/include/libcfs/linux/linux-time.h +++ b/libcfs/include/libcfs/linux/linux-time.h @@ -40,24 +40,6 @@ #define __LIBCFS_LINUX_LINUX_TIME_H__ /* Portable time API */ - -/* - * Platform provides three opaque data-types: - * - * cfs_time_t represents point in time. This is internal kernel - * time rather than "wall clock". This time bears no - * relation to gettimeofday(). - * - * cfs_duration_t represents time interval with resolution of internal - * platform clock - * - * cfs_time_t cfs_time_current(void); - * cfs_time_t cfs_time_add (cfs_time_t, cfs_duration_t); - * cfs_duration_t cfs_time_sub (cfs_time_t, cfs_time_t); - * - * time_t cfs_duration_sec (cfs_duration_t); - */ - #include #include #include @@ -71,10 +53,6 @@ /* * Generic kernel stuff */ - -typedef unsigned long cfs_time_t; /* jiffies */ -typedef long cfs_duration_t; - #ifndef HAVE_TIMESPEC64 typedef __s64 time64_t; @@ -214,34 +192,9 @@ static inline ktime_t timespec64_to_ktime(struct timespec64 ts) } #endif -static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2) -{ - return time_before(t1, t2); -} - -static inline int cfs_time_beforeq(cfs_time_t t1, cfs_time_t t2) -{ - return time_before_eq(t1, t2); -} - -static inline cfs_time_t cfs_time_current(void) -{ - return jiffies; -} - -static inline time_t cfs_time_current_sec(void) -{ - return get_seconds(); -} - -static inline cfs_duration_t cfs_time_seconds(int seconds) -{ - return ((cfs_duration_t)seconds) * msecs_to_jiffies(MSEC_PER_SEC); -} - -static inline time_t cfs_duration_sec(cfs_duration_t d) +static inline unsigned long cfs_time_seconds(time64_t seconds) { - return d / msecs_to_jiffies(MSEC_PER_SEC); + return nsecs_to_jiffies(seconds * NSEC_PER_SEC); } #endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */ diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index a329689..98c30b7 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -39,7 +39,6 @@ #include #include -#include #include #include "tracefile.h" @@ -148,7 +147,7 @@ static int param_get_delay(char *buffer, cfs_kernel_param_arg_t *kp) { unsigned int d = *(unsigned int *)kp->arg; - return sprintf(buffer, "%u", (unsigned int)cfs_duration_sec(d * 100)); + return sprintf(buffer, "%lu", jiffies_to_msecs(d * 10) / MSEC_PER_SEC); } unsigned int libcfs_console_max_delay; diff --git a/libcfs/libcfs/linux/linux-prim.c b/libcfs/libcfs/linux/linux-prim.c index d9fd96b..4f07340 100644 --- a/libcfs/libcfs/linux/linux-prim.c +++ b/libcfs/libcfs/linux/linux-prim.c @@ -41,12 +41,13 @@ #include #endif #include -#include #if defined(CONFIG_KGDB) #include #endif +#include + #ifndef HAVE_KTIME_GET_TS64 void ktime_get_ts64(struct timespec64 *ts) { diff --git a/libcfs/libcfs/module.c b/libcfs/libcfs/module.c index 9fbf40c..e6e6d0c 100644 --- a/libcfs/libcfs/module.c +++ b/libcfs/libcfs/module.c @@ -53,7 +53,6 @@ #include #include -#include #include #include "tracefile.h" diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index 5074ab1..6e6a28f 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -46,7 +46,6 @@ #include #include #include -#include #include /* XXX move things up to the top, comment */ @@ -395,34 +394,34 @@ console: return 1; } - if (cdls != NULL) { - if (libcfs_console_ratelimit && - cdls->cdls_next != 0 && /* not first time ever */ - !cfs_time_after(cfs_time_current(), cdls->cdls_next)) { - /* skipping a console message */ - cdls->cdls_count++; - if (tcd != NULL) - cfs_trace_put_tcd(tcd); - return 1; - } + if (cdls != NULL) { + if (libcfs_console_ratelimit && + cdls->cdls_next != 0 && /* not first time ever */ + time_after(jiffies, cdls->cdls_next)) { + /* skipping a console message */ + cdls->cdls_count++; + if (tcd != NULL) + cfs_trace_put_tcd(tcd); + return 1; + } - if (cfs_time_after(cfs_time_current(), cdls->cdls_next + - libcfs_console_max_delay - + cfs_time_seconds(10))) { - /* last timeout was a long time ago */ - cdls->cdls_delay /= libcfs_console_backoff * 4; - } else { - cdls->cdls_delay *= libcfs_console_backoff; - } + if (time_after(jiffies, cdls->cdls_next + + libcfs_console_max_delay + + cfs_time_seconds(10))) { + /* last timeout was a long time ago */ + cdls->cdls_delay /= libcfs_console_backoff * 4; + } else { + cdls->cdls_delay *= libcfs_console_backoff; + } if (cdls->cdls_delay < libcfs_console_min_delay) cdls->cdls_delay = libcfs_console_min_delay; else if (cdls->cdls_delay > libcfs_console_max_delay) cdls->cdls_delay = libcfs_console_max_delay; - /* ensure cdls_next is never zero after it's been seen */ - cdls->cdls_next = (cfs_time_current() + cdls->cdls_delay) | 1; - } + /* ensure cdls_next is never zero after it's been seen */ + cdls->cdls_next = (jiffies + cdls->cdls_delay) | 1; + } if (tcd != NULL) { cfs_print_to_console(&header, mask, string_buf, needed, file, diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 985d9a9..6197be6 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -41,7 +41,6 @@ # error This include is only for kernel use. #endif -#include #include #include #include diff --git a/lnet/klnds/gnilnd/gnilnd.h b/lnet/klnds/gnilnd/gnilnd.h index 4a05d98..b511c9f 100644 --- a/lnet/klnds/gnilnd/gnilnd.h +++ b/lnet/klnds/gnilnd/gnilnd.h @@ -66,6 +66,11 @@ #include #include "gnilnd_version.h" +static inline time_t cfs_duration_sec(long duration_jiffies) +{ + return jiffies_to_msecs(duration_jiffies) / MSEC_PER_SEC; +} + #ifdef CONFIG_SLAB #define GNILND_MBOX_SIZE KMALLOC_MAX_SIZE #else diff --git a/lnet/klnds/o2iblnd/o2iblnd.h b/lnet/klnds/o2iblnd/o2iblnd.h index 8ac9c45..7c0d7f6 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.h +++ b/lnet/klnds/o2iblnd/o2iblnd.h @@ -79,7 +79,7 @@ #define DEBUG_SUBSYSTEM S_LND -#include +#include #include #define IBLND_PEER_HASH_SIZE 101 /* # peer_ni lists */ diff --git a/lnet/lnet/router_proc.c b/lnet/lnet/router_proc.c index 329e43f..ea2aa6c 100644 --- a/lnet/lnet/router_proc.c +++ b/lnet/lnet/router_proc.c @@ -24,7 +24,6 @@ #include -#include #include #include diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 6c9b1f0..de1f0c6 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -45,8 +45,7 @@ #include #include -#include -#include +#include #include struct lprocfs_vars { diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 10438ce..c400795 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -1666,7 +1666,7 @@ void unlock_res_and_lock(struct ldlm_lock *lock); * There are not used outside of ldlm. * @{ */ -int ldlm_pools_recalc(enum ldlm_side client); +time64_t ldlm_pools_recalc(enum ldlm_side client); int ldlm_pools_init(void); void ldlm_pools_fini(void); @@ -1675,7 +1675,7 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, gfp_t gfp_mask); void ldlm_pool_fini(struct ldlm_pool *pl); int ldlm_pool_setup(struct ldlm_pool *pl, int limit); -int ldlm_pool_recalc(struct ldlm_pool *pl); +time64_t ldlm_pool_recalc(struct ldlm_pool *pl); __u32 ldlm_pool_get_lvf(struct ldlm_pool *pl); __u64 ldlm_pool_get_slv(struct ldlm_pool *pl); __u64 ldlm_pool_get_clv(struct ldlm_pool *pl); diff --git a/lustre/include/lustre_lib.h b/lustre/include/lustre_lib.h index 5acfd89..4ab0db6 100644 --- a/lustre/include/lustre_lib.h +++ b/lustre/include/lustre_lib.h @@ -47,7 +47,6 @@ #include #endif -#include #include #include #include @@ -166,9 +165,9 @@ static inline int back_to_sleep(void *arg) #define LWI_ON_SIGNAL_NOOP ((void (*)(void *))(-1)) struct l_wait_info { - cfs_duration_t lwi_timeout; - cfs_duration_t lwi_interval; - int lwi_allow_intr; + long lwi_timeout; + long lwi_interval; + int lwi_allow_intr; int (*lwi_on_timeout)(void *); void (*lwi_on_signal)(void *); void *lwi_cb_data; @@ -260,8 +259,8 @@ static inline void __add_wait_queue_exclusive(wait_queue_head_t *q, #define __l_wait_event(wq, condition, info, ret, l_add_wait) \ do { \ wait_queue_entry_t __wait; \ - cfs_duration_t __timeout = info->lwi_timeout; \ - sigset_t __blocked; \ + long __timeout = info->lwi_timeout; \ + sigset_t __blocked; \ int __allow_intr = info->lwi_allow_intr; \ \ ret = 0; \ @@ -310,13 +309,12 @@ do { \ if (__timeout == 0) { \ schedule(); \ } else { \ - cfs_duration_t interval = info->lwi_interval? \ - min_t(cfs_duration_t, \ - info->lwi_interval,__timeout):\ - __timeout; \ - cfs_duration_t remaining = schedule_timeout(interval); \ - __timeout = cfs_time_sub(__timeout, \ - cfs_time_sub(interval, remaining));\ + long interval = info->lwi_interval ? \ + min_t(long, info->lwi_interval,\ + __timeout) : __timeout; \ + long remaining = schedule_timeout(interval); \ + \ + __timeout -= interval - remaining; \ if (__timeout == 0) { \ if (info->lwi_on_timeout == NULL || \ info->lwi_on_timeout(info->lwi_cb_data)) { \ diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 335cfe0..9e655e6 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -1787,8 +1787,8 @@ struct ptlrpc_service_part { struct list_head scp_rqbd_posted; /** incoming reqs */ struct list_head scp_req_incoming; - /** timeout before re-posting reqs, in tick */ - cfs_duration_t scp_rqbd_timeout; + /** timeout before re-posting reqs, in jiffies */ + long scp_rqbd_timeout; /** * all threads sleep on this. This wait-queue is signalled when new * incoming request arrives and when difficult reply has to be handled. @@ -1839,7 +1839,7 @@ struct ptlrpc_service_part { /** early reply timer */ struct timer_list scp_at_timer; /** debug */ - cfs_time_t scp_at_checktime; + ktime_t scp_at_checktime; /** check early replies */ unsigned scp_at_check; /** @} */ diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 5c122fb..45bbad4 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -39,6 +39,7 @@ #define DEBUG_SUBSYSTEM S_LDLM +#include #include #include #include @@ -787,7 +788,8 @@ static int target_handle_reconnect(struct lustre_handle *conn, } now = ktime_get_seconds(); - deadline = cfs_duration_sec(target->obd_recovery_timer.expires); + deadline = jiffies_to_msecs(target->obd_recovery_timer.expires) / + MSEC_PER_SEC; if (now < deadline) { struct target_distribute_txn_data *tdtd; int size = 0; @@ -1254,8 +1256,8 @@ no_export: i = atomic_read(&target->obd_lock_replay_clients); k = target->obd_max_recoverable_clients; s = target->obd_stale_clients; - t = target->obd_recovery_timer.expires; - t = cfs_duration_sec(target->obd_recovery_timer.expires); + t = jiffies_to_msecs(target->obd_recovery_timer.expires); + t /= MSEC_PER_SEC; t -= ktime_get_seconds(); LCONSOLE_WARN("%s: Denying connection for new client %s" "(at %s), waiting for %d known clients " diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 81ed655..122c284 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -245,9 +245,8 @@ static int expired_lock_main(void *arg) spin_unlock_bh(&export->exp_bl_list_lock); LDLM_ERROR(lock, - "lock callback timer expired after " - "%llds: evicting client at %s ", - cfs_time_current_sec() - + "lock callback timer expired after %llds: evicting client at %s ", + ktime_get_real_seconds() - lock->l_last_activity, obd_export_nid2str(export)); ldlm_lock_to_ns(lock)->ns_timeouts++; diff --git a/lustre/ldlm/ldlm_pool.c b/lustre/ldlm/ldlm_pool.c index dd1856b..7e49fba 100644 --- a/lustre/ldlm/ldlm_pool.c +++ b/lustre/ldlm/ldlm_pool.c @@ -575,7 +575,7 @@ static struct ldlm_pool_ops ldlm_cli_pool_ops = { * Pool recalc wrapper. Will call either client or server pool recalc callback * depending what pool \a pl is used. */ -int ldlm_pool_recalc(struct ldlm_pool *pl) +time64_t ldlm_pool_recalc(struct ldlm_pool *pl) { time64_t recalc_interval_sec; int count; @@ -1244,15 +1244,15 @@ static int ldlm_pools_cli_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask)) #endif /* HAVE_SHRINKER_COUNT */ -int ldlm_pools_recalc(enum ldlm_side client) +time64_t ldlm_pools_recalc(enum ldlm_side client) { unsigned long nr_l = 0, nr_p = 0, l; struct ldlm_namespace *ns; struct ldlm_namespace *ns_old = NULL; int nr, equal = 0; /* seconds of sleep if no active namespaces */ - int time = client ? LDLM_POOL_CLI_DEF_RECALC_PERIOD : - LDLM_POOL_SRV_DEF_RECALC_PERIOD; + time64_t time = client ? LDLM_POOL_CLI_DEF_RECALC_PERIOD : + LDLM_POOL_SRV_DEF_RECALC_PERIOD; /* * No need to setup pool limit for client pools. @@ -1388,7 +1388,7 @@ int ldlm_pools_recalc(enum ldlm_side client) * After setup is done - recalc the pool. */ if (!skip) { - int ttime = ldlm_pool_recalc(&ns->ns_pool); + time64_t ttime = ldlm_pool_recalc(&ns->ns_pool); if (ttime < time) time = ttime; @@ -1406,9 +1406,9 @@ int ldlm_pools_recalc(enum ldlm_side client) static int ldlm_pools_thread_main(void *arg) { struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; - int s_time, c_time; - ENTRY; + time64_t s_time, c_time; + ENTRY; thread_set_flags(thread, SVC_RUNNING); wake_up(&thread->t_ctl_waitq); @@ -1540,7 +1540,7 @@ int ldlm_pool_setup(struct ldlm_pool *pl, int limit) return 0; } -int ldlm_pool_recalc(struct ldlm_pool *pl) +time64_t ldlm_pool_recalc(struct ldlm_pool *pl) { return 0; } @@ -1617,7 +1617,7 @@ void ldlm_pools_fini(void) return; } -int ldlm_pools_recalc(enum ldlm_side client) +time64_t ldlm_pools_recalc(enum ldlm_side client) { return 0; } diff --git a/lustre/lod/lod_internal.h b/lustre/lod/lod_internal.h index f6bee8a..c2b9346 100644 --- a/lustre/lod/lod_internal.h +++ b/lustre/lod/lod_internal.h @@ -100,7 +100,7 @@ struct lod_qos_oss { __u64 lqo_penalty; /* current penalty */ __u64 lqo_penalty_per_obj; /* penalty decrease every obj*/ - time_t lqo_used; /* last used time, seconds */ + time64_t lqo_used; /* last used time, seconds */ __u32 lqo_ost_count; /* number of osts on this oss */ }; @@ -110,7 +110,7 @@ struct ltd_qos { __u64 ltq_penalty_per_obj; /* penalty decrease every obj*/ __u64 ltq_weight; /* net weighting */ - time_t ltq_used; /* last used time, seconds */ + time64_t ltq_used; /* last used time, seconds */ bool ltq_usable:1; /* usable for striping */ }; diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index 98f8daf..e00b172 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -320,7 +320,7 @@ static int lod_qos_calc_ppo(struct lod_device *lod) __u32 num_active; unsigned int i; int rc, prio_wide; - time_t now, age; + time64_t now, age; ENTRY; if (!lod->lod_qos.lq_dirty) @@ -344,9 +344,10 @@ static int lod_qos_calc_ppo(struct lod_device *lod) ba_min = (__u64)(-1); ba_max = 0; - now = cfs_time_current_sec(); + now = ktime_get_real_seconds(); /* Calculate OST penalty per object - * (lod ref taken in lod_qos_prep_create()) */ + * (lod ref taken in lod_qos_prep_create()) + */ cfs_foreach_bit(lod->lod_ost_bitmap, i) { LASSERT(OST_TGT(lod,i)); temp = TGT_BAVAIL(i); @@ -482,7 +483,7 @@ static int lod_qos_used(struct lod_device *lod, struct ost_pool *osts, oss->lqo_penalty >>= 1; /* mark the OSS and OST as recently used */ - ost->ltd_qos.ltq_used = oss->lqo_used = cfs_time_current_sec(); + ost->ltd_qos.ltq_used = oss->lqo_used = ktime_get_real_seconds(); /* Set max penalties for this OST and OSS */ ost->ltd_qos.ltq_penalty += diff --git a/lustre/obdclass/jobid.c b/lustre/obdclass/jobid.c index 842def4..75fd29b 100644 --- a/lustre/obdclass/jobid.c +++ b/lustre/obdclass/jobid.c @@ -38,7 +38,7 @@ #endif #include -#include +#include #include #include #include diff --git a/lustre/obdclass/linkea.c b/lustre/obdclass/linkea.c index a501021..cf17a50 100644 --- a/lustre/obdclass/linkea.c +++ b/lustre/obdclass/linkea.c @@ -143,10 +143,11 @@ int linkea_add_buf(struct linkea_data *ldata, const struct lu_name *lname, reclen = lname->ln_namelen + sizeof(struct link_ea_entry); if (unlikely(leh->leh_len + reclen > MAX_LINKEA_SIZE)) { /* Use 32-bits to save the overflow time, although it will - * shrink the cfs_time_current_sec() returned 64-bits value + * shrink the ktime_get_real_seconds() returned 64-bits value * to 32-bits value, it is still quite large and can be used - * for about 140 years. That is enough. */ - leh->leh_overflow_time = cfs_time_current_sec(); + * for about 140 years. That is enough. + */ + leh->leh_overflow_time = ktime_get_real_seconds(); if (unlikely(leh->leh_overflow_time == 0)) leh->leh_overflow_time++; @@ -235,7 +236,7 @@ int linkea_overflow_shrink(struct linkea_data *ldata) if (unlikely(leh->leh_reccount == 0)) return 0; - leh->leh_overflow_time = cfs_time_current_sec(); + leh->leh_overflow_time = ktime_get_real_seconds(); if (unlikely(leh->leh_overflow_time == 0)) leh->leh_overflow_time++; ldata->ld_reclen = 0; diff --git a/lustre/obdclass/upcall_cache.c b/lustre/obdclass/upcall_cache.c index 6023346..5622410 100644 --- a/lustre/obdclass/upcall_cache.c +++ b/lustre/obdclass/upcall_cache.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_SEC -#include #include #include #include diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 2e7ac0e..3ecc4dc 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -256,7 +256,7 @@ static time64_t ptlrpc_inflight_deadline(struct ptlrpc_request *req, return dl - now; } -static unsigned int ptlrpc_inflight_timeout(struct obd_import *imp) +static time64_t ptlrpc_inflight_timeout(struct obd_import *imp) { time64_t now = ktime_get_real_seconds(); struct list_head *tmp, *n; diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 89154e0..ab7aea1 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -482,7 +482,7 @@ static void ptlrpc_at_timer(unsigned long castmeharder) svcpt = (struct ptlrpc_service_part *)castmeharder; svcpt->scp_at_check = 1; - svcpt->scp_at_checktime = cfs_time_current(); + svcpt->scp_at_checktime = ktime_get(); wake_up(&svcpt->scp_waitq); } @@ -1183,7 +1183,7 @@ static int ptlrpc_check_req(struct ptlrpc_request *req) static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt) { struct ptlrpc_at_array *array = &svcpt->scp_at_array; - __s32 next; + time64_t next; if (array->paa_count == 0) { del_timer(&svcpt->scp_at_timer); @@ -1191,13 +1191,14 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt) } /* Set timer for closest deadline */ - next = (__s32)(array->paa_deadline - ktime_get_real_seconds() - - at_early_margin); + next = array->paa_deadline - ktime_get_real_seconds() - + at_early_margin; if (next <= 0) { ptlrpc_at_timer((unsigned long)svcpt); } else { - mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next)); - CDEBUG(D_INFO, "armed %s at %+ds\n", + mod_timer(&svcpt->scp_at_timer, + jiffies + nsecs_to_jiffies(next * NSEC_PER_SEC)); + CDEBUG(D_INFO, "armed %s at %+llds\n", svcpt->scp_service->srv_name, next); } } @@ -1449,16 +1450,16 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) __u32 index, count; time64_t deadline; time64_t now = ktime_get_real_seconds(); - cfs_duration_t delay; - int first, counter = 0; - ENTRY; + s64 delay; + int first, counter = 0; + ENTRY; spin_lock(&svcpt->scp_at_lock); if (svcpt->scp_at_check == 0) { spin_unlock(&svcpt->scp_at_lock); RETURN(0); } - delay = cfs_time_sub(cfs_time_current(), svcpt->scp_at_checktime); + delay = ktime_ms_delta(ktime_get(), svcpt->scp_at_checktime); svcpt->scp_at_check = 0; if (array->paa_count == 0) { @@ -1522,7 +1523,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) LCONSOLE_WARN("%s: This server is not able to keep up with " "request traffic (cpu-bound).\n", svcpt->scp_service->srv_name); - CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=%ld(jiff)\n", + CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=%lld\n", counter, svcpt->scp_nreqs_incoming, svcpt->scp_nreqs_active, at_get(&svcpt->scp_at_estimate), delay); -- 1.8.3.1