Whamcloud - gitweb
LU-12930 various: use schedule_timeout_*interruptible
[fs/lustre-release.git] / lnet / selftest / conrpc.c
index 100b447..8efacc0 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -40,7 +36,6 @@
  * Author: Liang Zhen <liang@whamcloud.com>
  */
 
-#ifdef __KERNEL__
 
 #include <libcfs/libcfs.h>
 #include <lnet/lib-lnet.h>
 #include "conrpc.h"
 #include "console.h"
 
-void lstcon_rpc_stat_reply(lstcon_rpc_trans_t *, srpc_msg_t *,
-                          lstcon_node_t *, lstcon_trans_stat_t *);
+void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *,
+                          struct lstcon_node *, struct lstcon_trans_stat *);
 
 static void
-lstcon_rpc_done(srpc_client_rpc_t *rpc)
+lstcon_rpc_done(struct srpc_client_rpc *rpc)
 {
-       lstcon_rpc_t *crpc = (lstcon_rpc_t *)rpc->crpc_priv;
+       struct lstcon_rpc *crpc = rpc->crpc_priv;
 
        LASSERT(crpc != NULL && rpc == crpc->crp_rpc);
        LASSERT(crpc->crp_posted && !crpc->crp_finished);
@@ -74,11 +69,11 @@ lstcon_rpc_done(srpc_client_rpc_t *rpc)
        /* not an orphan RPC */
        crpc->crp_finished = 1;
 
-       if (crpc->crp_stamp == 0) {
+       if (crpc->crp_stamp_ns == 0) {
                /* 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;
        }
 
@@ -89,23 +84,20 @@ lstcon_rpc_done(srpc_client_rpc_t *rpc)
        spin_unlock(&rpc->crpc_lock);
 }
 
-int
-lstcon_rpc_init(lstcon_node_t *nd, int service, unsigned feats,
-               int bulk_npg, int bulk_len, int embedded, lstcon_rpc_t *crpc)
+static int
+lstcon_rpc_init(struct lstcon_node *nd, int service, unsigned int feats,
+               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_trans    = NULL;
        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);
 
@@ -114,18 +106,18 @@ lstcon_rpc_init(lstcon_node_t *nd, int service, unsigned feats,
        return 0;
 }
 
-int
-lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats,
-               int bulk_npg, int bulk_len, lstcon_rpc_t **crpcpp)
+static int
+lstcon_rpc_prep(struct lstcon_node *nd, int service, unsigned int feats,
+               int bulk_npg, int bulk_len, struct lstcon_rpc **crpcpp)
 {
-       lstcon_rpc_t  *crpc = NULL;
-       int            rc;
+       struct lstcon_rpc *crpc = NULL;
+       int rc;
 
        spin_lock(&console_session.ses_rpc_lock);
 
        if (!list_empty(&console_session.ses_rpc_freelist)) {
                crpc = list_entry(console_session.ses_rpc_freelist.next,
-                                 lstcon_rpc_t, crp_link);
+                                 struct lstcon_rpc, crp_link);
                list_del_init(&crpc->crp_link);
        }
 
@@ -149,10 +141,10 @@ lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats,
 }
 
 void
-lstcon_rpc_put(lstcon_rpc_t *crpc)
+lstcon_rpc_put(struct lstcon_rpc *crpc)
 {
-       srpc_bulk_t *bulk = &crpc->crp_rpc->crpc_bulk;
-       int          i;
+       struct srpc_bulk *bulk = &crpc->crp_rpc->crpc_bulk;
+       int i;
 
        LASSERT(list_empty(&crpc->crp_link));
 
@@ -183,10 +175,10 @@ lstcon_rpc_put(lstcon_rpc_t *crpc)
        atomic_dec(&console_session.ses_rpc_counter);
 }
 
-void
-lstcon_rpc_post(lstcon_rpc_t *crpc)
+static void
+lstcon_rpc_post(struct lstcon_rpc *crpc)
 {
-        lstcon_rpc_trans_t *trans = crpc->crp_trans;
+       struct lstcon_rpc_trans *trans = crpc->crp_trans;
 
         LASSERT (trans != NULL);
 
@@ -237,9 +229,9 @@ lstcon_rpc_trans_name(int transop)
 
 int
 lstcon_rpc_trans_prep(struct list_head *translist, int transop,
-                     lstcon_rpc_trans_t **transpp)
+                     struct lstcon_rpc_trans **transpp)
 {
-       lstcon_rpc_trans_t *trans;
+       struct lstcon_rpc_trans *trans;
 
        if (translist != NULL) {
                list_for_each_entry(trans, translist, tas_link) {
@@ -277,18 +269,18 @@ lstcon_rpc_trans_prep(struct list_head *translist, int transop,
 }
 
 void
-lstcon_rpc_trans_addreq(lstcon_rpc_trans_t *trans, lstcon_rpc_t *crpc)
+lstcon_rpc_trans_addreq(struct lstcon_rpc_trans *trans, struct lstcon_rpc *crpc)
 {
        list_add_tail(&crpc->crp_link, &trans->tas_rpcs_list);
        crpc->crp_trans = trans;
 }
 
 void
-lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error)
+lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error)
 {
-       srpc_client_rpc_t *rpc;
-       lstcon_rpc_t      *crpc;
-       lstcon_node_t     *nd;
+       struct srpc_client_rpc *rpc;
+       struct lstcon_rpc *crpc;
+       struct lstcon_node *nd;
 
        list_for_each_entry(crpc, &trans->tas_rpcs_list, crp_link) {
                rpc = crpc->crp_rpc;
@@ -296,16 +288,16 @@ lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error)
                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_stamp  = cfs_time_current();
+               crpc->crp_stamp_ns  = ktime_get_ns();
                crpc->crp_status = error;
 
                spin_unlock(&rpc->crpc_lock);
@@ -316,16 +308,16 @@ lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error)
                        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;
 
-               nd->nd_stamp = crpc->crp_stamp;
+               nd->nd_stamp = ktime_set(0, crpc->crp_stamp_ns);
                nd->nd_state = LST_NODE_DOWN;
        }
 }
 
 static int
-lstcon_rpc_trans_check(lstcon_rpc_trans_t *trans)
+lstcon_rpc_trans_check(struct lstcon_rpc_trans *trans)
 {
        if (console_session.ses_shutdown &&
            !list_empty(&trans->tas_olink)) /* Not an end session RPC */
@@ -335,10 +327,10 @@ lstcon_rpc_trans_check(lstcon_rpc_trans_t *trans)
 }
 
 int
-lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
+lstcon_rpc_trans_postwait(struct lstcon_rpc_trans *trans, int timeout)
 {
-       lstcon_rpc_t  *crpc;
-       int            rc;
+       struct lstcon_rpc *crpc;
+       int rc;
 
        if (list_empty(&trans->tas_rpcs_list))
                 return 0;
@@ -385,15 +377,15 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
         return rc;
 }
 
-int
-lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
+static int
+lstcon_rpc_get_reply(struct lstcon_rpc *crpc, struct srpc_msg **msgpp)
 {
-        lstcon_node_t        *nd  = crpc->crp_node;
-        srpc_client_rpc_t    *rpc = crpc->crp_rpc;
-        srpc_generic_reply_t *rep;
+       struct lstcon_node *nd = crpc->crp_node;
+       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;
@@ -406,11 +398,11 @@ lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
                 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;
@@ -423,11 +415,12 @@ lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
 }
 
 void
-lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat)
+lstcon_rpc_trans_stat(struct lstcon_rpc_trans *trans,
+                     struct lstcon_trans_stat *stat)
 {
-       lstcon_rpc_t    *crpc;
-       srpc_msg_t      *rep;
-       int              error;
+       struct lstcon_rpc *crpc;
+       struct srpc_msg *rep;
+       int error;
 
        LASSERT(stat != NULL);
 
@@ -436,7 +429,7 @@ lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat)
        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) {
@@ -464,25 +457,23 @@ lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat)
                lstcon_rpc_stat_failure(stat, 0),
                lstcon_rpc_stat_total(stat, 0),
                stat->trs_rpc_errno, stat->trs_fwk_errno);
