Whamcloud - gitweb
LU-3478 iokit: fix sgpdd-survey scripts (output and plotting)
[fs/lustre-release.git] / lnet / selftest / rpc.c
index 3f03e5f..301a31a 100644 (file)
@@ -26,6 +26,8 @@
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -86,9 +88,9 @@ void srpc_set_counters (const srpc_counters_t *cnt)
 }
 
 int
-srpc_add_bulk_page(srpc_bulk_t *bk, cfs_page_t *pg, int i, int nob)
+srpc_add_bulk_page(srpc_bulk_t *bk, struct page *pg, int i, int nob)
 {
-       nob = min(nob, (int)CFS_PAGE_SIZE);
+       nob = min(nob, (int)PAGE_CACHE_SIZE);
 
        LASSERT(nob > 0);
        LASSERT(i >= 0 && i < bk->bk_niov);
@@ -102,7 +104,7 @@ srpc_add_bulk_page(srpc_bulk_t *bk, cfs_page_t *pg, int i, int nob)
 
        bk->bk_pages[i] = pg;
        bk->bk_iovs[i].iov_len  = nob;
-       bk->bk_iovs[i].iov_base = cfs_page_address(pg);
+       bk->bk_iovs[i].iov_base = page_address(pg);
 #endif
        return nob;
 }
@@ -111,7 +113,7 @@ void
 srpc_free_bulk (srpc_bulk_t *bk)
 {
         int         i;
-        cfs_page_t *pg;
+       struct page *pg;
 
         LASSERT (bk != NULL);
 #ifndef __KERNEL__
@@ -126,11 +128,11 @@ srpc_free_bulk (srpc_bulk_t *bk)
 #endif
                 if (pg == NULL) break;
 
-                cfs_free_page(pg);
+               __free_page(pg);
         }
 
 #ifndef __KERNEL__
-        LIBCFS_FREE(bk->bk_pages, sizeof(cfs_page_t *) * bk->bk_niov);
+       LIBCFS_FREE(bk->bk_pages, sizeof(struct page *) * bk->bk_niov);
 #endif
         LIBCFS_FREE(bk, offsetof(srpc_bulk_t, bk_iovs[bk->bk_niov]));
         return;
@@ -140,7 +142,7 @@ srpc_bulk_t *
 srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
 {
        srpc_bulk_t  *bk;
-       cfs_page_t  **pages;
+       struct page  **pages;
        int           i;
 
        LASSERT(bulk_npg > 0 && bulk_npg <= LNET_MAX_IOV);
@@ -158,24 +160,24 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
        bk->bk_niov   = bulk_npg;
 #ifndef __KERNEL__
        LIBCFS_CPT_ALLOC(pages, lnet_cpt_table(), cpt,
-                        sizeof(cfs_page_t *) * bulk_npg);
+                        sizeof(struct page *) * bulk_npg);
        if (pages == NULL) {
                LIBCFS_FREE(bk, offsetof(srpc_bulk_t, bk_iovs[bulk_npg]));
                CERROR("Can't allocate page array for %d pages\n", bulk_npg);
                return NULL;
        }
 
-       memset(pages, 0, sizeof(cfs_page_t *) * bulk_npg);
+       memset(pages, 0, sizeof(struct page *) * bulk_npg);
        bk->bk_pages = pages;
 #else
        UNUSED(pages);
 #endif
 
        for (i = 0; i < bulk_npg; i++) {
-               cfs_page_t *pg;
+               struct page *pg;
                int         nob;
 
-               pg = cfs_page_cpt_alloc(lnet_cpt_table(), cpt, CFS_ALLOC_STD);
+               pg = cfs_page_cpt_alloc(lnet_cpt_table(), cpt, GFP_IOFS);
                if (pg == NULL) {
                        CERROR("Can't allocate page %d of %d\n", i, bulk_npg);
                        srpc_free_bulk(bk);
@@ -689,8 +691,10 @@ srpc_finish_service(struct srpc_service *sv)
 
        cfs_percpt_for_each(scd, i, sv->sv_cpt_data) {
                spin_lock(&scd->scd_lock);
-               if (!swi_deschedule_workitem(&scd->scd_buf_wi))
+               if (!swi_deschedule_workitem(&scd->scd_buf_wi)) {
+                       spin_unlock(&scd->scd_lock);
                        return 0;
+               }
 
                if (scd->scd_buf_nposted > 0) {
                        CDEBUG(D_NET, "waiting for %d posted buffers to unlink",
@@ -1211,13 +1215,20 @@ int
 srpc_send_rpc (swi_workitem_t *wi)
 {
         int                rc = 0;
-        srpc_client_rpc_t *rpc = wi->swi_workitem.wi_data;
-        srpc_msg_t        *reply = &rpc->crpc_replymsg;
-        int                do_bulk = rpc->crpc_bulk.bk_niov > 0;
+       srpc_client_rpc_t *rpc;
+       srpc_msg_t        *reply;
+       int                do_bulk;
+
+       LASSERT(wi != NULL);
+
+       rpc = wi->swi_workitem.wi_data;
 
         LASSERT (rpc != NULL);
         LASSERT (wi == &rpc->crpc_wi);
 
+       reply = &rpc->crpc_replymsg;
+       do_bulk = rpc->crpc_bulk.bk_niov > 0;
+
        spin_lock(&rpc->crpc_lock);
 
        if (rpc->crpc_aborted) {