Whamcloud - gitweb
LU-10707 lnet: revert to cfs_time functions 82/32082/3
authorAmir Shehata <amir.shehata@intel.com>
Thu, 19 Apr 2018 17:47:32 +0000 (10:47 -0700)
committerJohn L. Hammond <john.hammond@intel.com>
Thu, 3 May 2018 19:17:09 +0000 (19:17 +0000)
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 <amir.shehata@intel.com>
Change-Id: Id0765e8332a8b97167d3a602e6410f5bb6a48137
Reviewed-on: https://review.whamcloud.com/32082
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
19 files changed:
lnet/klnds/o2iblnd/o2iblnd.h
lnet/klnds/o2iblnd/o2iblnd_cb.c
lnet/klnds/socklnd/socklnd.c
lnet/klnds/socklnd/socklnd.h
lnet/klnds/socklnd/socklnd_cb.c
lnet/lnet/api-ni.c
lnet/lnet/config.c
lnet/lnet/lib-move.c
lnet/lnet/router.c
lnet/lnet/router_proc.c
lnet/selftest/conctl.c
lnet/selftest/conrpc.c
lnet/selftest/console.c
lnet/selftest/console.h
lnet/selftest/framework.c
lnet/selftest/rpc.c
lnet/selftest/selftest.h
lnet/selftest/timer.c
lnet/selftest/timer.h

index c4a4742..d8ad142 100644 (file)
@@ -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 */
index 9e01f97..4892118 100644 (file)
@@ -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);
                        }
index 259411e..c4700c0 100644 (file)
@@ -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)
index 1eb5a06..4668fc1 100644 (file)
@@ -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 */
index 4da9a01..58400db 100644 (file)
@@ -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;
 
index aac37c0..c70e266 100644 (file)
@@ -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]);
index fbbc18c..2c15e1f 100644 (file)
@@ -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);
 
index 5863836..b60106f 100644 (file)
@@ -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;
index aba5699..f35b67e 100644 (file)
@@ -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;
index f9d8d36..4e1368b 100644 (file)
@@ -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;
index 17a95ce..5476097 100644 (file)
@@ -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;
index 749714a..f9f6c71 100644 (file)
@@ -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);
 
index f2cf0a4..a9fe8a8 100644 (file)
@@ -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);
 
index 3145346..0d597c4 100644 (file)
@@ -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 */
index 032d95e..b5d430d 100644 (file)
@@ -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;
 }
index f5ea3e2..abed281 100644 (file)
@@ -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;
 
index 44bb2f8..2a29161 100644 (file)
@@ -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 */
index ff016e9..7e09e66 100644 (file)
@@ -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++)
index 476eee7..71c3de2 100644 (file)
@@ -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;