-
-        return;
 }
 
 int
-lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
-                            struct list_head *head_up,
+lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
+                            struct list_head __user *head_up,
                             lstcon_rpc_readent_func_t readent)
 {
-       struct list_head      tmp;
-       struct list_head     *next;
-        lstcon_rpc_ent_t     *ent;
-        srpc_generic_reply_t *rep;
-        lstcon_rpc_t         *crpc;
-        srpc_msg_t           *msg;
-        lstcon_node_t        *nd;
-        cfs_duration_t        dur;
-        struct timeval        tv;
-        int                   error;
+       struct list_head tmp;
+       struct list_head __user *next;
+       struct lstcon_rpc_ent *ent;
+       struct srpc_generic_reply *rep;
+       struct lstcon_rpc *crpc;
+       struct srpc_msg *msg;
+       struct lstcon_node *nd;
+       struct timeval tv;
+       int error;
+       s64 dur;
 
        LASSERT(head_up != NULL);
 
@@ -498,20 +489,20 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
 
                next = tmp.next;
 
-               ent = list_entry(next, lstcon_rpc_ent_t, 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);
-                cfs_duration_usec(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(lnet_process_id_t)) ||
+                                &nd->nd_id, sizeof(struct lnet_process_id)) ||
                    copy_to_user(&ent->rpe_stamp, &tv, sizeof(tv)) ||
                    copy_to_user(&ent->rpe_state,
                                 &nd->nd_state, sizeof(nd->nd_state)) ||
