X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Fselftest%2Fconrpc.c;h=749714af20c0e39396d7c410022e933b21b640d0;hb=d054c3d4c173a41ca7c74ebe361d6de2e7aa507a;hp=de80dd9c9e662791910625144e724b3bb9ca6fdd;hpb=33984c012883a7c714429d2c612cf6dcda191974;p=fs%2Flustre-release.git diff --git a/lnet/selftest/conrpc.c b/lnet/selftest/conrpc.c index de80dd9..749714a 100644 --- a/lnet/selftest/conrpc.c +++ b/lnet/selftest/conrpc.c @@ -15,11 +15,7 @@ * * 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, 2014, 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 */ -#ifdef __KERNEL__ #include #include @@ -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) @@ -423,7 +418,7 @@ 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; @@ -475,7 +470,7 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans, { struct list_head tmp; struct list_head __user *next; - lstcon_rpc_ent_t *ent; + struct lstcon_rpc_ent *ent; srpc_generic_reply_t *rep; lstcon_rpc_t *crpc; srpc_msg_t *msg; @@ -498,7 +493,7 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans, next = tmp.next; - ent = list_entry(next, lstcon_rpc_ent_t, rpe_link); + ent = list_entry(next, struct lstcon_rpc_ent, rpe_link); LASSERT(crpc->crp_stamp != 0); @@ -508,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)) || @@ -526,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; @@ -704,17 +699,17 @@ lstcon_statrpc_prep(lstcon_node_t *nd, unsigned feats, lstcon_rpc_t **crpc) return 0; } -static 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]; } @@ -723,7 +718,7 @@ 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; @@ -774,7 +769,7 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx, } static int -lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req) +lstcon_pingrpc_prep(struct lst_test_ping_param *param, srpc_test_reqst_t *req) { test_ping_req_t *prq = &req->tsr_u.ping; @@ -785,27 +780,28 @@ lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req) } static int -lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req) +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; } static int -lstcon_bulkrpc_v1_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req) +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; } @@ -826,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); @@ -853,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); @@ -894,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; @@ -966,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; @@ -1179,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; @@ -1193,10 +1190,10 @@ 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; @@ -1251,9 +1248,8 @@ lstcon_rpc_pinger(void *arg) 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,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); } @@ -1303,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; } @@ -1322,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; } @@ -1354,7 +1350,8 @@ 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); } @@ -1403,4 +1400,3 @@ lstcon_rpc_module_fini(void) LASSERT(atomic_read(&console_session.ses_rpc_counter) == 0); } -#endif