Whamcloud - gitweb
LU-4423 selftest: use jiffies_to_*() instead of cfs_duration_usec
[fs/lustre-release.git] / lnet / selftest / conrpc.c
index 37455a2..749714a 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>
@@ -49,7 +44,7 @@
 #include "console.h"
 
 void lstcon_rpc_stat_reply(lstcon_rpc_trans_t *, srpc_msg_t *,
-                          lstcon_node_t *, lstcon_trans_stat_t *);
+                          lstcon_node_t *, struct lstcon_trans_stat *);
 
 static void
 lstcon_rpc_done(srpc_client_rpc_t *rpc)
@@ -89,32 +84,32 @@ lstcon_rpc_done(srpc_client_rpc_t *rpc)
        spin_unlock(&rpc->crpc_lock);
 }
 
-int
+static int
 lstcon_rpc_init(lstcon_node_t *nd, int service, unsigned feats,
                int bulk_npg, int bulk_len, int embedded, lstcon_rpc_t *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;
+       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;
-        CFS_INIT_LIST_HEAD(&crpc->crp_link);
+       INIT_LIST_HEAD(&crpc->crp_link);
 
        atomic_inc(&console_session.ses_rpc_counter);
 
-        return 0;
+       return 0;
 }
 
-int
+static int
 lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats,
                int bulk_npg, int bulk_len, lstcon_rpc_t **crpcpp)
 {
@@ -123,10 +118,10 @@ lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats,
 
        spin_lock(&console_session.ses_rpc_lock);
 
-       if (!cfs_list_empty(&console_session.ses_rpc_freelist)) {
-               crpc = cfs_list_entry(console_session.ses_rpc_freelist.next,
-                                     lstcon_rpc_t, crp_link);
-               cfs_list_del_init(&crpc->crp_link);
+       if (!list_empty(&console_session.ses_rpc_freelist)) {
+               crpc = list_entry(console_session.ses_rpc_freelist.next,
+                                 lstcon_rpc_t, crp_link);
+               list_del_init(&crpc->crp_link);
        }
 
        spin_unlock(&console_session.ses_rpc_lock);
@@ -151,19 +146,19 @@ lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats,
 void
 lstcon_rpc_put(lstcon_rpc_t *crpc)
 {
-        srpc_bulk_t *bulk = &crpc->crp_rpc->crpc_bulk;
-        int          i;
+       srpc_bulk_t *bulk = &crpc->crp_rpc->crpc_bulk;
+       int          i;
 
-        LASSERT (cfs_list_empty(&crpc->crp_link));
+       LASSERT(list_empty(&crpc->crp_link));
 
-        for (i = 0; i < bulk->bk_niov; i++) {
-                if (bulk->bk_iovs[i].kiov_page == NULL)
-                        continue;
+       for (i = 0; i < bulk->bk_niov; i++) {
+               if (bulk->bk_iovs[i].kiov_page == NULL)
+                       continue;
 
                __free_page(bulk->bk_iovs[i].kiov_page);
-        }
+       }
 
-        srpc_client_rpc_decref(crpc->crp_rpc);
+       srpc_client_rpc_decref(crpc->crp_rpc);
 
        if (crpc->crp_embedded) {
                /* embedded RPC, don't recycle it */
@@ -173,8 +168,8 @@ lstcon_rpc_put(lstcon_rpc_t *crpc)
        } else {
                spin_lock(&console_session.ses_rpc_lock);
 
-               cfs_list_add(&crpc->crp_link,
-                            &console_session.ses_rpc_freelist);
+               list_add(&crpc->crp_link,
+                        &console_session.ses_rpc_freelist);
 
                spin_unlock(&console_session.ses_rpc_lock);
        }
@@ -183,7 +178,7 @@ lstcon_rpc_put(lstcon_rpc_t *crpc)
        atomic_dec(&console_session.ses_rpc_counter);
 }
 
-void
+static void
 lstcon_rpc_post(lstcon_rpc_t *crpc)
 {
         lstcon_rpc_trans_t *trans = crpc->crp_trans;
@@ -236,36 +231,35 @@ lstcon_rpc_trans_name(int transop)
 }
 
 int
-lstcon_rpc_trans_prep(cfs_list_t *translist,
-                      int transop, lstcon_rpc_trans_t **transpp)
+lstcon_rpc_trans_prep(struct list_head *translist, int transop,
+                     lstcon_rpc_trans_t **transpp)
 {
-        lstcon_rpc_trans_t *trans;
-
-        if (translist != NULL) {
-                cfs_list_for_each_entry_typed(trans, translist,
-                                              lstcon_rpc_trans_t, tas_link) {
-                        /* Can't enqueue two private transaction on
-                         * the same object */
-                        if ((trans->tas_opc & transop) == LST_TRANS_PRIVATE)
-                                return -EPERM;
-                }
-        }
+       lstcon_rpc_trans_t *trans;
+
+       if (translist != NULL) {
+               list_for_each_entry(trans, translist, tas_link) {
+                       /* Can't enqueue two private transaction on
+                        * the same object */
+                       if ((trans->tas_opc & transop) == LST_TRANS_PRIVATE)
+                               return -EPERM;
+               }
+       }
 
-        /* create a trans group */
-        LIBCFS_ALLOC(trans, sizeof(*trans));
-        if (trans == NULL)
-                return -ENOMEM;
+       /* create a trans group */
+       LIBCFS_ALLOC(trans, sizeof(*trans));
+       if (trans == NULL)
+               return -ENOMEM;
 
-        trans->tas_opc = transop;
+       trans->tas_opc = transop;
 
        if (translist == NULL)
-                CFS_INIT_LIST_HEAD(&trans->tas_olink);
-        else
-                cfs_list_add_tail(&trans->tas_olink, translist);
+               INIT_LIST_HEAD(&trans->tas_olink);
+       else
+               list_add_tail(&trans->tas_olink, translist);
 
-        cfs_list_add_tail(&trans->tas_link, &console_session.ses_trans_list);
+       list_add_tail(&trans->tas_link, &console_session.ses_trans_list);
 
-       CFS_INIT_LIST_HEAD(&trans->tas_rpcs_list);
+       INIT_LIST_HEAD(&trans->tas_rpcs_list);
        atomic_set(&trans->tas_remaining, 0);
        init_waitqueue_head(&trans->tas_waitq);
 
@@ -280,8 +274,8 @@ lstcon_rpc_trans_prep(cfs_list_t *translist,
 void
 lstcon_rpc_trans_addreq(lstcon_rpc_trans_t *trans, lstcon_rpc_t *crpc)
 {
-        cfs_list_add_tail(&crpc->crp_link, &trans->tas_rpcs_list);
-        crpc->crp_trans = trans;
+       list_add_tail(&crpc->crp_link, &trans->tas_rpcs_list);
+       crpc->crp_trans = trans;
 }
 
 void
@@ -291,8 +285,7 @@ lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error)
        lstcon_rpc_t      *crpc;
        lstcon_node_t     *nd;
 
-       cfs_list_for_each_entry_typed(crpc, &trans->tas_rpcs_list,
-                                     lstcon_rpc_t, crp_link) {
+       list_for_each_entry(crpc, &trans->tas_rpcs_list, crp_link) {
                rpc = crpc->crp_rpc;
 
                spin_lock(&rpc->crpc_lock);
@@ -329,9 +322,9 @@ lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error)
 static int
 lstcon_rpc_trans_check(lstcon_rpc_trans_t *trans)
 {
-        if (console_session.ses_shutdown &&
-            !cfs_list_empty(&trans->tas_olink)) /* Not an end session RPC */
-                return 1;
+       if (console_session.ses_shutdown &&
+           !list_empty(&trans->tas_olink)) /* Not an end session RPC */
+               return 1;
 
        return (atomic_read(&trans->tas_remaining) == 0) ? 1: 0;
 }
@@ -339,25 +332,24 @@ lstcon_rpc_trans_check(lstcon_rpc_trans_t *trans)
 int
 lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
 {
-        lstcon_rpc_t  *crpc;
-        int            rc;
+       lstcon_rpc_t  *crpc;
+       int            rc;
 
-        if (cfs_list_empty(&trans->tas_rpcs_list))
+       if (list_empty(&trans->tas_rpcs_list))
                 return 0;
 
-        if (timeout < LST_TRANS_MIN_TIMEOUT)
-                timeout = LST_TRANS_MIN_TIMEOUT;
+       if (timeout < LST_TRANS_MIN_TIMEOUT)
+               timeout = LST_TRANS_MIN_TIMEOUT;
 
-        CDEBUG(D_NET, "Transaction %s started\n",
-               lstcon_rpc_trans_name(trans->tas_opc));
+       CDEBUG(D_NET, "Transaction %s started\n",
+       lstcon_rpc_trans_name(trans->tas_opc));
 
-        /* post all requests */
-        cfs_list_for_each_entry_typed (crpc, &trans->tas_rpcs_list,
-                                       lstcon_rpc_t, crp_link) {
-                LASSERT (!crpc->crp_posted);
+       /* post all requests */
+       list_for_each_entry(crpc, &trans->tas_rpcs_list, crp_link) {
+               LASSERT(!crpc->crp_posted);
 
-                lstcon_rpc_post(crpc);
-        }
+               lstcon_rpc_post(crpc);
+       }
 
        mutex_unlock(&console_session.ses_mutex);
 
@@ -388,7 +380,7 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
         return rc;
 }
 
-int
+static int
 lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
 {
         lstcon_node_t        *nd  = crpc->crp_node;
@@ -426,21 +418,20 @@ 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(lstcon_rpc_trans_t *trans, struct lstcon_trans_stat *stat)
 {
-        lstcon_rpc_t      *crpc;
-        srpc_msg_t        *rep;
-        int                error;
+       lstcon_rpc_t    *crpc;
+       srpc_msg_t      *rep;
+       int              error;
 
-        LASSERT (stat != NULL);
+       LASSERT(stat != NULL);
 
-        memset(stat, 0, sizeof(*stat));
+       memset(stat, 0, sizeof(*stat));
 
-        cfs_list_for_each_entry_typed(crpc, &trans->tas_rpcs_list,
-                                      lstcon_rpc_t, 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 != 0);
 
                 error = lstcon_rpc_get_reply(crpc, &rep);
                 if (error != 0) {
@@ -474,12 +465,12 @@ lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat)
 
 int
 lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
-                             cfs_list_t *head_up,
-                             lstcon_rpc_readent_func_t readent)
+                            struct list_head __user *head_up,
+                            lstcon_rpc_readent_func_t readent)
 {
-        cfs_list_t            tmp;
-        cfs_list_t           *next;
-        lstcon_rpc_ent_t     *ent;
+       struct list_head      tmp;
+       struct list_head     __user *next;
+       struct lstcon_rpc_ent     *ent;
         srpc_generic_reply_t *rep;
         lstcon_rpc_t         *crpc;
         srpc_msg_t           *msg;
@@ -488,24 +479,23 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
         struct timeval        tv;
         int                   error;
 
-        LASSERT (head_up != NULL);
+       LASSERT(head_up != NULL);
 
-        next = head_up;
+       next = head_up;
 
-        cfs_list_for_each_entry_typed(crpc, &trans->tas_rpcs_list,
-                                      lstcon_rpc_t, crp_link) {
+       list_for_each_entry(crpc, &trans->tas_rpcs_list, crp_link) {
                if (copy_from_user(&tmp, next,
-                                       sizeof(cfs_list_t)))
-                        return -EFAULT;
+                                  sizeof(struct list_head)))
+                       return -EFAULT;
 
-                if (tmp.next == head_up)
-                        return 0;
+               if (tmp.next == head_up)
+                       return 0;
 
-                next = tmp.next;
+               next = tmp.next;
 
-                ent = cfs_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 != 0);
 
                 error = lstcon_rpc_get_reply(crpc, &msg);
 
@@ -513,10 +503,10 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
 
                 dur = (cfs_duration_t)cfs_time_sub(crpc->crp_stamp,
                       (cfs_time_t)console_session.ses_id.ses_stamp);
-                cfs_duration_usec(dur, &tv);
+               jiffies_to_timeval(dur, &tv);
 
                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)) ||
@@ -531,7 +521,7 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
                rep = (srpc_generic_reply_t *)&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;
@@ -550,15 +540,13 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
 void
 lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
 {
-        srpc_client_rpc_t *rpc;
-        lstcon_rpc_t      *crpc;
-        lstcon_rpc_t      *tmp;
-        int                count = 0;
+       srpc_client_rpc_t *rpc;
+       lstcon_rpc_t      *crpc;
+       lstcon_rpc_t      *tmp;
+       int                count = 0;
 
-        cfs_list_for_each_entry_safe_typed(crpc, tmp,
-                                           &trans->tas_rpcs_list,
-                                           lstcon_rpc_t, crp_link) {
-                rpc = crpc->crp_rpc;
+       list_for_each_entry_safe(crpc, tmp, &trans->tas_rpcs_list, crp_link) {
+               rpc = crpc->crp_rpc;
 
                spin_lock(&rpc->crpc_lock);
 
@@ -566,41 +554,41 @@ lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
                if (!crpc->crp_posted || crpc->crp_finished) {
                        spin_unlock(&rpc->crpc_lock);
 
-                        cfs_list_del_init(&crpc->crp_link);
-                        lstcon_rpc_put(crpc);
+                       list_del_init(&crpc->crp_link);
+                       lstcon_rpc_put(crpc);
 
-                        continue;
-                }
+                       continue;
+               }
 
-                /* rpcs can be still not callbacked (even LNetMDUnlink is called)
-                 * because huge timeout for inaccessible network, don't make
-                 * user wait for them, just abandon them, they will be recycled
-                 * in callback */
+               /* rpcs can be still not callbacked (even LNetMDUnlink is
+                * called) because huge timeout for inaccessible network,
+                * don't make user wait for them, just abandon them, they
+                * will be recycled in callback */
 
-                LASSERT (crpc->crp_status != 0);
+               LASSERT(crpc->crp_status != 0);
 
-                crpc->crp_node  = NULL;
-                crpc->crp_trans = NULL;
-                cfs_list_del_init(&crpc->crp_link);
-                count ++;
+               crpc->crp_node  = NULL;
+               crpc->crp_trans = NULL;
+               list_del_init(&crpc->crp_link);
+               count++;
 
                spin_unlock(&rpc->crpc_lock);
 
                atomic_dec(&trans->tas_remaining);
-        }
+       }
 
-       LASSERT (atomic_read(&trans->tas_remaining) == 0);
+       LASSERT(atomic_read(&trans->tas_remaining) == 0);
 
-        cfs_list_del(&trans->tas_link);
-        if (!cfs_list_empty(&trans->tas_olink))
-                cfs_list_del(&trans->tas_olink);
+       list_del(&trans->tas_link);
+       if (!list_empty(&trans->tas_olink))
+               list_del(&trans->tas_olink);
 
-        CDEBUG(D_NET, "Transaction %s destroyed with %d pending RPCs\n",
-               lstcon_rpc_trans_name(trans->tas_opc), count);
+       CDEBUG(D_NET, "Transaction %s destroyed with %d pending RPCs\n",
+              lstcon_rpc_trans_name(trans->tas_opc), count);
 
-        LIBCFS_FREE(trans, sizeof(*trans));
+       LIBCFS_FREE(trans, sizeof(*trans));
 
-        return;
+       return;
 }
 
 int
@@ -621,8 +609,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:
@@ -711,26 +699,26 @@ 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
+static int
 lstcon_dstnodes_prep(lstcon_group_t *grp, int idx,
                      int dist, int span, int nkiov, lnet_kiov_t *kiov)
 {
-        lnet_process_id_packed_t *pid;
+       struct lnet_process_id_packed *pid;
         lstcon_ndlink_t          *ndl;
         lstcon_node_t            *nd;
         int                       start;
@@ -747,43 +735,41 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx,
         start = ((idx / dist) * span) % grp->grp_nnode;
         end   = ((idx / dist) * span + span - 1) % grp->grp_nnode;
 
-        cfs_list_for_each_entry_typed(ndl, &grp->grp_ndl_list,
-                                      lstcon_ndlink_t, ndl_link) {
-                nd = ndl->ndl_node;
-                if (i < start) {
-                        i ++;
-                        continue;
-                }
+       list_for_each_entry(ndl, &grp->grp_ndl_list, ndl_link) {
+               nd = ndl->ndl_node;
+               if (i < start) {
+                       i++;
+                       continue;
+               }
 
-                if (i > (end >= start ? end: grp->grp_nnode))
-                        break;
+               if (i > (end >= start ? end : grp->grp_nnode))
+                       break;
 
-                pid = lstcon_next_id((i - start), nkiov, kiov);
-                pid->nid = nd->nd_id.nid;
-                pid->pid = nd->nd_id.pid;
-                i++;
-        }
+               pid = lstcon_next_id((i - start), nkiov, kiov);
+               pid->nid = nd->nd_id.nid;
+               pid->pid = nd->nd_id.pid;
+               i++;
+       }
 
-        if (start <= end) /* done */
-                return 0;
+       if (start <= end)       /* done */
+               return 0;
 
-        cfs_list_for_each_entry_typed(ndl, &grp->grp_ndl_list,
-                                      lstcon_ndlink_t, ndl_link) {
-                if (i > grp->grp_nnode + end)
-                        break;
+       list_for_each_entry(ndl, &grp->grp_ndl_list, ndl_link) {
+               if (i > grp->grp_nnode + end)
+                       break;
 
-                nd = ndl->ndl_node;
-                pid = lstcon_next_id((i - start), nkiov, kiov);
-                pid->nid = nd->nd_id.nid;
-                pid->pid = nd->nd_id.pid;
-                i++;
-        }
+               nd = ndl->ndl_node;
+               pid = lstcon_next_id((i - start), nkiov, kiov);
+               pid->nid = nd->nd_id.nid;
+               pid->pid = nd->nd_id.pid;
+               i++;
+       }
 
-        return 0;
+       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, srpc_test_reqst_t *req)
 {
         test_ping_req_t *prq = &req->tsr_u.ping;
 
@@ -793,28 +779,29 @@ 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, srpc_test_reqst_t *req)
 {
        test_bulk_req_t *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,
+                      srpc_test_reqst_t *req)
 {
        test_bulk_req_v1_t *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;
 }
@@ -835,8 +822,8 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
        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);