@@ -523,10 +514,10 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
                        continue;
 
                /* RPC is done */
-               rep = (srpc_generic_reply_t *)&msg->msg_body.reply;
+               rep = (struct srpc_generic_reply *)&msg->msg_body.reply;
 
                if (copy_to_user(&ent->rpe_sid,
-                                &rep->sid, sizeof(lst_sid_t)) ||
+                                &rep->sid, sizeof(rep->sid)) ||
                    copy_to_user(&ent->rpe_fwk_errno,
                                 &rep->status, sizeof(rep->status)))
                        return -EFAULT;
@@ -543,12 +534,12 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
 }
 
 void
-lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
+lstcon_rpc_trans_destroy(struct lstcon_rpc_trans *trans)
 {
-       srpc_client_rpc_t *rpc;
-       lstcon_rpc_t      *crpc;
-       lstcon_rpc_t      *tmp;
-       int                count = 0;
+       struct srpc_client_rpc *rpc;
+       struct lstcon_rpc *crpc;
+       struct lstcon_rpc *tmp;
+       int count = 0;
 
        list_for_each_entry_safe(crpc, tmp, &trans->tas_rpcs_list, crp_link) {
                rpc = crpc->crp_rpc;
@@ -592,17 +583,15 @@ lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
               lstcon_rpc_trans_name(trans->tas_opc), count);
 
        LIBCFS_FREE(trans, sizeof(*trans));
-
-       return;
 }
 
 int
