Whamcloud - gitweb
LU-4423 selftest: use jiffies_to_*() instead of cfs_duration_usec
[fs/lustre-release.git] / lnet / selftest / framework.c
index 24f2e39..032d95e 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) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -43,7 +39,7 @@
 
 #include "selftest.h"
 
-lst_sid_t LST_INVALID_SID = {LNET_NID_ANY, -1};
+struct lst_sid LST_INVALID_SID = { .ses_nid = LNET_NID_ANY, .ses_stamp = -1};
 
 static int session_timeout = 100;
 module_param(session_timeout, int, 0444);
@@ -178,8 +174,7 @@ sfw_add_session_timer (void)
         LASSERT (!sn->sn_timer_active);
 
         sn->sn_timer_active = 1;
-        timer->stt_expires = cfs_time_add(sn->sn_timeout,
-                                          cfs_time_current_sec());
+       timer->stt_expires = ktime_get_real_seconds()+ sn->sn_timeout;
         stt_add_timer(timer);
         return;
 }
@@ -257,7 +252,7 @@ sfw_session_expired (void *data)
         LASSERT (sn->sn_timer_active);
         LASSERT (sn == sfw_data.fw_session);
 
-        CWARN ("Session expired! sid: %s-"LPU64", name: %s\n",
+       CWARN ("Session expired! sid: %s-%llu, name: %s\n",
                libcfs_nid2str(sn->sn_id.ses_nid),
                sn->sn_id.ses_stamp, &sn->sn_name[0]);
 
@@ -268,7 +263,7 @@ sfw_session_expired (void *data)
 }
 
 static inline void
