Whamcloud - gitweb
LU-4423 lnet: use 64-bit time for selftest
[fs/lustre-release.git] / lnet / selftest / rpc.c
index 8e2cfbe..4079698 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, 2015, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -59,7 +55,7 @@ static struct smoketest_rpc {
        srpc_service_t  *rpc_services[SRPC_SERVICE_MAX_ID + 1];
        lnet_handle_eq_t rpc_lnet_eq;   /* _the_ LNet event queue */
        srpc_state_t     rpc_state;
-       srpc_counters_t  rpc_counters;
+       struct srpc_counters     rpc_counters;
        __u64            rpc_matchbits; /* matchbits counter */
 } srpc_data;
 
@@ -71,16 +67,16 @@ srpc_serv_portal(int svc_id)
 }
 
 /* forward ref's */
-int srpc_handle_rpc (swi_workitem_t *wi);
+int srpc_handle_rpc(swi_workitem_t *wi);
 
-void srpc_get_counters (srpc_counters_t *cnt)
+void srpc_get_counters(struct srpc_counters *cnt)
 {
        spin_lock(&srpc_data.rpc_glock);
        *cnt = srpc_data.rpc_counters;
        spin_unlock(&srpc_data.rpc_glock);
 }
 
-void srpc_set_counters (const srpc_counters_t *cnt)
+void srpc_set_counters(const struct srpc_counters *cnt)
 {
        spin_lock(&srpc_data.rpc_glock);
        srpc_data.rpc_counters = *cnt;
@@ -88,14 +84,12 @@ void srpc_set_counters (const srpc_counters_t *cnt)
 }
 
 static int
-srpc_add_bulk_page(srpc_bulk_t *bk, struct page *pg, int i, int nob)
+srpc_add_bulk_page(srpc_bulk_t *bk, struct page *pg, int i, int off, int nob)
 {
-       nob = min(nob, (int)PAGE_CACHE_SIZE);
-
-       LASSERT(nob > 0);
-       LASSERT(i >= 0 && i < bk->bk_niov);
+       LASSERT(off < PAGE_SIZE);
+       LASSERT(nob > 0 && nob <= PAGE_SIZE);
 
-       bk->bk_iovs[i].kiov_offset = 0;
+       bk->bk_iovs[i].kiov_offset = off;
        bk->bk_iovs[i].kiov_page   = pg;
        bk->bk_iovs[i].kiov_len    = nob;
        return nob;
@@ -121,7 +115,8 @@ srpc_free_bulk (srpc_bulk_t *bk)
 }
 
 srpc_bulk_t *
-srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
+srpc_alloc_bulk(int cpt, unsigned bulk_off, unsigned bulk_npg,
+               unsigned bulk_len, int sink)
 {
        srpc_bulk_t  *bk;
        int           i;
@@ -151,8 +146,12 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
                        return NULL;
                }
 
-               nob = srpc_add_bulk_page(bk, pg, i, bulk_len);
+               nob = min_t(unsigned, bulk_off + bulk_len, PAGE_SIZE) -
+                     bulk_off;
+
+               srpc_add_bulk_page(bk, pg, i, bulk_off, nob);
                bulk_len -= nob;
+               bulk_off = 0;
        }
 
        return bk;
@@ -385,7 +384,7 @@ srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf,
         }
 
         CDEBUG (D_NET,
-                "Posted passive RDMA: peer %s, portal %d, matchbits "LPX64"\n",
+               "Posted passive RDMA: peer %s, portal %d, matchbits %#llx\n",
                 libcfs_id2str(peer), portal, matchbits);
         return 0;
 }
@@ -425,7 +424,7 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len,
         }
 
         if (rc != 0) {
-                CERROR ("LNet%s(%s, %d, "LPD64") failed: %d\n",
+               CERROR ("LNet%s(%s, %d, %lld) failed: %d\n",
                         ((options & LNET_MD_OP_PUT) != 0) ? "Put" : "Get",
                         libcfs_id2str(peer), portal, matchbits, rc);
 
@@ -436,7 +435,7 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len,
                 LASSERT (rc == 0);
         } else {
                 CDEBUG (D_NET,
-                        "Posted active RDMA: peer %s, portal %u, matchbits "LPX64"\n",
+                       "Posted active RDMA: peer %s, portal %u, matchbits %#llx\n",
                         libcfs_id2str(peer), portal, matchbits);
         }
         return 0;
@@ -554,7 +553,7 @@ srpc_add_buffer(struct swi_workitem *wi)
        }
 
        if (rc != 0) {
-               scd->scd_buf_err_stamp = cfs_time_current_sec();
+               scd->scd_buf_err_stamp = ktime_get_real_seconds();
                scd->scd_buf_err = rc;
 
                LASSERT(scd->scd_buf_posting > 0);
@@ -1092,8 +1091,7 @@ srpc_add_client_rpc_timer(srpc_client_rpc_t *rpc)
        INIT_LIST_HEAD(&timer->stt_list);
        timer->stt_data    = rpc;
        timer->stt_func    = srpc_client_rpc_expired;
-       timer->stt_expires = cfs_time_add(rpc->crpc_timeout,
-                                         cfs_time_current_sec());
+       timer->stt_expires = ktime_get_real_seconds() + rpc->crpc_timeout;
        stt_add_timer(timer);
        return;
 }
@@ -1483,7 +1481,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
                }
 
                if (scd->scd_buf_err_stamp != 0 &&
-                   scd->scd_buf_err_stamp < cfs_time_current_sec()) {
+                   scd->scd_buf_err_stamp < ktime_get_real_seconds()) {
                        /* re-enable adding buffer */
                        scd->scd_buf_err_stamp = 0;
                        scd->scd_buf_err = 0;
@@ -1589,9 +1587,9 @@ srpc_startup (void)
        /* 1 second pause to avoid timestamp reuse */
        set_current_state(TASK_UNINTERRUPTIBLE);
        schedule_timeout(cfs_time_seconds(1));
-       srpc_data.rpc_matchbits = ((__u64) cfs_time_current_sec()) << 48;
+       srpc_data.rpc_matchbits = ((__u64) ktime_get_real_seconds()) << 48;
 
-        srpc_data.rpc_state = SRPC_STATE_NONE;
+       srpc_data.rpc_state = SRPC_STATE_NONE;
 
        rc = LNetNIInit(LNET_PID_LUSTRE);
         if (rc < 0) {