Whamcloud - gitweb
LU-9019 selftest: remove remaining cfs_time wrappers
[fs/lustre-release.git] / lnet / selftest / conrpc.c
index 96a57f2..56a6bde 100644 (file)
@@ -69,11 +69,11 @@ lstcon_rpc_done(struct srpc_client_rpc *rpc)
        /* not an orphan RPC */
        crpc->crp_finished = 1;
 
        /* not an orphan RPC */
        crpc->crp_finished = 1;
 
-       if (crpc->crp_stamp == 0) {
+       if (crpc->crp_stamp_ns == 0) {
                /* not aborted */
                /* not aborted */
-               LASSERT (crpc->crp_status == 0);
+               LASSERT(crpc->crp_status == 0);
 
 
-               crpc->crp_stamp  = cfs_time_current();
+               crpc->crp_stamp_ns = ktime_get_ns();
                crpc->crp_status = rpc->crpc_status;
        }
 
                crpc->crp_status = rpc->crpc_status;
        }
 
@@ -89,19 +89,15 @@ lstcon_rpc_init(struct lstcon_node *nd, int service, unsigned int feats,
                int bulk_npg, int bulk_len, int embedded,
                struct lstcon_rpc *crpc)
 {
                int bulk_npg, int bulk_len, int embedded,
                struct lstcon_rpc *crpc)
 {
+       memset(crpc, 0, sizeof(*crpc));
+
        crpc->crp_rpc = sfw_create_rpc(nd->nd_id, service,
                                       feats, bulk_npg, bulk_len,
                                       lstcon_rpc_done, (void *)crpc);
        if (crpc->crp_rpc == NULL)
                return -ENOMEM;
 
        crpc->crp_rpc = sfw_create_rpc(nd->nd_id, service,
                                       feats, bulk_npg, bulk_len,
                                       lstcon_rpc_done, (void *)crpc);
        if (crpc->crp_rpc == NULL)
                return -ENOMEM;
 
-       crpc->crp_trans    = NULL;
        crpc->crp_node     = nd;
        crpc->crp_node     = nd;
-       crpc->crp_posted   = 0;
-       crpc->crp_finished = 0;
-       crpc->crp_unpacked = 0;
-       crpc->crp_status   = 0;
-       crpc->crp_stamp    = 0;
        crpc->crp_embedded = embedded;
        INIT_LIST_HEAD(&crpc->crp_link);
 
        crpc->crp_embedded = embedded;
        INIT_LIST_HEAD(&crpc->crp_link);
 
@@ -292,16 +288,16 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
                spin_lock(&rpc->crpc_lock);
 
                if (!crpc->crp_posted || /* not posted */
                spin_lock(&rpc->crpc_lock);
 
                if (!crpc->crp_posted || /* not posted */
-                   crpc->crp_stamp != 0) { /* rpc done or aborted already */
-                       if (crpc->crp_stamp == 0) {
-                               crpc->crp_stamp = cfs_time_current();
+                   crpc->crp_stamp_ns != 0) { /* rpc done or aborted already */
+                       if (crpc->crp_stamp_ns == 0) {
+                               crpc->crp_stamp_ns = ktime_get_ns();
                                crpc->crp_status = -EINTR;
                        }
                        spin_unlock(&rpc->crpc_lock);
                        continue;
                }
 
                                crpc->crp_status = -EINTR;
                        }
                        spin_unlock(&rpc->crpc_lock);
                        continue;
                }
 
-               crpc->crp_stamp  = cfs_time_current();
+               crpc->crp_stamp_ns  = ktime_get_ns();
                crpc->crp_status = error;
 
                spin_unlock(&rpc->crpc_lock);
                crpc->crp_status = error;
 
                spin_unlock(&rpc->crpc_lock);
@@ -312,10 +308,10 @@ lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
                        continue;
 
                nd = crpc->crp_node;
                        continue;
 
                nd = crpc->crp_node;
-               if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
+               if (ktime_to_ns(nd->nd_stamp) > crpc->crp_stamp_ns)
                        continue;
 
                        continue;
 
-               nd->nd_stamp = crpc->crp_stamp;
+               nd->nd_stamp = ktime_set(0, crpc->crp_stamp_ns);
                nd->nd_state = LST_NODE_DOWN;
        }
 }
                nd->nd_state = LST_NODE_DOWN;
        }
 }
@@ -388,8 +384,8 @@ lstcon_rpc_get_reply(struct lstcon_rpc *crpc, struct srpc_msg **msgpp)
        struct srpc_client_rpc *rpc = crpc->crp_rpc;
        struct srpc_generic_reply *rep;
 
        struct srpc_client_rpc *rpc = crpc->crp_rpc;
        struct srpc_generic_reply *rep;
 