-lstcon_sesrpc_prep(lstcon_node_t *nd, int transop,
-                  unsigned feats, lstcon_rpc_t **crpc)
+lstcon_sesrpc_prep(struct lstcon_node *nd, int transop,
+                  unsigned int feats, struct lstcon_rpc **crpc)
 {
-        srpc_mksn_reqst_t *msrq;
-        srpc_rmsn_reqst_t *rsrq;
-        int                rc;
+       struct srpc_mksn_reqst *msrq;
+       struct srpc_rmsn_reqst *rsrq;
+       int rc;
 
         switch (transop) {
         case LST_TRANS_SESNEW:
@@ -614,8 +603,8 @@ lstcon_sesrpc_prep(lstcon_node_t *nd, int transop,
                 msrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.mksn_reqst;
                 msrq->mksn_sid     = console_session.ses_id;
                 msrq->mksn_force   = console_session.ses_force;
-                strncpy(msrq->mksn_name, console_session.ses_name,
-                        strlen(console_session.ses_name));
+               strlcpy(msrq->mksn_name, console_session.ses_name,
+                       sizeof(msrq->mksn_name));
                 break;
 
         case LST_TRANS_SESEND:
@@ -636,10 +625,11 @@ lstcon_sesrpc_prep(lstcon_node_t *nd, int transop,
 }
 
 int
-lstcon_dbgrpc_prep(lstcon_node_t *nd, unsigned feats, lstcon_rpc_t **crpc)
+lstcon_dbgrpc_prep(struct lstcon_node *nd, unsigned int feats,
+                  struct lstcon_rpc **crpc)
 {
-       srpc_debug_reqst_t *drq;
-       int                 rc;
+       struct srpc_debug_reqst *drq;
+       int rc;
 
        rc = lstcon_rpc_prep(nd, SRPC_SERVICE_DEBUG, feats, 0, 0, crpc);
         if (rc != 0)
@@ -654,12 +644,12 @@ lstcon_dbgrpc_prep(lstcon_node_t *nd, unsigned feats, lstcon_rpc_t **crpc)
 }
 
 int
-lstcon_batrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
-                  lstcon_tsb_hdr_t *tsb, lstcon_rpc_t **crpc)
+lstcon_batrpc_prep(struct lstcon_node *nd, int transop, unsigned int feats,
+                  struct lstcon_tsb_hdr *tsb, struct lstcon_rpc **crpc)
 {
-       lstcon_batch_t     *batch;
-       srpc_batch_reqst_t *brq;
-       int                 rc;
+       struct lstcon_batch *batch;
+       struct srpc_batch_reqst *brq;
+       int rc;
 
        rc = lstcon_rpc_prep(nd, SRPC_SERVICE_BATCH, feats, 0, 0, crpc);
         if (rc != 0)
@@ -680,17 +670,18 @@ lstcon_batrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
 
         LASSERT (tsb->tsb_index == 0);
 
-        batch = (lstcon_batch_t *)tsb;
+       batch = (struct lstcon_batch *)tsb;
         brq->bar_arg = batch->bat_arg;
 
         return 0;
 }
 
 int
-lstcon_statrpc_prep(lstcon_node_t *nd, unsigned feats, lstcon_rpc_t **crpc)
+lstcon_statrpc_prep(struct lstcon_node *nd, unsigned int feats,
+                   struct lstcon_rpc **crpc)
 {
-       srpc_stat_reqst_t *srq;
-       int                rc;
+       struct srpc_stat_reqst *srq;
+       int rc;
 
        rc = lstcon_rpc_prep(nd, SRPC_SERVICE_QUERY_STAT, feats, 0, 0, crpc);
         if (rc != 0)
@@ -704,31 +695,31 @@ lstcon_statrpc_prep(lstcon_node_t *nd, unsigned feats, lstcon_rpc_t **crpc)
         return 0;
 }
 
-lnet_process_id_packed_t *
+static struct lnet_process_id_packed *
 lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov)
 {
-        lnet_process_id_packed_t *pid;
+       struct lnet_process_id_packed *pid;
         int                       i;
 
         i = idx / SFW_ID_PER_PAGE;
-        
+
         LASSERT (i < nkiov);
 
-       pid = (lnet_process_id_packed_t *)page_address(kiov[i].kiov_page);
+       pid = (struct lnet_process_id_packed *)page_address(kiov[i].kiov_page);
 
         return &pid[idx % SFW_ID_PER_PAGE];
 }
 
-int
-lstcon_dstnodes_prep(lstcon_group_t *grp, int idx,
+static int
+lstcon_dstnodes_prep(struct lstcon_group *grp, int idx,
                      int dist, int span, int nkiov, lnet_kiov_t *kiov)
 {
-        lnet_process_id_packed_t *pid;
-        lstcon_ndlink_t          *ndl;
-        lstcon_node_t            *nd;
-        int                       start;
-        int                       end;
-        int                       i = 0;
+       struct lnet_process_id_packed *pid;
+       struct lstcon_ndlink *ndl;
+       struct lstcon_node *nd;
+       int start;
+       int end;
+       int i = 0;
 
         LASSERT (dist >= 1);
         LASSERT (span >= 1);
@@ -773,10 +764,11 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx,
        return 0;
 }
 
-int
-lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req)
+static int
+lstcon_pingrpc_prep(struct lst_test_ping_param *param,
+                   struct srpc_test_reqst *req)
 {
-        test_ping_req_t *prq = &req->tsr_u.ping;
+       struct test_ping_req *prq = &req->tsr_u.ping;
 
         prq->png_size   = param->png_size;
         prq->png_flags  = param->png_flags;
@@ -784,50 +776,52 @@ lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req)
         return 0;
 }
 
