From 07ff616a18cc602460724e6693e142782cad0fcc Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 24 Oct 2016 21:43:12 -0400 Subject: [PATCH] LU-6245 libcfs: add ktime_get_real_seconds support In newer kernels time support is moving to u64 to avoid the 2038 limitation. The function get_seconds() which only returns a 32 bit value is being replaced by a new function ktime_get_real_seconds(). This patch adds a wrapper for older platforms that lack this function. Only the libcfs/LNet layer has been ported in this patch since it is a huge change. Signed-off-by: James Simmons Change-Id: Ic16859f1b052bfb72299cc85fe50364a9e70d660 Reviewed-on: https://review.whamcloud.com/22866 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Frank Zago Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- libcfs/autoconf/lustre-libcfs.m4 | 58 ++++++++++++++++++++++++++++++++ libcfs/include/libcfs/linux/linux-time.h | 12 +++++++ libcfs/libcfs/debug.c | 11 +++--- libcfs/libcfs/linux/linux-prim.c | 48 +++++++++++++++++++++++++- lnet/include/lnet/lib-types.h | 2 +- lnet/klnds/o2iblnd/o2iblnd.h | 2 +- lnet/klnds/o2iblnd/o2iblnd_cb.c | 5 +-- lnet/klnds/socklnd/socklnd.c | 22 ++++++------ lnet/klnds/socklnd/socklnd.h | 4 +-- lnet/klnds/socklnd/socklnd_cb.c | 8 ++--- lnet/lnet/api-ni.c | 12 ++++--- lnet/lnet/config.c | 2 +- lnet/lnet/lib-move.c | 4 +-- lnet/lnet/router.c | 4 +-- lnet/lnet/router_proc.c | 2 +- lnet/selftest/conctl.c | 2 +- lnet/selftest/conrpc.c | 18 +++++----- lnet/selftest/console.c | 2 +- lnet/selftest/console.h | 2 +- lnet/selftest/framework.c | 2 +- lnet/selftest/rpc.c | 10 +++--- lnet/selftest/selftest.h | 2 +- lnet/selftest/timer.c | 14 ++++---- lnet/selftest/timer.h | 4 +-- 24 files changed, 186 insertions(+), 66 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index daa8626..95b25c0 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -262,6 +262,25 @@ AS_IF([test "x$enable_crc32c_crypto" = xyes], [ ]) # LIBCFS_ENABLE_CRC32C_ACCEL # +# Kernel version 3.11 introduced ktime_get_ts64 +# +AC_DEFUN([LIBCFS_KTIME_GET_TS64],[ +LB_CHECK_COMPILE([does function 'ktime_get_ts64' exist], +ktime_get_ts64, [ + #include +],[ + struct timespec64 *ts = NULL; + + ktime_get_ts64(ts); +],[ + AC_DEFINE(HAVE_KTIME_GET_TS64, 1, + ['ktime_get_ts64' is available]) +]) +]) # LIBCFS_KTIME_GET_TS64 + +# + +# # FC19 3.12 kernel struct shrinker change # AC_DEFUN([LIBCFS_SHRINKER_COUNT],[ @@ -329,6 +348,40 @@ ktime_get_real_ts64, [ ]) # LIBCFS_KTIME_GET_REAL_TS64 # +# Kernel version 3.17 introduced ktime_get_real_seconds +# +AC_DEFUN([LIBCFS_KTIME_GET_REAL_SECONDS],[ +LB_CHECK_COMPILE([does function 'ktime_get_real_seconds' exist], +ktime_get_real_seconds, [ + #include +],[ + time64_t now; + + now = ktime_get_real_seconds(); +],[ + AC_DEFINE(HAVE_KTIME_GET_REAL_SECONDS, 1, + ['ktime_get_real_seconds' is available]) +]) +]) # LIBCFS_KTIME_GET_REAL_SECONDS + +# +# Kernel version 3.19 introduced ktime_get_seconds +# +AC_DEFUN([LIBCFS_KTIME_GET_SECONDS],[ +LB_CHECK_COMPILE([does function 'ktime_get_seconds' exist], +ktime_get_seconds, [ + #include +],[ + time64_t now; + + now = ktime_get_seconds(); +],[ + AC_DEFINE(HAVE_KTIME_GET_SECONDS, 1, + ['ktime_get_seconds' is available]) +]) +]) # LIBCFS_KTIME_GET_SECONDS + +# # Kernel version 4.2 changed topology_thread_cpumask # to topology_sibling_cpumask # @@ -443,12 +496,17 @@ LIBCFS_HAVE_CRC32 LIBCFS_ENABLE_CRC32_ACCEL # 3.10 LIBCFS_ENABLE_CRC32C_ACCEL +# 3.11 +LIBCFS_KTIME_GET_TS64 # 3.12 LIBCFS_SHRINKER_COUNT # 3.17 LIBCFS_HLIST_ADD_AFTER LIBCFS_TIMESPEC64 LIBCFS_KTIME_GET_REAL_TS64 +LIBCFS_KTIME_GET_REAL_SECONDS +# 3.19 +LIBCFS_KTIME_GET_SECONDS # 4.2 LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK LIBCFS_FPU_API diff --git a/libcfs/include/libcfs/linux/linux-time.h b/libcfs/include/libcfs/linux/linux-time.h index e7b2956..706b79c 100644 --- a/libcfs/include/libcfs/linux/linux-time.h +++ b/libcfs/include/libcfs/linux/linux-time.h @@ -130,10 +130,22 @@ static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) #endif /* HAVE_TIMESPEC64 */ +#ifndef HAVE_KTIME_GET_TS64 +void ktime_get_ts64(struct timespec64 *ts); +#endif /* HAVE_KTIME_GET_TS */ + #ifndef HAVE_KTIME_GET_REAL_TS64 void ktime_get_real_ts64(struct timespec64 *ts); #endif /* HAVE_KTIME_GET_REAL_TS */ +#ifndef HAVE_KTIME_GET_REAL_SECONDS +time64_t ktime_get_real_seconds(void); +#endif /* HAVE_KTIME_GET_REAL_SECONDS */ + +#ifndef HAVE_KTIME_GET_SECONDS +time64_t ktime_get_seconds(void); +#endif /* HAVE_KTIME_GET_SECONDS */ + static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2) { return time_before(t1, t2); diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index d945a34..c3c3d15 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -214,21 +214,20 @@ libcfs_debug_str2mask(int *mask, const char *str, int is_subsys) */ void libcfs_debug_dumplog_internal(void *arg) { - static time_t last_dump_time; - time_t current_time; + static time64_t last_dump_time; + time64_t current_time; void *journal_info; journal_info = current->journal_info; current->journal_info = NULL; - - current_time = cfs_time_current_sec(); + current_time = ktime_get_real_seconds(); if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0 && current_time > last_dump_time) { last_dump_time = current_time; snprintf(debug_file_name, sizeof(debug_file_name) - 1, - "%s.%ld.%ld", libcfs_debug_file_path_arr, - current_time, (uintptr_t)arg); + "%s.%lld.%ld", libcfs_debug_file_path_arr, + (s64)current_time, (uintptr_t)arg); printk(KERN_ALERT "LustreError: dumping log to %s\n", debug_file_name); cfs_tracefile_dump_all_pages(debug_file_name); diff --git a/libcfs/libcfs/linux/linux-prim.c b/libcfs/libcfs/linux/linux-prim.c index bd3979f..4d10dcb 100644 --- a/libcfs/libcfs/linux/linux-prim.c +++ b/libcfs/libcfs/linux/linux-prim.c @@ -80,14 +80,60 @@ cfs_time_t cfs_timer_deadline(struct timer_list *t) } EXPORT_SYMBOL(cfs_timer_deadline); +#ifndef HAVE_KTIME_GET_TS64 +void ktime_get_ts64(struct timespec64 *ts) +{ + struct timespec now; + + ktime_get_ts(&now); + *ts = timespec_to_timespec64(now); +} +EXPORT_SYMBOL(ktime_get_ts64); +#endif /* HAVE_KTIME_GET_TS64 */ + #ifndef HAVE_KTIME_GET_REAL_TS64 void ktime_get_real_ts64(struct timespec64 *ts) { - *ts = timespec_to_timespec64(CURRENT_TIME); + struct timespec now; + + getnstimeofday(&now); + *ts = timespec_to_timespec64(now); } EXPORT_SYMBOL(ktime_get_real_ts64); #endif /* HAVE_KTIME_GET_REAL_TS64 */ +#ifndef HAVE_KTIME_GET_REAL_SECONDS +/* + * Get the seconds portion of CLOCK_REALTIME (wall clock). + * This is the clock that can be altered by NTP and is + * independent of a reboot. + */ +time64_t ktime_get_real_seconds(void) +{ + return (time64_t)get_seconds(); +} +EXPORT_SYMBOL(ktime_get_real_seconds); +#endif /* HAVE_KTIME_GET_REAL_SECONDS */ + +#ifndef HAVE_KTIME_GET_SECONDS +/* + * Get the seconds portion of CLOCK_MONOTONIC + * This clock is immutable and is reset across + * reboots. For older platforms this is a + * wrapper around get_seconds which is valid + * until 2038. By that time this will be gone + * one would hope. + */ +time64_t ktime_get_seconds(void) +{ + struct timespec64 now; + + ktime_get_ts64(&now); + return now.tv_sec; +} +EXPORT_SYMBOL(ktime_get_seconds); +#endif /* HAVE_KTIME_GET_SECONDS */ + sigset_t cfs_block_allsigs(void) { diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index 3d8eab3..3ff7b33 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -281,7 +281,7 @@ typedef struct lnet_ni { lnd_t *ni_lnd; /* procedural interface */ struct lnet_tx_queue **ni_tx_queues; /* percpt TX queues */ int **ni_refs; /* percpt reference count */ - long ni_last_alive; /* when I was last alive */ + time64_t ni_last_alive; /* when I was last alive */ lnet_ni_status_t *ni_status; /* my health status */ /* per NI LND tunables */ struct lnet_ioctl_config_lnd_tunables *ni_lnd_tunables; diff --git a/lnet/klnds/o2iblnd/o2iblnd.h b/lnet/klnds/o2iblnd/o2iblnd.h index f3947a6..a617b63 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.h +++ b/lnet/klnds/o2iblnd/o2iblnd.h @@ -418,7 +418,7 @@ typedef struct * The second that peers are pulled out from \a kib_reconn_wait * for reconnection. */ - unsigned int kib_reconn_sec; + time64_t kib_reconn_sec; /* connection daemon sleeps here */ wait_queue_head_t kib_connd_waitq; spinlock_t kib_connd_lock; /* serialise */ diff --git a/lnet/klnds/o2iblnd/o2iblnd_cb.c b/lnet/klnds/o2iblnd/o2iblnd_cb.c index 9526d7e..a72bdba 100644 --- a/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -3320,8 +3320,9 @@ kiblnd_connd (void *arg) } while (reconn < KIB_RECONN_BREAK) { - if (kiblnd_data.kib_reconn_sec != get_seconds()) { - kiblnd_data.kib_reconn_sec = get_seconds(); + if (kiblnd_data.kib_reconn_sec != + ktime_get_real_seconds()) { + kiblnd_data.kib_reconn_sec = ktime_get_real_seconds(); list_splice_init(&kiblnd_data.kib_reconn_wait, &kiblnd_data.kib_reconn_list); } diff --git a/lnet/klnds/socklnd/socklnd.c b/lnet/klnds/socklnd/socklnd.c index f3a5dfd..33c34cd 100644 --- a/lnet/klnds/socklnd/socklnd.c +++ b/lnet/klnds/socklnd/socklnd.c @@ -1250,7 +1250,7 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, } conn->ksnc_peer = peer; /* conn takes my ref on peer */ - peer->ksnp_last_alive = cfs_time_current(); + peer->ksnp_last_alive = ktime_get_real_seconds(); peer->ksnp_send_keepalive = 0; peer->ksnp_error = 0; @@ -1258,7 +1258,7 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, sched->kss_nconns++; conn->ksnc_scheduler = sched; - conn->ksnc_tx_last_post = cfs_time_current(); + conn->ksnc_tx_last_post = ktime_get_real_seconds(); /* Set the deadline for the outgoing HELLO to drain */ conn->ksnc_tx_bufnob = sock->sk->sk_wmem_queued; conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout); @@ -1644,7 +1644,7 @@ ksocknal_destroy_conn (ksock_conn_t *conn) libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type, &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_rx_nob_wanted, conn->ksnc_rx_nob_left, - cfs_duration_sec(cfs_time_sub(cfs_time_current(), + cfs_duration_sec(cfs_time_sub(ktime_get_real_seconds(), last_rcv))); lnet_finalize (conn->ksnc_peer->ksnp_ni, conn->ksnc_cookie, -EIO); @@ -1785,14 +1785,14 @@ ksocknal_notify (lnet_ni_t *ni, lnet_nid_t gw_nid, int alive) } void -ksocknal_query (lnet_ni_t *ni, lnet_nid_t nid, cfs_time_t *when) +ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, cfs_time_t *when) { - int connect = 1; - cfs_time_t last_alive = 0; - cfs_time_t now = cfs_time_current(); - ksock_peer_t *peer = NULL; - rwlock_t *glock = &ksocknal_data.ksnd_global_lock; - lnet_process_id_t id = { + int connect = 1; + time64_t last_alive = 0; + time64_t now = ktime_get_real_seconds(); + ksock_peer_t *peer = NULL; + rwlock_t *glock = &ksocknal_data.ksnd_global_lock; + lnet_process_id_t id = { .nid = nid, .pid = LNET_PID_LUSTRE, }; @@ -2444,7 +2444,7 @@ ksocknal_base_startup(void) ksocknal_data.ksnd_connd_starting = 0; ksocknal_data.ksnd_connd_failed_stamp = 0; - ksocknal_data.ksnd_connd_starting_stamp = cfs_time_current_sec(); + ksocknal_data.ksnd_connd_starting_stamp = ktime_get_real_seconds(); /* must have at least 2 connds to remain responsive to accepts while * connecting */ if (*ksocknal_tunables.ksnd_nconnds < SOCKNAL_CONND_RESV + 1) diff --git a/lnet/klnds/socklnd/socklnd.h b/lnet/klnds/socklnd/socklnd.h index 4e89053..6d38849 100644 --- a/lnet/klnds/socklnd/socklnd.h +++ b/lnet/klnds/socklnd/socklnd.h @@ -235,11 +235,11 @@ typedef struct /* # connds connecting */ int ksnd_connd_connecting; /** time stamp of the last failed connecting attempt */ - long ksnd_connd_failed_stamp; + time64_t ksnd_connd_failed_stamp; /** # starting connd */ unsigned ksnd_connd_starting; /** time stamp of the last starting connd */ - long ksnd_connd_starting_stamp; + time64_t ksnd_connd_starting_stamp; /** # running connd */ unsigned ksnd_connd_running; /* serialise */ diff --git a/lnet/klnds/socklnd/socklnd_cb.c b/lnet/klnds/socklnd/socklnd_cb.c index c2f7c57..386006e 100644 --- a/lnet/klnds/socklnd/socklnd_cb.c +++ b/lnet/klnds/socklnd/socklnd_cb.c @@ -2006,7 +2006,7 @@ ksocknal_connect (ksock_route_t *route) * running out of resource. */ static int -ksocknal_connd_check_start(long sec, long *timeout) +ksocknal_connd_check_start(time64_t sec, long *timeout) { char name[16]; int rc; @@ -2056,7 +2056,7 @@ ksocknal_connd_check_start(long sec, long *timeout) /* we tried ... */ LASSERT(ksocknal_data.ksnd_connd_starting > 0); ksocknal_data.ksnd_connd_starting--; - ksocknal_data.ksnd_connd_failed_stamp = cfs_time_current_sec(); + ksocknal_data.ksnd_connd_failed_stamp = ktime_get_real_seconds(); return 1; } @@ -2068,7 +2068,7 @@ ksocknal_connd_check_start(long sec, long *timeout) * again to recheck these conditions. */ static int -ksocknal_connd_check_stop(long sec, long *timeout) +ksocknal_connd_check_stop(time64_t sec, long *timeout) { int val; @@ -2149,7 +2149,7 @@ ksocknal_connd (void *arg) while (!ksocknal_data.ksnd_shuttingdown) { ksock_route_t *route = NULL; - long sec = cfs_time_current_sec(); + time64_t sec = ktime_get_real_seconds(); long timeout = MAX_SCHEDULE_TIMEOUT; int dropped_lock = 0; diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index f897057..e0c478b 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -2088,11 +2088,15 @@ LNetCtl(unsigned int cmd, void *arg) &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_qnob); } - case IOC_LIBCFS_NOTIFY_ROUTER: + case IOC_LIBCFS_NOTIFY_ROUTER: { + unsigned long jiffies_passed; + + jiffies_passed = ktime_get_real_seconds() - data->ioc_u64[0]; + jiffies_passed = cfs_time_seconds(jiffies_passed); + return lnet_notify(NULL, data->ioc_nid, data->ioc_flags, - cfs_time_current() - - cfs_time_seconds(cfs_time_current_sec() - - (time_t)data->ioc_u64[0])); + jiffies - jiffies_passed); + } case IOC_LIBCFS_LNET_DIST: rc = LNetDist(data->ioc_nid, &data->ioc_nid, &data->ioc_u32[1]); diff --git a/lnet/lnet/config.c b/lnet/lnet/config.c index 322f776..ba8b879 100644 --- a/lnet/lnet/config.c +++ b/lnet/lnet/config.c @@ -187,7 +187,7 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist) else ni->ni_net_ns = NULL; - ni->ni_last_alive = cfs_time_current_sec(); + ni->ni_last_alive = ktime_get_real_seconds(); list_add_tail(&ni->ni_list, nilist); return ni; failed: diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index d611e50..5a749b6 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -1869,10 +1869,10 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, } if (the_lnet.ln_routing && - ni->ni_last_alive != cfs_time_current_sec()) { + ni->ni_last_alive != ktime_get_real_seconds()) { /* NB: so far here is the only place to set NI status to "up */ lnet_ni_lock(ni); - ni->ni_last_alive = cfs_time_current_sec(); + ni->ni_last_alive = ktime_get_real_seconds(); if (ni->ni_status != NULL && ni->ni_status->ns_status == LNET_NI_STATUS_DOWN) ni->ni_status->ns_status = LNET_NI_STATUS_UP; diff --git a/lnet/lnet/router.c b/lnet/lnet/router.c index 2023cfd..6d15c6c 100644 --- a/lnet/lnet/router.c +++ b/lnet/lnet/router.c @@ -838,7 +838,7 @@ static void lnet_update_ni_status_locked(void) { lnet_ni_t *ni; - long now; + time64_t now; int timeout; LASSERT(the_lnet.ln_routing); @@ -846,7 +846,7 @@ lnet_update_ni_status_locked(void) timeout = router_ping_timeout + MAX(live_router_check_interval, dead_router_check_interval); - now = cfs_time_current_sec(); + now = ktime_get_real_seconds(); list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { if (ni->ni_lnd->lnd_type == LOLND) continue; diff --git a/lnet/lnet/router_proc.c b/lnet/lnet/router_proc.c index 40d0289..efec11b 100644 --- a/lnet/lnet/router_proc.c +++ b/lnet/lnet/router_proc.c @@ -681,7 +681,7 @@ proc_lnet_nis(struct ctl_table *table, int write, void __user *buffer, if (ni != NULL) { struct lnet_tx_queue *tq; char *stat; - long now = cfs_time_current_sec(); + time64_t now = ktime_get_real_seconds(); int last_alive = -1; int i; int j; diff --git a/lnet/selftest/conctl.c b/lnet/selftest/conctl.c index ac67085..f9e4c0d 100644 --- a/lnet/selftest/conctl.c +++ b/lnet/selftest/conctl.c @@ -834,7 +834,7 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) mutex_lock(&console_session.ses_mutex); - console_session.ses_laststamp = cfs_time_current_sec(); + console_session.ses_laststamp = ktime_get_real_seconds(); if (console_session.ses_shutdown) { rc = -ESHUTDOWN; diff --git a/lnet/selftest/conrpc.c b/lnet/selftest/conrpc.c index f41b1e0..ce8e833 100644 --- a/lnet/selftest/conrpc.c +++ b/lnet/selftest/conrpc.c @@ -1190,10 +1190,10 @@ lstcon_rpc_pinger(void *arg) return; } - if (!console_session.ses_expired && - cfs_time_current_sec() - console_session.ses_laststamp > - (time_t)console_session.ses_timeout) - console_session.ses_expired = 1; + if (!console_session.ses_expired && + ktime_get_real_seconds() - console_session.ses_laststamp > + (time64_t)console_session.ses_timeout) + console_session.ses_expired = 1; trans = console_session.ses_ping; @@ -1278,8 +1278,8 @@ lstcon_rpc_pinger(void *arg) CDEBUG(D_NET, "Ping %d nodes in session\n", count); - ptimer->stt_expires = (cfs_time_t)(cfs_time_current_sec() + LST_PING_INTERVAL); - stt_add_timer(ptimer); + ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL; + stt_add_timer(ptimer); mutex_unlock(&console_session.ses_mutex); } @@ -1300,10 +1300,10 @@ lstcon_rpc_pinger_start(void) return rc; } - ptimer = &console_session.ses_ping_timer; - ptimer->stt_expires = (cfs_time_t)(cfs_time_current_sec() + LST_PING_INTERVAL); + ptimer = &console_session.ses_ping_timer; + ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL; - stt_add_timer(ptimer); + stt_add_timer(ptimer); return 0; } diff --git a/lnet/selftest/console.c b/lnet/selftest/console.c index 34d262b..e7f04c7 100644 --- a/lnet/selftest/console.c +++ b/lnet/selftest/console.c @@ -2019,7 +2019,7 @@ lstcon_console_init(void) console_session.ses_expired = 0; console_session.ses_feats_updated = 0; console_session.ses_features = LST_FEATS_MASK; - console_session.ses_laststamp = cfs_time_current_sec(); + console_session.ses_laststamp = ktime_get_real_seconds(); mutex_init(&console_session.ses_mutex); diff --git a/lnet/selftest/console.h b/lnet/selftest/console.h index 48a446e..d178354 100644 --- a/lnet/selftest/console.h +++ b/lnet/selftest/console.h @@ -149,7 +149,7 @@ typedef struct { int ses_key; /* local session key */ int ses_state; /* state of session */ int ses_timeout; /* timeout in seconds */ - time_t ses_laststamp; /* last operation stamp (seconds) */ + time64_t ses_laststamp; /* last operation stamp (seconds) */ /** tests features of the session */ unsigned ses_features; /** features are synced with remote test nodes */ diff --git a/lnet/selftest/framework.c b/lnet/selftest/framework.c index 506fcd9..1e26566 100644 --- a/lnet/selftest/framework.c +++ b/lnet/selftest/framework.c @@ -175,7 +175,7 @@ sfw_add_session_timer (void) sn->sn_timer_active = 1; timer->stt_expires = cfs_time_add(sn->sn_timeout, - cfs_time_current_sec()); + ktime_get_real_seconds()); stt_add_timer(timer); return; } diff --git a/lnet/selftest/rpc.c b/lnet/selftest/rpc.c index 89f4b55..090956f 100644 --- a/lnet/selftest/rpc.c +++ b/lnet/selftest/rpc.c @@ -553,7 +553,7 @@ srpc_add_buffer(struct swi_workitem *wi) } if (rc != 0) { - scd->scd_buf_err_stamp = cfs_time_current_sec(); + scd->scd_buf_err_stamp = ktime_get_real_seconds(); scd->scd_buf_err = rc; LASSERT(scd->scd_buf_posting > 0); @@ -1092,7 +1092,7 @@ srpc_add_client_rpc_timer(srpc_client_rpc_t *rpc) timer->stt_data = rpc; timer->stt_func = srpc_client_rpc_expired; timer->stt_expires = cfs_time_add(rpc->crpc_timeout, - cfs_time_current_sec()); + ktime_get_real_seconds()); stt_add_timer(timer); return; } @@ -1482,7 +1482,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev) } if (scd->scd_buf_err_stamp != 0 && - scd->scd_buf_err_stamp < cfs_time_current_sec()) { + scd->scd_buf_err_stamp < ktime_get_real_seconds()) { /* re-enable adding buffer */ scd->scd_buf_err_stamp = 0; scd->scd_buf_err = 0; @@ -1588,9 +1588,9 @@ srpc_startup (void) /* 1 second pause to avoid timestamp reuse */ set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(cfs_time_seconds(1)); - srpc_data.rpc_matchbits = ((__u64) cfs_time_current_sec()) << 48; + srpc_data.rpc_matchbits = ((__u64) ktime_get_real_seconds()) << 48; - srpc_data.rpc_state = SRPC_STATE_NONE; + srpc_data.rpc_state = SRPC_STATE_NONE; rc = LNetNIInit(LNET_PID_LUSTRE); if (rc < 0) { diff --git a/lnet/selftest/selftest.h b/lnet/selftest/selftest.h index e660fe14..6017704 100644 --- a/lnet/selftest/selftest.h +++ b/lnet/selftest/selftest.h @@ -274,7 +274,7 @@ struct srpc_service_cd { /** error code for scd_buf_wi */ int scd_buf_err; /** timestamp for scd_buf_err */ - unsigned long scd_buf_err_stamp; + time64_t scd_buf_err_stamp; /** total # request buffers */ int scd_buf_total; /** # posted request buffers */ diff --git a/lnet/selftest/timer.c b/lnet/selftest/timer.c index 1dfa817..404542f 100644 --- a/lnet/selftest/timer.c +++ b/lnet/selftest/timer.c @@ -74,7 +74,7 @@ stt_add_timer(stt_timer_t *timer) LASSERT(!stt_data.stt_shuttingdown); LASSERT(timer->stt_func != NULL); LASSERT(list_empty(&timer->stt_list)); - LASSERT(cfs_time_after(timer->stt_expires, cfs_time_current_sec())); + LASSERT(cfs_time_after(timer->stt_expires, ktime_get_real_seconds())); /* a simple insertion sort */ list_for_each_prev(pos, STTIMER_SLOT(timer->stt_expires)) { @@ -118,7 +118,7 @@ stt_del_timer(stt_timer_t *timer) /* called with stt_data.stt_lock held */ static int -stt_expire_list(struct list_head *slot, cfs_time_t now) +stt_expire_list(struct list_head *slot, time64_t now) { int expired = 0; stt_timer_t *timer; @@ -142,13 +142,13 @@ stt_expire_list(struct list_head *slot, cfs_time_t now) } static int -stt_check_timers (cfs_time_t *last) +stt_check_timers(cfs_time_t *last) { - int expired = 0; - cfs_time_t now; + int expired = 0; + time64_t now; cfs_time_t this_slot; - now = cfs_time_current_sec(); + now = ktime_get_real_seconds(); this_slot = now & STTIMER_SLOTTIMEMASK; spin_lock(&stt_data.stt_lock); @@ -210,7 +210,7 @@ stt_startup (void) int i; stt_data.stt_shuttingdown = 0; - stt_data.stt_prev_slot = cfs_time_current_sec() & STTIMER_SLOTTIMEMASK; + stt_data.stt_prev_slot = ktime_get_real_seconds() & STTIMER_SLOTTIMEMASK; spin_lock_init(&stt_data.stt_lock); for (i = 0; i < STTIMER_NSLOTS; i++) diff --git a/lnet/selftest/timer.h b/lnet/selftest/timer.h index 3720e34..476eee7 100644 --- a/lnet/selftest/timer.h +++ b/lnet/selftest/timer.h @@ -36,8 +36,8 @@ typedef struct { struct list_head stt_list; - cfs_time_t stt_expires; - void (*stt_func) (void *); + time64_t stt_expires; + void (*stt_func)(void *); void *stt_data; } stt_timer_t; -- 1.8.3.1