-sfw_init_session(sfw_session_t *sn, lst_sid_t sid,
+sfw_init_session(sfw_session_t *sn, struct lst_sid sid,
                 unsigned features, const char *name)
 {
         stt_timer_t *timer = &sn->sn_timer;
@@ -334,7 +329,7 @@ sfw_client_rpc_fini (srpc_client_rpc_t *rpc)
 }
 
 static sfw_batch_t *
-sfw_find_batch (lst_bid_t bid)
+sfw_find_batch(struct lst_bid bid)
 {
        sfw_session_t *sn = sfw_data.fw_session;
        sfw_batch_t   *bat;
@@ -350,7 +345,7 @@ sfw_find_batch (lst_bid_t bid)
 }
 
 static sfw_batch_t *
-sfw_bid2batch (lst_bid_t bid)
+sfw_bid2batch(struct lst_bid bid)
 {
         sfw_session_t *sn = sfw_data.fw_session;
         sfw_batch_t   *bat;
@@ -379,9 +374,8 @@ static int
 sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
 {
         sfw_session_t  *sn = sfw_data.fw_session;
-        sfw_counters_t *cnt = &reply->str_fw;
+       struct sfw_counters *cnt = &reply->str_fw;
         sfw_batch_t    *bat;
-        struct timeval  tv;
 
         reply->str_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
 
@@ -400,10 +394,7 @@ sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
 
         /* send over the msecs since the session was started
          - with 32 bits to send, this is ~49 days */
-        cfs_duration_usec(cfs_time_sub(cfs_time_current(),
-                                       sn->sn_started), &tv);
-
-        cnt->running_ms      = (__u32)(tv.tv_sec * 1000 + tv.tv_usec / 1000);
+       cnt->running_ms      = jiffies_to_msecs(jiffies - sn->sn_started);
        cnt->brw_errors      = atomic_read(&sn->sn_brw_errors);
        cnt->ping_errors     = atomic_read(&sn->sn_ping_errors);
        cnt->zombie_sessions = atomic_read(&sfw_data.fw_nzombies);
@@ -757,7 +748,7 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
 
         LIBCFS_ALLOC(tsi, sizeof(*tsi));
         if (tsi == NULL) {
-                CERROR ("Can't allocate test instance for batch: "LPU64"\n",
+               CERROR ("Can't allocate test instance for batch: %llu\n",
                         tsb->bat_id.bat_id);
                 return -ENOMEM;
         }
@@ -793,14 +784,14 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
         LASSERT (bk != NULL);
         LASSERT (bk->bk_niov * SFW_ID_PER_PAGE >= (unsigned int)ndest);
        LASSERT((unsigned int)bk->bk_len >=
-               sizeof(lnet_process_id_packed_t) * ndest);
+               sizeof(struct lnet_process_id_packed) * ndest);
 
        sfw_unpack_addtest_req(msg);
         memcpy(&tsi->tsi_u, &req->tsr_u, sizeof(tsi->tsi_u));
 
         for (i = 0; i < ndest; i++) {
-                lnet_process_id_packed_t *dests;
-                lnet_process_id_packed_t  id;
+               struct lnet_process_id_packed *dests;
+               struct lnet_process_id_packed  id;
                 int                       j;
 
                dests = page_address(bk->bk_iovs[i / SFW_ID_PER_PAGE].kiov_page);
@@ -918,7 +909,7 @@ sfw_test_rpc_done (srpc_client_rpc_t *rpc)
 }
 
 int
-sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer,
+sfw_create_test_rpc(sfw_test_unit_t *tsu, struct lnet_process_id peer,
                    unsigned features, int nblk, int blklen,
                    srpc_client_rpc_t **rpcpp)
 {
@@ -1017,7 +1008,7 @@ sfw_run_batch (sfw_batch_t *tsb)
         sfw_test_instance_t *tsi;
 
         if (sfw_batch_active(tsb)) {
-                CDEBUG(D_NET, "Batch already active: "LPU64" (%d)\n",
+               CDEBUG(D_NET, "Batch already active: %llu (%d)\n",
                       tsb->bat_id.bat_id, atomic_read(&tsb->bat_nactive));
                 return 0;
         }
@@ -1037,7 +1028,8 @@ sfw_run_batch (sfw_batch_t *tsb)
                        wi = &tsu->tsu_worker;
                        swi_init_workitem(wi, tsu, sfw_run_test,
                                          lst_sched_test[\
-                                         lnet_cpt_of_nid(tsu->tsu_dest.nid)]);
+                                         lnet_cpt_of_nid(tsu->tsu_dest.nid,
+                                                         NULL)]);
                        swi_schedule_workitem(wi);
                }
        }
@@ -1052,7 +1044,7 @@ sfw_stop_batch (sfw_batch_t *tsb, int force)
         srpc_client_rpc_t   *rpc;
 
         if (!sfw_batch_active(tsb)) {
-                CDEBUG(D_NET, "Batch "LPU64" inactive\n", tsb->bat_id.bat_id);
+               CDEBUG(D_NET, "Batch %llu inactive\n", tsb->bat_id.bat_id);
                 return 0;
         }
 
@@ -1125,7 +1117,7 @@ sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len,
        LASSERT(rpc->srpc_bulk == NULL);
        LASSERT(npages > 0 && npages <= LNET_MAX_IOV);
 
-       rpc->srpc_bulk = srpc_alloc_bulk(cpt, npages, len, sink);
+       rpc->srpc_bulk = srpc_alloc_bulk(cpt, 0, npages, len, sink);
        if (rpc->srpc_bulk == NULL)
                return -ENOMEM;
 
@@ -1181,10 +1173,10 @@ sfw_add_test (srpc_server_rpc_t *rpc)
                int     len;
 
                if ((sn->sn_features & LST_FEAT_BULK_LEN) == 0) {
-                       len = npg * PAGE_CACHE_SIZE;
+                       len = npg * PAGE_SIZE;
 
                } else  {
-                       len = sizeof(lnet_process_id_packed_t) *
+                       len = sizeof(struct lnet_process_id_packed) *
                              request->tsr_ndest;
                }
 
@@ -1398,7 +1390,7 @@ sfw_bulk_ready(struct srpc_server_rpc *rpc, int status)
 }
 
 srpc_client_rpc_t *
-sfw_create_rpc(lnet_process_id_t peer, int service,
+sfw_create_rpc(struct lnet_process_id peer, int service,
               unsigned features, int nbulkiov, int bulklen,
               void (*done)(srpc_client_rpc_t *), void *priv)
 {