-int
-lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req)
+static int
+lstcon_bulkrpc_v0_prep(struct lst_test_bulk_param *param,
+                      struct srpc_test_reqst *req)
 {
-       test_bulk_req_t *brq = &req->tsr_u.bulk_v0;
+       struct test_bulk_req *brq = &req->tsr_u.bulk_v0;
 
        brq->blk_opc    = param->blk_opc;
-       brq->blk_npg    = (param->blk_size + PAGE_CACHE_SIZE - 1) /
-                          PAGE_CACHE_SIZE;
+       brq->blk_npg    = (param->blk_size + PAGE_SIZE - 1) /
+                          PAGE_SIZE;
        brq->blk_flags  = param->blk_flags;
 
        return 0;
 }
 
-int
-lstcon_bulkrpc_v1_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req)
+static int
+lstcon_bulkrpc_v1_prep(struct lst_test_bulk_param *param, bool is_client,
+                      struct srpc_test_reqst *req)
 {
-       test_bulk_req_v1_t *brq = &req->tsr_u.bulk_v1;
+       struct test_bulk_req_v1 *brq = &req->tsr_u.bulk_v1;
 
        brq->blk_opc    = param->blk_opc;
        brq->blk_flags  = param->blk_flags;
        brq->blk_len    = param->blk_size;
-       brq->blk_offset = 0; /* reserved */
+       brq->blk_offset = is_client ? param->blk_cli_off : param->blk_srv_off;
 
        return 0;
 }
 
 int
-lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
-                    lstcon_test_t *test, lstcon_rpc_t **crpc)
+lstcon_testrpc_prep(struct lstcon_node *nd, int transop, unsigned int feats,
+                   struct lstcon_test *test, struct lstcon_rpc **crpc)
 {
-        lstcon_group_t    *sgrp = test->tes_src_grp;
-        lstcon_group_t    *dgrp = test->tes_dst_grp;
-        srpc_test_reqst_t *trq;
-        srpc_bulk_t       *bulk;
-        int                i;
-       int                npg = 0;
-       int                nob = 0;
-       int                rc  = 0;
+       struct lstcon_group *sgrp = test->tes_src_grp;
+       struct lstcon_group *dgrp = test->tes_dst_grp;
+       struct srpc_test_reqst *trq;
+       struct srpc_bulk *bulk;
+       int i;
+       int npg = 0;
+       int nob = 0;
+       int rc = 0;
 
        if (transop == LST_TRANS_TSBCLIADD) {
                npg = sfw_id_pages(test->tes_span);
                nob = (feats & LST_FEAT_BULK_LEN) == 0 ?
-                     npg * PAGE_CACHE_SIZE :
-                     sizeof(lnet_process_id_packed_t) * test->tes_span;
+                     npg * PAGE_SIZE :
+                     sizeof(struct lnet_process_id_packed) * test->tes_span;
        }
 
        rc = lstcon_rpc_prep(nd, SRPC_SERVICE_TEST, feats, npg, nob, crpc);
@@ -853,13 +847,13 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
                        LASSERT(nob > 0);
 
                        len = (feats & LST_FEAT_BULK_LEN) == 0 ?
-                             PAGE_CACHE_SIZE : min_t(int, nob, PAGE_CACHE_SIZE);
+                             PAGE_SIZE : min_t(int, nob, PAGE_SIZE);
                        nob -= len;
 
                        bulk->bk_iovs[i].kiov_offset = 0;
                        bulk->bk_iovs[i].kiov_len    = len;
                        bulk->bk_iovs[i].kiov_page   =
-                               alloc_page(GFP_IOFS);
+                               alloc_page(GFP_KERNEL);
 
                        if (bulk->bk_iovs[i].kiov_page == NULL) {
                                lstcon_rpc_put(*crpc);
@@ -883,7 +877,7 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
 
                 trq->tsr_ndest = test->tes_span;
                 trq->tsr_loop  = test->tes_loop;
-        } 
+       }
 
         trq->tsr_sid        = console_session.ses_id;
         trq->tsr_bid        = test->tes_hdr.tsb_id;
