From 0049c057d0ad5e1c56dc972004ca414dbfe6a6b8 Mon Sep 17 00:00:00 2001 From: Amir Shehata Date: Thu, 19 Apr 2018 10:47:32 -0700 Subject: [PATCH] LU-10707 lnet: revert to cfs_time functions In 2.10 the entire set of changes to using ktime function is not in creating a situation where routers consider peers dead, essentially breaking routing functionality. Revert the changes that were made to LNet as part of LU-6245. Signed-off-by: Amir Shehata Change-Id: Id0765e8332a8b97167d3a602e6410f5bb6a48137 Reviewed-on: https://review.whamcloud.com/32082 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Dmitry Eremin Reviewed-by: Sebastien Buisson Reviewed-by: John L. Hammond --- lnet/klnds/o2iblnd/o2iblnd.h | 2 +- lnet/klnds/o2iblnd/o2iblnd_cb.c | 5 ++--- lnet/klnds/socklnd/socklnd.c | 12 ++++++------ 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 | 8 ++++---- lnet/selftest/console.c | 2 +- lnet/selftest/console.h | 2 +- lnet/selftest/framework.c | 3 ++- lnet/selftest/rpc.c | 9 +++++---- lnet/selftest/selftest.h | 2 +- lnet/selftest/timer.c | 10 +++++----- lnet/selftest/timer.h | 2 +- 19 files changed, 46 insertions(+), 49 deletions(-) diff --git a/lnet/klnds/o2iblnd/o2iblnd.h b/lnet/klnds/o2iblnd/o2iblnd.h index c4a4742..d8ad142 100644 --- a/lnet/klnds/o2iblnd/o2iblnd.h +++ b/lnet/klnds/o2iblnd/o2iblnd.h @@ -426,7 +426,7 @@ typedef struct * The second that peers are pulled out from \a kib_reconn_wait * for reconnection. */ - time64_t kib_reconn_sec; + unsigned int 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 9e01f97..4892118 100644 --- a/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -3356,9 +3356,8 @@ kiblnd_connd (void *arg) } while (reconn < KIB_RECONN_BREAK) { - if (kiblnd_data.kib_reconn_sec != - ktime_get_real_seconds()) { - kiblnd_data.kib_reconn_sec = ktime_get_real_seconds(); + if (kiblnd_data.kib_reconn_sec != get_seconds()) { + kiblnd_data.kib_reconn_sec = get_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 259411e..c4700c0 100644 --- a/lnet/klnds/socklnd/socklnd.c +++ b/lnet/klnds/socklnd/socklnd.c @@ -1268,7 +1268,7 @@ ksocknal_create_conn(struct lnet_ni *ni, ksock_route_t *route, } conn->ksnc_peer = peer_ni; /* conn takes my ref on peer_ni */ - peer_ni->ksnp_last_alive = ktime_get_real_seconds(); + peer_ni->ksnp_last_alive = cfs_time_current(); peer_ni->ksnp_send_keepalive = 0; peer_ni->ksnp_error = 0; @@ -1285,7 +1285,7 @@ ksocknal_create_conn(struct lnet_ni *ni, ksock_route_t *route, sched->kss_nconns++; conn->ksnc_scheduler = sched; - conn->ksnc_tx_last_post = ktime_get_real_seconds(); + conn->ksnc_tx_last_post = cfs_time_current(); /* 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); @@ -1677,7 +1677,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(ktime_get_real_seconds(), + cfs_duration_sec(cfs_time_sub(cfs_time_current(), last_rcv))); lnet_finalize(conn->ksnc_cookie, -EIO); break; @@ -1821,8 +1821,8 @@ void ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, cfs_time_t *when) { int connect = 1; - time64_t last_alive = 0; - time64_t now = ktime_get_real_seconds(); + cfs_time_t last_alive = 0; + cfs_time_t now = cfs_time_current(); ksock_peer_ni_t *peer_ni = NULL; rwlock_t *glock = &ksocknal_data.ksnd_global_lock; struct lnet_process_id id = { @@ -2466,7 +2466,7 @@ ksocknal_base_startup(void) ksocknal_data.ksnd_connd_starting = 0; ksocknal_data.ksnd_connd_failed_stamp = 0; - ksocknal_data.ksnd_connd_starting_stamp = ktime_get_real_seconds(); + ksocknal_data.ksnd_connd_starting_stamp = cfs_time_current_sec(); /* 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 1eb5a06..4668fc1 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 */ - time64_t ksnd_connd_failed_stamp; + long ksnd_connd_failed_stamp; /** # starting connd */ unsigned ksnd_connd_starting; /** time stamp of the last starting connd */ - time64_t ksnd_connd_starting_stamp; + long 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 4da9a01..58400db 100644 --- a/lnet/klnds/socklnd/socklnd_cb.c +++ b/lnet/klnds/socklnd/socklnd_cb.c @@ -2011,7 +2011,7 @@ ksocknal_connect (ksock_route_t *route) * running out of resource. */ static int -ksocknal_connd_check_start(time64_t sec, long *timeout) +ksocknal_connd_check_start(long sec, long *timeout) { char name[16]; int rc; @@ -2061,7 +2061,7 @@ ksocknal_connd_check_start(time64_t sec, long *timeout) /* we tried ... */ LASSERT(ksocknal_data.ksnd_connd_starting > 0); ksocknal_data.ksnd_connd_starting--; - ksocknal_data.ksnd_connd_failed_stamp = ktime_get_real_seconds(); + ksocknal_data.ksnd_connd_failed_stamp = cfs_time_current_sec(); return 1; } @@ -2073,7 +2073,7 @@ ksocknal_connd_check_start(time64_t sec, long *timeout) * again to recheck these conditions. */ static int -ksocknal_connd_check_stop(time64_t sec, long *timeout) +ksocknal_connd_check_stop(long sec, long *timeout) { int val; @@ -2154,7 +2154,7 @@ ksocknal_connd (void *arg) while (!ksocknal_data.ksnd_shuttingdown) { ksock_route_t *route = NULL; - time64_t sec = ktime_get_real_seconds(); + long sec = cfs_time_current_sec(); long timeout = MAX_SCHEDULE_TIMEOUT; int dropped_lock = 0; diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index aac37c0..c70e266 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -2859,15 +2859,11 @@ LNetCtl(unsigned int cmd, void *arg) return rc; } - 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); - + case IOC_LIBCFS_NOTIFY_ROUTER: return lnet_notify(NULL, data->ioc_nid, data->ioc_flags, - jiffies - jiffies_passed); - } + cfs_time_current() - + cfs_time_seconds(cfs_time_current_sec() - + (time_t)data->ioc_u64[0])); 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 fbbc18c..2c15e1f 100644 --- a/lnet/lnet/config.c +++ b/lnet/lnet/config.c @@ -479,7 +479,7 @@ lnet_ni_alloc_common(struct lnet_net *net, char *iface) else ni->ni_net_ns = NULL; - ni->ni_last_alive = ktime_get_real_seconds(); + ni->ni_last_alive = cfs_time_current_sec(); ni->ni_state = LNET_NI_STATE_INIT; list_add_tail(&ni->ni_netlist, &net->net_ni_added); diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c index 5863836..b60106f 100644 --- a/lnet/lnet/lib-move.c +++ b/lnet/lnet/lib-move.c @@ -2446,10 +2446,10 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid, } if (the_lnet.ln_routing && - ni->ni_last_alive != ktime_get_real_seconds()) { + ni->ni_last_alive != cfs_time_current_sec()) { /* NB: so far here is the only place to set NI status to "up */ lnet_ni_lock(ni); - ni->ni_last_alive = ktime_get_real_seconds(); + ni->ni_last_alive = cfs_time_current_sec(); 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 aba5699..f35b67e 100644 --- a/lnet/lnet/router.c +++ b/lnet/lnet/router.c @@ -881,7 +881,7 @@ static void lnet_update_ni_status_locked(void) { struct lnet_ni *ni = NULL; - time64_t now; + long now; int timeout; LASSERT(the_lnet.ln_routing); @@ -889,7 +889,7 @@ lnet_update_ni_status_locked(void) timeout = router_ping_timeout + MAX(live_router_check_interval, dead_router_check_interval); - now = ktime_get_real_seconds(); + now = cfs_time_current_sec(); while ((ni = lnet_get_next_ni_locked(NULL, ni))) { if (ni->ni_net->net_lnd->lnd_type == LOLND) continue; diff --git a/lnet/lnet/router_proc.c b/lnet/lnet/router_proc.c index f9d8d36..4e1368b 100644 --- a/lnet/lnet/router_proc.c +++ b/lnet/lnet/router_proc.c @@ -729,7 +729,7 @@ proc_lnet_nis(struct ctl_table *table, int write, void __user *buffer, if (ni != NULL) { struct lnet_tx_queue *tq; char *stat; - time64_t now = ktime_get_real_seconds(); + long now = cfs_time_current_sec(); int last_alive = -1; int i; int j; diff --git a/lnet/selftest/conctl.c b/lnet/selftest/conctl.c index 17a95ce..5476097 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 = ktime_get_real_seconds(); + console_session.ses_laststamp = cfs_time_current_sec(); if (console_session.ses_shutdown) { rc = -ESHUTDOWN; diff --git a/lnet/selftest/conrpc.c b/lnet/selftest/conrpc.c index 749714a..f9f6c71 100644 --- a/lnet/selftest/conrpc.c +++ b/lnet/selftest/conrpc.c @@ -1191,8 +1191,8 @@ lstcon_rpc_pinger(void *arg) } if (!console_session.ses_expired && - ktime_get_real_seconds() - console_session.ses_laststamp > - (time64_t)console_session.ses_timeout) + cfs_time_current_sec() - console_session.ses_laststamp > + (time_t)console_session.ses_timeout) console_session.ses_expired = 1; trans = console_session.ses_ping; @@ -1277,7 +1277,7 @@ lstcon_rpc_pinger(void *arg) CDEBUG(D_NET, "Ping %d nodes in session\n", count); - ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL; + ptimer->stt_expires = (cfs_time_t)(cfs_time_current_sec() + LST_PING_INTERVAL); stt_add_timer(ptimer); mutex_unlock(&console_session.ses_mutex); @@ -1300,7 +1300,7 @@ lstcon_rpc_pinger_start(void) } ptimer = &console_session.ses_ping_timer; - ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL; + ptimer->stt_expires = (cfs_time_t)(cfs_time_current_sec() + LST_PING_INTERVAL); stt_add_timer(ptimer); diff --git a/lnet/selftest/console.c b/lnet/selftest/console.c index f2cf0a4..a9fe8a8 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 = ktime_get_real_seconds(); + console_session.ses_laststamp = cfs_time_current_sec(); mutex_init(&console_session.ses_mutex); diff --git a/lnet/selftest/console.h b/lnet/selftest/console.h index 3145346..0d597c4 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 */ - time64_t ses_laststamp; /* last operation stamp (seconds) */ + time_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 032d95e..b5d430d 100644 --- a/lnet/selftest/framework.c +++ b/lnet/selftest/framework.c @@ -174,7 +174,8 @@ sfw_add_session_timer (void) LASSERT (!sn->sn_timer_active); sn->sn_timer_active = 1; - timer->stt_expires = ktime_get_real_seconds()+ sn->sn_timeout; + timer->stt_expires = cfs_time_add(sn->sn_timeout, + cfs_time_current_sec()); stt_add_timer(timer); return; } diff --git a/lnet/selftest/rpc.c b/lnet/selftest/rpc.c index f5ea3e2b..abed281 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 = ktime_get_real_seconds(); + scd->scd_buf_err_stamp = cfs_time_current_sec(); scd->scd_buf_err = rc; LASSERT(scd->scd_buf_posting > 0); @@ -1091,7 +1091,8 @@ srpc_add_client_rpc_timer(srpc_client_rpc_t *rpc) INIT_LIST_HEAD(&timer->stt_list); timer->stt_data = rpc; timer->stt_func = srpc_client_rpc_expired; - timer->stt_expires = ktime_get_real_seconds() + rpc->crpc_timeout; + timer->stt_expires = cfs_time_add(rpc->crpc_timeout, + cfs_time_current_sec()); stt_add_timer(timer); return; } @@ -1481,7 +1482,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev) } if (scd->scd_buf_err_stamp != 0 && - scd->scd_buf_err_stamp < ktime_get_real_seconds()) { + scd->scd_buf_err_stamp < cfs_time_current_sec()) { /* re-enable adding buffer */ scd->scd_buf_err_stamp = 0; scd->scd_buf_err = 0; @@ -1587,7 +1588,7 @@ 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) ktime_get_real_seconds()) << 48; + srpc_data.rpc_matchbits = ((__u64) cfs_time_current_sec()) << 48; srpc_data.rpc_state = SRPC_STATE_NONE; diff --git a/lnet/selftest/selftest.h b/lnet/selftest/selftest.h index 44bb2f8..2a29161 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 */ - time64_t scd_buf_err_stamp; + unsigned long 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 ff016e9..7e09e66 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(timer->stt_expires > ktime_get_real_seconds()); + LASSERT(cfs_time_after(timer->stt_expires, cfs_time_current_sec())); /* 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, time64_t now) +stt_expire_list(struct list_head *slot, cfs_time_t now) { int expired = 0; stt_timer_t *timer; @@ -145,10 +145,10 @@ static int stt_check_timers(cfs_time_t *last) { int expired = 0; - time64_t now; + cfs_time_t now; cfs_time_t this_slot; - now = ktime_get_real_seconds(); + now = cfs_time_current_sec(); 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 = ktime_get_real_seconds() & STTIMER_SLOTTIMEMASK; + stt_data.stt_prev_slot = cfs_time_current_sec() & 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 476eee7..71c3de27 100644 --- a/lnet/selftest/timer.h +++ b/lnet/selftest/timer.h @@ -36,7 +36,7 @@ typedef struct { struct list_head stt_list; - time64_t stt_expires; + cfs_time_t stt_expires; void (*stt_func)(void *); void *stt_data; } stt_timer_t; -- 1.8.3.1