-        LASSERT (nd != NULL && rpc != NULL);
-        LASSERT (crpc->crp_stamp != 0);
+       LASSERT(nd != NULL && rpc != NULL);
+       LASSERT(crpc->crp_stamp_ns != 0);
 
         if (crpc->crp_status != 0) {
                 *msgpp = NULL;
 
         if (crpc->crp_status != 0) {
                 *msgpp = NULL;
@@ -402,11 +398,11 @@ lstcon_rpc_get_reply(struct lstcon_rpc *crpc, struct srpc_msg **msgpp)
                 crpc->crp_unpacked = 1;
         }
 
                 crpc->crp_unpacked = 1;
         }
 
-        if (cfs_time_after(nd->nd_stamp, crpc->crp_stamp))
-                return 0;
+       if (ktime_to_ns(nd->nd_stamp) > crpc->crp_stamp_ns)
+               return 0;
 
 
-        nd->nd_stamp = crpc->crp_stamp;
-        rep = &(*msgpp)->msg_body.reply;
+       nd->nd_stamp = ktime_set(0, crpc->crp_stamp_ns);
+       rep = &(*msgpp)->msg_body.reply;
 
         if (rep->sid.ses_nid == LNET_NID_ANY)
                 nd->nd_state = LST_NODE_UNKNOWN;
 
         if (rep->sid.ses_nid == LNET_NID_ANY)
                 nd->nd_state = LST_NODE_UNKNOWN;
@@ -433,7 +429,7 @@ lstcon_rpc_trans_stat(struct lstcon_rpc_trans *trans,
        list_for_each_entry(crpc, &trans->tas_rpcs_list, crp_link) {
                lstcon_rpc_stat_total(stat, 1);
 
        list_for_each_entry(crpc, &trans->tas_rpcs_list, crp_link) {
                lstcon_rpc_stat_total(stat, 1);
 
-               LASSERT(crpc->crp_stamp != 0);
+               LASSERT(crpc->crp_stamp_ns != 0);
 
                 error = lstcon_rpc_get_reply(crpc, &rep);
                 if (error != 0) {
 
                 error = lstcon_rpc_get_reply(crpc, &rep);
                 if (error != 0) {
@@ -477,9 +473,9 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
        struct lstcon_rpc *crpc;
        struct srpc_msg *msg;
        struct lstcon_node *nd;
        struct lstcon_rpc *crpc;
        struct srpc_msg *msg;
        struct lstcon_node *nd;
-       cfs_duration_t dur;
        struct timeval tv;
        int error;
        struct timeval tv;
        int error;
+       s64 dur;
 
        LASSERT(head_up != NULL);
 
 
        LASSERT(head_up != NULL);
 
@@ -497,15 +493,15 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
 
                ent = list_entry(next, struct lstcon_rpc_ent, rpe_link);
 
 
                ent = list_entry(next, struct lstcon_rpc_ent, rpe_link);
 
-               LASSERT(crpc->crp_stamp != 0);
+               LASSERT(crpc->crp_stamp_ns != 0);
 
 
-                error = lstcon_rpc_get_reply(crpc, &msg);
+               error = lstcon_rpc_get_reply(crpc, &msg);
 
 
-                nd = crpc->crp_node;
+               nd = crpc->crp_node;
 
 
-                dur = (cfs_duration_t)cfs_time_sub(crpc->crp_stamp,
-                      (cfs_time_t)console_session.ses_id.ses_stamp);
-               jiffies_to_timeval(dur, &tv);
+               dur = crpc->crp_stamp_ns -
+                     console_session.ses_id.ses_stamp * NSEC_PER_MSEC;
+               tv = ns_to_timeval(dur);
 
                if (copy_to_user(&ent->rpe_peer,
                                 &nd->nd_id, sizeof(struct lnet_process_id)) ||
 
                if (copy_to_user(&ent->rpe_peer,
                                 &nd->nd_id, sizeof(struct lnet_process_id)) ||
@@ -1253,12 +1249,12 @@ lstcon_rpc_pinger(void *arg)
                        lstcon_rpc_put(crpc);
                }
 
                        lstcon_rpc_put(crpc);
                }
 
-                if (nd->nd_state != LST_NODE_ACTIVE)
-                        continue;
+               if (nd->nd_state != LST_NODE_ACTIVE)
+                       continue;
 
 
-               intv = cfs_duration_sec(jiffies - nd->nd_stamp);
+               intv = ktime_ms_delta(ktime_get(), nd->nd_stamp) / MSEC_PER_SEC;
                if (intv < nd->nd_timeout / 2)
                if (intv < nd->nd_timeout / 2)
-                        continue;
+                       continue;
 
                rc = lstcon_rpc_init(nd, SRPC_SERVICE_DEBUG,
                                     trans->tas_features, 0, 0, 1, crpc);
 
                rc = lstcon_rpc_init(nd, SRPC_SERVICE_DEBUG,
                                     trans->tas_features, 0, 0, 1, crpc);