@@ -894,18 +888,19 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
         switch (test->tes_type) {
         case LST_TEST_PING:
                 trq->tsr_service = SRPC_SERVICE_PING;
-               rc = lstcon_pingrpc_prep((lst_test_ping_param_t *)
+               rc = lstcon_pingrpc_prep((struct lst_test_ping_param *)
                                         &test->tes_param[0], trq);
                break;
 
        case LST_TEST_BULK:
                trq->tsr_service = SRPC_SERVICE_BRW;
                if ((feats & LST_FEAT_BULK_LEN) == 0) {
-                       rc = lstcon_bulkrpc_v0_prep((lst_test_bulk_param_t *)
+                       rc = lstcon_bulkrpc_v0_prep((struct lst_test_bulk_param *)
                                                    &test->tes_param[0], trq);
                } else {
-                       rc = lstcon_bulkrpc_v1_prep((lst_test_bulk_param_t *)
-                                                   &test->tes_param[0], trq);
+                       rc = lstcon_bulkrpc_v1_prep((struct lst_test_bulk_param *)
+                                                   &test->tes_param[0],
+                                                   trq->tsr_is_client, trq);
                }
 
                 break;
@@ -917,12 +912,12 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
         return rc;
 }
 
-int
-lstcon_sesnew_stat_reply(lstcon_rpc_trans_t *trans,
-                        lstcon_node_t *nd, srpc_msg_t *reply)
+static int
+lstcon_sesnew_stat_reply(struct lstcon_rpc_trans *trans,
+                        struct lstcon_node *nd, struct srpc_msg *reply)
 {
-       srpc_mksn_reply_t *mksn_rep = &reply->msg_body.mksn_reply;
-       int                status   = mksn_rep->mksn_status;
+       struct srpc_mksn_reply *mksn_rep = &reply->msg_body.mksn_reply;
+       int status = mksn_rep->mksn_status;
 
        if (status == 0 &&
            (reply->msg_ses_feats & ~LST_FEATS_MASK) != 0) {
@@ -965,15 +960,15 @@ lstcon_sesnew_stat_reply(lstcon_rpc_trans_t *trans,
 }
 
 void
-lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
-                      lstcon_node_t *nd, lstcon_trans_stat_t *stat)
+lstcon_rpc_stat_reply(struct lstcon_rpc_trans *trans, struct srpc_msg *msg,
+                     struct lstcon_node *nd, struct lstcon_trans_stat *stat)
 {
-        srpc_rmsn_reply_t  *rmsn_rep;
-        srpc_debug_reply_t *dbg_rep;
-        srpc_batch_reply_t *bat_rep;
-        srpc_test_reply_t  *test_rep;
-        srpc_stat_reply_t  *stat_rep;
-        int                 rc = 0;
+       struct srpc_rmsn_reply *rmsn_rep;
+       struct srpc_debug_reply *dbg_rep;
+       struct srpc_batch_reply *bat_rep;
+       struct srpc_test_reply *test_rep;
+       struct srpc_stat_reply *stat_rep;
+       int rc = 0;
 
        switch (trans->tas_opc) {
        case LST_TRANS_SESNEW:
@@ -1023,7 +1018,7 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
                         return;
                 }
 
-                if (bat_rep->bar_status == EPERM && 
+               if (bat_rep->bar_status == EPERM &&
                    trans->tas_opc == LST_TRANS_TSBSTOP) {
                         lstcon_tsbop_stat_success(stat, 1);
                         return;
@@ -1037,12 +1032,12 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
         case LST_TRANS_TSBSRVQRY:
                 bat_rep = &msg->msg_body.bat_reply;
 
-                if (bat_rep->bar_active != 0) 
+               if (bat_rep->bar_active != 0)
                         lstcon_tsbqry_stat_run(stat, 1);
                 else
                         lstcon_tsbqry_stat_idle(stat, 1);
 
-                if (bat_rep->bar_status == 0) 
+               if (bat_rep->bar_status == 0)
                         return;
 
                 lstcon_tsbqry_stat_failure(stat, 1);
@@ -1080,22 +1075,20 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
 
         if (stat->trs_fwk_errno == 0)
                 stat->trs_fwk_errno = rc;
-
-        return;
 }
 
 int
 lstcon_rpc_trans_ndlist(struct list_head *ndlist,
                        struct list_head *translist, int transop,
                        void *arg, lstcon_rpc_cond_func_t condition,
-                       lstcon_rpc_trans_t **transpp)
+                       struct lstcon_rpc_trans **transpp)
 {
-        lstcon_rpc_trans_t *trans;
-        lstcon_ndlink_t    *ndl;
-        lstcon_node_t      *nd;
-        lstcon_rpc_t       *rpc;
-       unsigned            feats;
-        int                 rc;
+       struct lstcon_rpc_trans *trans;
+       struct lstcon_ndlink *ndl;
+       struct lstcon_node *nd;
+       struct lstcon_rpc *rpc;
+       unsigned int feats;
+       int rc;
 
         /* Creating session RPG for list of nodes */
 
@@ -1133,14 +1126,16 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
                case LST_TRANS_TSBCLIADD:
                case LST_TRANS_TSBSRVADD:
                        rc = lstcon_testrpc_prep(nd, transop, feats,
-                                                (lstcon_test_t *)arg, &rpc);
+                                                (struct lstcon_test *)arg,
+                                                &rpc);
                        break;
                case LST_TRANS_TSBRUN:
                case LST_TRANS_TSBSTOP:
                case LST_TRANS_TSBCLIQRY:
                case LST_TRANS_TSBSRVQRY:
                        rc = lstcon_batrpc_prep(nd, transop, feats,
-                                               (lstcon_tsb_hdr_t *)arg, &rpc);
+                                               (struct lstcon_tsb_hdr *)arg,
+                                               &rpc);
                        break;
                case LST_TRANS_STATQRY:
                        rc = lstcon_statrpc_prep(nd, feats, &rpc);
@@ -1169,19 +1164,19 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
         return rc;
 }
 
-void
+static void
 lstcon_rpc_pinger(void *arg)
 {
-        stt_timer_t        *ptimer = (stt_timer_t *)arg;
-        lstcon_rpc_trans_t *trans;
-        lstcon_rpc_t       *crpc;
-        srpc_msg_t         *rep;
-        srpc_debug_reqst_t *drq;
-        lstcon_ndlink_t    *ndl;
-        lstcon_node_t      *nd;
-        time_t              intv;
-        int                 count = 0;
-        int                 rc;
+       struct stt_timer *ptimer = arg;
+       struct lstcon_rpc_trans *trans;
+       struct lstcon_rpc *crpc;
+       struct srpc_msg *rep;
+       struct srpc_debug_reqst *drq;
+       struct lstcon_ndlink *ndl;
+       struct lstcon_node *nd;
+       int intv;
+       int count = 0;
+       int rc;
 
         /* RPC pinger is a special case of transaction,
          * it's called by timer at 8 seconds interval.
@@ -1193,10 +1188,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;
 
@@ -1248,13 +1243,13 @@ lstcon_rpc_pinger(void *arg)
                        lstcon_rpc_put(crpc);
                }
 
-                if (nd->nd_state != LST_NODE_ACTIVE)
-                        continue;
+               if (nd->nd_state != LST_NODE_ACTIVE)
+                       continue;
 
-                intv = cfs_duration_sec(cfs_time_sub(cfs_time_current(),
-                                                     nd->nd_stamp));
-                if (intv < (time_t)nd->nd_timeout / 2)
-                        continue;
+               intv = div_u64(ktime_ms_delta(ktime_get(), nd->nd_stamp),
+                              MSEC_PER_SEC);
+               if (intv < nd->nd_timeout / 2)
+                       continue;
 
                rc = lstcon_rpc_init(nd, SRPC_SERVICE_DEBUG,
                                     trans->tas_features, 0, 0, 1, crpc);
@@ -1281,8 +1276,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);
 }
@@ -1290,8 +1285,8 @@ lstcon_rpc_pinger(void *arg)
 int
 lstcon_rpc_pinger_start(void)
 {
-       stt_timer_t     *ptimer;
-       int              rc;
+       struct stt_timer *ptimer;
+       int rc;
 
        LASSERT(list_empty(&console_session.ses_rpc_freelist));
        LASSERT(atomic_read(&console_session.ses_rpc_counter) == 0);
@@ -1303,10 +1298,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;
 }
@@ -1322,7 +1317,7 @@ lstcon_rpc_pinger_stop(void)
         lstcon_rpc_trans_stat(console_session.ses_ping, lstcon_trans_stat());
         lstcon_rpc_trans_destroy(console_session.ses_ping);
 
-        memset(lstcon_trans_stat(), 0, sizeof(lstcon_trans_stat_t));
+       memset(lstcon_trans_stat(), 0, sizeof(struct lstcon_trans_stat));
 
         console_session.ses_ping = NULL;
 }
@@ -1330,10 +1325,10 @@ lstcon_rpc_pinger_stop(void)
 void
 lstcon_rpc_cleanup_wait(void)
 {
-       lstcon_rpc_trans_t      *trans;
-       lstcon_rpc_t            *crpc;
-       struct list_head        *pacer;
-       struct list_head         zlist;
+       struct lstcon_rpc_trans *trans;
+       struct lstcon_rpc *crpc;
+       struct list_head *pacer;
+       struct list_head zlist;
 
        /* Called with hold of global mutex */
 
@@ -1341,7 +1336,7 @@ lstcon_rpc_cleanup_wait(void)
 
        while (!list_empty(&console_session.ses_trans_list)) {
                list_for_each(pacer, &console_session.ses_trans_list) {
-                       trans = list_entry(pacer, lstcon_rpc_trans_t,
+                       trans = list_entry(pacer, struct lstcon_rpc_trans,
                                           tas_link);
 
                        CDEBUG(D_NET, "Session closed, wakeup transaction %s\n",
@@ -1354,7 +1349,7 @@ lstcon_rpc_cleanup_wait(void)
 
                CWARN("Session is shutting down, "
                      "waiting for termination of transactions\n");
-               cfs_pause(cfs_time_seconds(1));
+               schedule_timeout_uninterruptible(cfs_time_seconds(1));
 
                mutex_lock(&console_session.ses_mutex);
        }
@@ -1373,10 +1368,10 @@ lstcon_rpc_cleanup_wait(void)
        spin_unlock(&console_session.ses_rpc_lock);
 
        while (!list_empty(&zlist)) {
-               crpc = list_entry(zlist.next, lstcon_rpc_t, crp_link);
+               crpc = list_entry(zlist.next, struct lstcon_rpc, crp_link);
 
                list_del(&crpc->crp_link);
-               LIBCFS_FREE(crpc, sizeof(lstcon_rpc_t));
+               LIBCFS_FREE(crpc, sizeof(*crpc));
        }
 }
 
@@ -1403,4 +1398,3 @@ lstcon_rpc_module_fini(void)
        LASSERT(atomic_read(&console_session.ses_rpc_counter) == 0);
 }
 
-#endif