@@ -862,13 +849,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);
@@ -892,7 +879,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;
@@ -903,18 +890,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;
@@ -926,7 +914,7 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
         return rc;
 }
 
-int
+static int
 lstcon_sesnew_stat_reply(lstcon_rpc_trans_t *trans,
                         lstcon_node_t *nd, srpc_msg_t *reply)
 {
@@ -975,7 +963,7 @@ 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_node_t *nd, struct lstcon_trans_stat *stat)
 {
         srpc_rmsn_reply_t  *rmsn_rep;
         srpc_debug_reply_t *dbg_rep;
@@ -1032,7 +1020,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;
@@ -1046,12 +1034,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);
@@ -1094,10 +1082,10 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
 }
 
 int
-lstcon_rpc_trans_ndlist(cfs_list_t *ndlist,
-                        cfs_list_t *translist, int transop,
-                        void *arg, lstcon_rpc_cond_func_t condition,
-                        lstcon_rpc_trans_t **transpp)
+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)
 {
         lstcon_rpc_trans_t *trans;
         lstcon_ndlink_t    *ndl;
@@ -1115,7 +1103,7 @@ lstcon_rpc_trans_ndlist(cfs_list_t *ndlist,
         }
 
        feats = trans->tas_features;
-        cfs_list_for_each_entry_typed(ndl, ndlist, lstcon_ndlink_t, ndl_link) {
+       list_for_each_entry(ndl, ndlist, ndl_link) {
                 rc = condition == NULL ? 1 :
                      condition(transop, ndl->ndl_node, arg);
 
@@ -1178,7 +1166,7 @@ lstcon_rpc_trans_ndlist(cfs_list_t *ndlist,
         return rc;
 }
 
-void
+static void
 lstcon_rpc_pinger(void *arg)
 {
         stt_timer_t        *ptimer = (stt_timer_t *)arg;
@@ -1188,7 +1176,7 @@ lstcon_rpc_pinger(void *arg)
         srpc_debug_reqst_t *drq;
         lstcon_ndlink_t    *ndl;
         lstcon_node_t      *nd;
-        time_t              intv;
+       int intv;
         int                 count = 0;
         int                 rc;
 
@@ -1202,18 +1190,17 @@ 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;
+       trans = console_session.ses_ping;
 
-        LASSERT (trans != NULL);
+       LASSERT(trans != NULL);
 
-        cfs_list_for_each_entry_typed(ndl, &console_session.ses_ndl_list,
-                                      lstcon_ndlink_t, ndl_link) {
-                nd = ndl->ndl_node;
+       list_for_each_entry(ndl, &console_session.ses_ndl_list, ndl_link) {
+               nd = ndl->ndl_node;
 
                 if (console_session.ses_expired) {
                         /* idle console, end session on all nodes */
@@ -1235,9 +1222,9 @@ lstcon_rpc_pinger(void *arg)
 
                 crpc = &nd->nd_ping;
 
-                if (crpc->crp_rpc != NULL) {
-                        LASSERT (crpc->crp_trans == trans);
-                        LASSERT (!cfs_list_empty(&crpc->crp_link));
+               if (crpc->crp_rpc != NULL) {
+                       LASSERT(crpc->crp_trans == trans);
+                       LASSERT(!list_empty(&crpc->crp_link));
 
                        spin_lock(&crpc->crp_rpc->crpc_lock);
 
@@ -1251,19 +1238,18 @@ lstcon_rpc_pinger(void *arg)
 
                        spin_unlock(&crpc->crp_rpc->crpc_lock);
 
-                        lstcon_rpc_get_reply(crpc, &rep);
+                       lstcon_rpc_get_reply(crpc, &rep);
 
-                        cfs_list_del_init(&crpc->crp_link);
+                       list_del_init(&crpc->crp_link);
 
-                        lstcon_rpc_put(crpc);
-                }
+                       lstcon_rpc_put(crpc);
+               }
 
                 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)
+               intv = cfs_duration_sec(jiffies - nd->nd_stamp);
+               if (intv < nd->nd_timeout / 2)
                         continue;
 
                rc = lstcon_rpc_init(nd, SRPC_SERVICE_DEBUG,
@@ -1281,7 +1267,7 @@ lstcon_rpc_pinger(void *arg)
                 lstcon_rpc_trans_addreq(trans, crpc);
                 lstcon_rpc_post(crpc);
 
-                count ++;
+               count++;
         }
 
         if (console_session.ses_expired) {
@@ -1291,8 +1277,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,11 +1286,11 @@ lstcon_rpc_pinger(void *arg)
 int
 lstcon_rpc_pinger_start(void)
 {
-        stt_timer_t    *ptimer;
-        int             rc;
+       stt_timer_t     *ptimer;
+       int              rc;
 
-        LASSERT (cfs_list_empty(&console_session.ses_rpc_freelist));
-       LASSERT (atomic_read(&console_session.ses_rpc_counter) == 0);
+       LASSERT(list_empty(&console_session.ses_rpc_freelist));
+       LASSERT(atomic_read(&console_session.ses_rpc_counter) == 0);
 
         rc = lstcon_rpc_trans_prep(NULL, LST_TRANS_SESPING,
                                    &console_session.ses_ping);
@@ -1313,10 +1299,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;
 }
@@ -1332,7 +1318,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;
 }
@@ -1340,19 +1326,19 @@ lstcon_rpc_pinger_stop(void)
 void
 lstcon_rpc_cleanup_wait(void)
 {
-        lstcon_rpc_trans_t *trans;
-        lstcon_rpc_t       *crpc;
-        cfs_list_t         *pacer;
-        cfs_list_t          zlist;
+       lstcon_rpc_trans_t      *trans;
+       lstcon_rpc_t            *crpc;
+       struct list_head        *pacer;
+       struct list_head         zlist;
 
-        /* Called with hold of global mutex */
+       /* Called with hold of global mutex */
 
-        LASSERT (console_session.ses_shutdown);
+       LASSERT(console_session.ses_shutdown);
 
-        while (!cfs_list_empty(&console_session.ses_trans_list)) { 
-                cfs_list_for_each(pacer, &console_session.ses_trans_list) {
-                        trans = cfs_list_entry(pacer, lstcon_rpc_trans_t,
-                                               tas_link);
+       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,
+                                          tas_link);
 
                        CDEBUG(D_NET, "Session closed, wakeup transaction %s\n",
                               lstcon_rpc_trans_name(trans->tas_opc));
@@ -1364,10 +1350,11 @@ lstcon_rpc_cleanup_wait(void)
 
                CWARN("Session is shutting down, "
                      "waiting for termination of transactions\n");
-               cfs_pause(cfs_time_seconds(1));
+               set_current_state(TASK_UNINTERRUPTIBLE);
+               schedule_timeout(cfs_time_seconds(1));
 
                mutex_lock(&console_session.ses_mutex);
-        }
+       }
 
        spin_lock(&console_session.ses_rpc_lock);
 
@@ -1377,23 +1364,23 @@ lstcon_rpc_cleanup_wait(void)
                        "waiting for %d console RPCs to being recycled\n",
                       atomic_read(&console_session.ses_rpc_counter));
 
-        cfs_list_add(&zlist, &console_session.ses_rpc_freelist);
-        cfs_list_del_init(&console_session.ses_rpc_freelist);
+       list_add(&zlist, &console_session.ses_rpc_freelist);
+       list_del_init(&console_session.ses_rpc_freelist);
 
        spin_unlock(&console_session.ses_rpc_lock);
 
-        while (!cfs_list_empty(&zlist)) {
-                crpc = cfs_list_entry(zlist.next, lstcon_rpc_t, crp_link);
+       while (!list_empty(&zlist)) {
+               crpc = list_entry(zlist.next, lstcon_rpc_t, crp_link);
 
-                cfs_list_del(&crpc->crp_link);
-                LIBCFS_FREE(crpc, sizeof(lstcon_rpc_t));
-        }
+               list_del(&crpc->crp_link);
+               LIBCFS_FREE(crpc, sizeof(lstcon_rpc_t));
+       }
 }
 
 int
 lstcon_rpc_module_init(void)
 {
-        CFS_INIT_LIST_HEAD(&console_session.ses_ping_timer.stt_list);
+       INIT_LIST_HEAD(&console_session.ses_ping_timer.stt_list);
         console_session.ses_ping_timer.stt_func = lstcon_rpc_pinger;
         console_session.ses_ping_timer.stt_data = &console_session.ses_ping_timer;
 
@@ -1401,7 +1388,7 @@ lstcon_rpc_module_init(void)
 
        spin_lock_init(&console_session.ses_rpc_lock);
        atomic_set(&console_session.ses_rpc_counter, 0);
-       CFS_INIT_LIST_HEAD(&console_session.ses_rpc_freelist);
+       INIT_LIST_HEAD(&console_session.ses_rpc_freelist);
 
        return 0;
 }
@@ -1409,8 +1396,7 @@ lstcon_rpc_module_init(void)
 void
 lstcon_rpc_module_fini(void)
 {
-        LASSERT (cfs_list_empty(&console_session.ses_rpc_freelist));
-       LASSERT (atomic_read(&console_session.ses_rpc_counter) == 0);
+       LASSERT(list_empty(&console_session.ses_rpc_freelist));
+       LASSERT(atomic_read(&console_session.ses_rpc_counter) == 0);
 }
 
-#endif