Whamcloud - gitweb
New release 2.15.64
[fs/lustre-release.git] / lnet / selftest / conrpc.c
index 39d19f0..ba0d820 100644 (file)
@@ -1,42 +1,20 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
+// SPDX-License-Identifier: GPL-2.0
+
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
  * Copyright (c) 2011, 2016, Intel Corporation.
  */
+
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lnet/selftest/conctl.c
  *
  * Console framework rpcs
  *
  * Author: Liang Zhen <liang@whamcloud.com>
  */
 
-
 #include <libcfs/libcfs.h>
 #include <lnet/lib-lnet.h>
 #include "timer.h"
@@ -116,8 +94,8 @@ lstcon_rpc_prep(struct lstcon_node *nd, int service, unsigned int feats,
        spin_lock(&console_session.ses_rpc_lock);
 
        if (!list_empty(&console_session.ses_rpc_freelist)) {
-               crpc = list_entry(console_session.ses_rpc_freelist.next,
-                                 struct lstcon_rpc, crp_link);
+               crpc = list_first_entry(&console_session.ses_rpc_freelist,
+                                       struct lstcon_rpc, crp_link);
                list_del_init(&crpc->crp_link);
        }
 
@@ -149,10 +127,10 @@ lstcon_rpc_put(struct lstcon_rpc *crpc)
        LASSERT(list_empty(&crpc->crp_link));
 
        for (i = 0; i < bulk->bk_niov; i++) {
-               if (bulk->bk_iovs[i].kiov_page == NULL)
+               if (bulk->bk_iovs[i].bv_page == NULL)
                        continue;
 
-               __free_page(bulk->bk_iovs[i].kiov_page);
+               __free_page(bulk->bk_iovs[i].bv_page);
        }
 
        srpc_client_rpc_decref(crpc->crp_rpc);
@@ -471,7 +449,7 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
        struct lstcon_rpc *crpc;
        struct srpc_msg *msg;
        struct lstcon_node *nd;
-       struct timeval tv;
+       struct timespec64 ts;
        int error;
        s64 dur;
 
@@ -499,11 +477,11 @@ lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
 
                dur = crpc->crp_stamp_ns -
                      console_session.ses_id.ses_stamp * NSEC_PER_MSEC;
-               tv = ns_to_timeval(dur);
+               ts = ns_to_timespec64(dur);
 
                if (copy_to_user(&ent->rpe_peer,
                                 &nd->nd_id, sizeof(struct lnet_process_id)) ||
-                   copy_to_user(&ent->rpe_stamp, &tv, sizeof(tv)) ||
+                   copy_to_user(&ent->rpe_stamp, &ts, sizeof(ts)) ||
                    copy_to_user(&ent->rpe_state,
                                 &nd->nd_state, sizeof(nd->nd_state)) ||
                    copy_to_user(&ent->rpe_rpc_errno, &error,
@@ -593,35 +571,39 @@ lstcon_sesrpc_prep(struct lstcon_node *nd, int transop,
        struct srpc_rmsn_reqst *rsrq;
        int rc;
 
-        switch (transop) {
-        case LST_TRANS_SESNEW:
+       switch (transop) {
+       case LST_TRANS_SESNEW:
                rc = lstcon_rpc_prep(nd, SRPC_SERVICE_MAKE_SESSION,
                                     feats, 0, 0, crpc);
-                if (rc != 0)
-                        return rc;
-
-                msrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.mksn_reqst;
-                msrq->mksn_sid     = console_session.ses_id;
-                msrq->mksn_force   = console_session.ses_force;
-               strlcpy(msrq->mksn_name, console_session.ses_name,
+               if (rc != 0)
+                       return rc;
+
+               msrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.mksn_reqst;
+               msrq->mksn_sid.ses_stamp = console_session.ses_id.ses_stamp;
+               msrq->mksn_sid.ses_nid =
+                       lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
+               msrq->mksn_force = console_session.ses_force;
+               strscpy(msrq->mksn_name, console_session.ses_name,
                        sizeof(msrq->mksn_name));
-                break;
+               break;
 
-        case LST_TRANS_SESEND:
+       case LST_TRANS_SESEND:
                rc = lstcon_rpc_prep(nd, SRPC_SERVICE_REMOVE_SESSION,
                                     feats, 0, 0, crpc);
-                if (rc != 0)
-                        return rc;
+               if (rc != 0)
+                       return rc;
 
-                rsrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.rmsn_reqst;
-                rsrq->rmsn_sid = console_session.ses_id;
-                break;
+               rsrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.rmsn_reqst;
+               rsrq->rmsn_sid.ses_stamp = console_session.ses_id.ses_stamp;
+               rsrq->rmsn_sid.ses_nid =
+                       lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
+               break;
 
-        default:
-                LBUG();
-        }
+       default:
+               LBUG();
+       }
 
-        return 0;
+       return 0;
 }
 
 int
@@ -637,7 +619,9 @@ lstcon_dbgrpc_prep(struct lstcon_node *nd, unsigned int feats,
 
         drq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.dbg_reqst;
 
-        drq->dbg_sid   = console_session.ses_id;
+       drq->dbg_sid.ses_stamp = console_session.ses_id.ses_stamp;
+       drq->dbg_sid.ses_nid =
+               lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
         drq->dbg_flags = 0;
 
         return rc;
@@ -657,7 +641,9 @@ lstcon_batrpc_prep(struct lstcon_node *nd, int transop, unsigned int feats,
 
         brq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.bat_reqst;
 
-        brq->bar_sid     = console_session.ses_id;
+       brq->bar_sid.ses_stamp = console_session.ses_id.ses_stamp;
+       brq->bar_sid.ses_nid =
+               lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
         brq->bar_bid     = tsb->tsb_id;
         brq->bar_testidx = tsb->tsb_index;
         brq->bar_opc     = transop == LST_TRANS_TSBRUN ? SRPC_BATCH_OPC_RUN :
@@ -689,14 +675,17 @@ lstcon_statrpc_prep(struct lstcon_node *nd, unsigned int feats,
 
         srq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.stat_reqst;
 
-        srq->str_sid  = console_session.ses_id;
+
+       srq->str_sid.ses_stamp = console_session.ses_id.ses_stamp;
+       srq->str_sid.ses_nid =
+               lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
         srq->str_type = 0; /* XXX remove it */
 
         return 0;
 }
 
 static struct lnet_process_id_packed *
-lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov)
+lstcon_next_id(int idx, int nkiov, struct bio_vec *kiov)
 {
        struct lnet_process_id_packed *pid;
         int                       i;
@@ -705,14 +694,14 @@ lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov)
 
         LASSERT (i < nkiov);
 
-       pid = (struct lnet_process_id_packed *)page_address(kiov[i].kiov_page);
+       pid = (struct lnet_process_id_packed *)page_address(kiov[i].bv_page);
 
         return &pid[idx % SFW_ID_PER_PAGE];
 }
 
 static int
 lstcon_dstnodes_prep(struct lstcon_group *grp, int idx,
-                     int dist, int span, int nkiov, lnet_kiov_t *kiov)
+                    int dist, int span, int nkiov, struct bio_vec *kiov)
 {
        struct lnet_process_id_packed *pid;
        struct lstcon_ndlink *ndl;
@@ -770,10 +759,15 @@ lstcon_pingrpc_prep(struct lst_test_ping_param *param,
 {
        struct test_ping_req *prq = &req->tsr_u.ping;
 
-        prq->png_size   = param->png_size;
-        prq->png_flags  = param->png_flags;
-        /* TODO dest */
-        return 0;
+       if (param) {
+               prq->png_size   = param->png_size;
+               prq->png_flags  = param->png_flags;
+       } else {
+               prq->png_size   = 0;
+               prq->png_flags  = 0;
+       }
+       /* TODO dest */
+       return 0;
 }
 
 static int
@@ -850,12 +844,12 @@ lstcon_testrpc_prep(struct lstcon_node *nd, int transop, unsigned int feats,
                              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   =
+                       bulk->bk_iovs[i].bv_offset = 0;
+                       bulk->bk_iovs[i].bv_len    = len;
+                       bulk->bk_iovs[i].bv_page   =
                                alloc_page(GFP_KERNEL);
 
-                       if (bulk->bk_iovs[i].kiov_page == NULL) {
+                       if (bulk->bk_iovs[i].bv_page == NULL) {
                                lstcon_rpc_put(*crpc);
                                return -ENOMEM;
                        }
@@ -879,19 +873,26 @@ lstcon_testrpc_prep(struct lstcon_node *nd, int transop, unsigned int feats,
                 trq->tsr_loop  = test->tes_loop;
        }
 
-        trq->tsr_sid        = console_session.ses_id;
+       trq->tsr_sid.ses_stamp = console_session.ses_id.ses_stamp;
+       trq->tsr_sid.ses_nid =
+               lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
         trq->tsr_bid        = test->tes_hdr.tsb_id;
         trq->tsr_concur     = test->tes_concur;
         trq->tsr_is_client  = (transop == LST_TRANS_TSBCLIADD) ? 1 : 0;
         trq->tsr_stop_onerr = !!test->tes_stop_onerr;
 
         switch (test->tes_type) {
-        case LST_TEST_PING:
-                trq->tsr_service = SRPC_SERVICE_PING;
-               rc = lstcon_pingrpc_prep((struct lst_test_ping_param *)
-                                        &test->tes_param[0], trq);
-               break;
+       case LST_TEST_PING: {
+               struct lst_test_ping_param *data = NULL;
+
+               trq->tsr_service = SRPC_SERVICE_PING;
+               if (test->tes_paramlen)
+                       data = ((struct lst_test_ping_param *)
+                               &test->tes_param[0]);
 
+               rc = lstcon_pingrpc_prep(data, trq);
+               break;
+       }
        case LST_TEST_BULK:
                trq->tsr_service = SRPC_SERVICE_BRW;
                if ((feats & LST_FEAT_BULK_LEN) == 0) {
@@ -1260,7 +1261,9 @@ lstcon_rpc_pinger(void *arg)
 
                 drq = &crpc->crp_rpc->crpc_reqstmsg.msg_body.dbg_reqst;
 
-                drq->dbg_sid   = console_session.ses_id;
+               drq->dbg_sid.ses_stamp = console_session.ses_id.ses_stamp;
+               drq->dbg_sid.ses_nid =
+                       lnet_nid_to_nid4(&console_session.ses_id.ses_nid);
                 drq->dbg_flags = 0;
 
                 lstcon_rpc_trans_addreq(trans, crpc);
@@ -1367,7 +1370,7 @@ lstcon_rpc_cleanup_wait(void)
        spin_unlock(&console_session.ses_rpc_lock);
 
        while (!list_empty(&zlist)) {
-               crpc = list_entry(zlist.next, struct lstcon_rpc, crp_link);
+               crpc = list_first_entry(&zlist, struct lstcon_rpc, crp_link);
 
                list_del(&crpc->crp_link);
                LIBCFS_FREE(crpc, sizeof(*crpc));