X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Fnrs_crr.c;h=41d0cb6a83643ea4b5f7301dab3d7531622ce51e;hb=HEAD;hp=f62728fd0381d225f4ec3aca3e1e151f6fededd0;hpb=9df933d9b4a63e06d93d2d07cf5e670fcc10c8fc;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/nrs_crr.c b/lustre/ptlrpc/nrs_crr.c index f62728f..73606e4 100644 --- a/lustre/ptlrpc/nrs_crr.c +++ b/lustre/ptlrpc/nrs_crr.c @@ -38,7 +38,6 @@ * \addtogoup nrs * @{ */ -#ifdef HAVE_SERVER_SUPPORT #define DEBUG_SUBSYSTEM S_RPC #include @@ -73,7 +72,7 @@ * \retval 1 e1 <= e2 */ static int -crrn_req_compare(struct cfs_binheap_node *e1, struct cfs_binheap_node *e2) +crrn_req_compare(struct binheap_node *e1, struct binheap_node *e2) { struct ptlrpc_nrs_request *nrq1; struct ptlrpc_nrs_request *nrq2; @@ -89,7 +88,7 @@ crrn_req_compare(struct cfs_binheap_node *e1, struct cfs_binheap_node *e2) return nrq1->nr_u.crr.cr_sequence < nrq2->nr_u.crr.cr_sequence; } -static struct cfs_binheap_ops nrs_crrn_heap_ops = { +static struct binheap_ops nrs_crrn_heap_ops = { .hop_enter = NULL, .hop_exit = NULL, .hop_compare = crrn_req_compare, @@ -98,27 +97,26 @@ static struct cfs_binheap_ops nrs_crrn_heap_ops = { /** * rhashtable operations for nrs_crrn_net::cn_cli_hash * - * This uses ptlrpc_request::rq_peer.nid as its key, in order to hash + * This uses ptlrpc_request::rq_peer.nid (as nid4) as its key, in order to hash * nrs_crrn_client objects. */ static u32 nrs_crrn_hashfn(const void *data, u32 len, u32 seed) { - const lnet_nid_t *nid = data; + const struct lnet_nid *nid = data; - seed ^= cfs_hash_64((u64)nid, 32); - return seed; + return cfs_hash_32(nidhash(nid) ^ seed, 32); } static int nrs_crrn_cmpfn(struct rhashtable_compare_arg *arg, const void *obj) { const struct nrs_crrn_client *cli = obj; - const lnet_nid_t *nid = arg->key; + const struct lnet_nid *nid = arg->key; - return *nid != cli->cc_nid; + return nid_same(nid, &cli->cc_nid) ? 0 : -ESRCH; } static const struct rhashtable_params nrs_crrn_hash_params = { - .key_len = sizeof(lnet_nid_t), + .key_len = sizeof(struct lnet_nid), .key_offset = offsetof(struct nrs_crrn_client, cc_nid), .head_offset = offsetof(struct nrs_crrn_client, cc_rhead), .hashfn = nrs_crrn_hashfn, @@ -131,7 +129,7 @@ static void nrs_crrn_exit(void *vcli, void *data) LASSERTF(atomic_read(&cli->cc_ref) == 0, "Busy CRR-N object from client with NID %s, with %d refs\n", - libcfs_nid2str(cli->cc_nid), atomic_read(&cli->cc_ref)); + libcfs_nidstr(&cli->cc_nid), atomic_read(&cli->cc_ref)); OBD_FREE_PTR(cli); } @@ -154,7 +152,7 @@ static int nrs_crrn_start(struct ptlrpc_nrs_policy *policy, char *arg) if (net == NULL) RETURN(-ENOMEM); - net->cn_binheap = cfs_binheap_create(&nrs_crrn_heap_ops, + net->cn_binheap = binheap_create(&nrs_crrn_heap_ops, CBH_FLAG_ATOMIC_GROW, 4096, NULL, nrs_pol2cptab(policy), nrs_pol2cptid(policy)); @@ -183,7 +181,7 @@ static int nrs_crrn_start(struct ptlrpc_nrs_policy *policy, char *arg) RETURN(rc); out_binheap: - cfs_binheap_destroy(net->cn_binheap); + binheap_destroy(net->cn_binheap); out_net: OBD_FREE_PTR(net); @@ -206,10 +204,10 @@ static void nrs_crrn_stop(struct ptlrpc_nrs_policy *policy) LASSERT(net != NULL); LASSERT(net->cn_binheap != NULL); - LASSERT(cfs_binheap_is_empty(net->cn_binheap)); + LASSERT(binheap_is_empty(net->cn_binheap)); rhashtable_free_and_destroy(&net->cn_cli_hash, nrs_crrn_exit, NULL); - cfs_binheap_destroy(net->cn_binheap); + binheap_destroy(net->cn_binheap); OBD_FREE_PTR(net); } @@ -234,7 +232,7 @@ static int nrs_crrn_ctl(struct ptlrpc_nrs_policy *policy, { assert_spin_locked(&policy->pol_nrs->nrs_lock); - switch((enum nrs_ctl_crr)opc) { + switch (opc) { default: RETURN(-EINVAL); @@ -302,7 +300,6 @@ static int nrs_crrn_res_get(struct ptlrpc_nrs_policy *policy, net = container_of(parent, struct nrs_crrn_net, cn_res); req = container_of(nrq, struct ptlrpc_request, rq_nrq); - cli = rhashtable_lookup_fast(&net->cn_cli_hash, &req->rq_peer.nid, nrs_crrn_hash_params); if (cli) @@ -377,7 +374,7 @@ struct ptlrpc_nrs_request *nrs_crrn_req_get(struct ptlrpc_nrs_policy *policy, bool peek, bool force) { struct nrs_crrn_net *net = policy->pol_private; - struct cfs_binheap_node *node = cfs_binheap_root(net->cn_binheap); + struct binheap_node *node = binheap_root(net->cn_binheap); struct ptlrpc_nrs_request *nrq; nrq = unlikely(node == NULL) ? NULL : @@ -394,16 +391,16 @@ struct ptlrpc_nrs_request *nrs_crrn_req_get(struct ptlrpc_nrs_policy *policy, LASSERT(nrq->nr_u.crr.cr_round <= cli->cc_round); - cfs_binheap_remove(net->cn_binheap, &nrq->nr_node); + binheap_remove(net->cn_binheap, &nrq->nr_node); cli->cc_active--; CDEBUG(D_RPCTRACE, "NRS: starting to handle %s request from %s, with round " "%llu\n", NRS_POL_NAME_CRRN, - libcfs_id2str(req->rq_peer), nrq->nr_u.crr.cr_round); + libcfs_idstr(&req->rq_peer), nrq->nr_u.crr.cr_round); /** Peek at the next request to be served */ - node = cfs_binheap_root(net->cn_binheap); + node = binheap_root(net->cn_binheap); /** No more requests */ if (unlikely(node == NULL)) { @@ -498,7 +495,7 @@ static int nrs_crrn_req_add(struct ptlrpc_nrs_policy *policy, nrq->nr_u.crr.cr_round = cli->cc_round; nrq->nr_u.crr.cr_sequence = cli->cc_sequence; - rc = cfs_binheap_insert(net->cn_binheap, &nrq->nr_node); + rc = binheap_insert(net->cn_binheap, &nrq->nr_node); if (rc == 0) { cli->cc_active++; if (--cli->cc_quantum == 0) @@ -528,9 +525,9 @@ static void nrs_crrn_req_del(struct ptlrpc_nrs_policy *policy, LASSERT(nrq->nr_u.crr.cr_round <= cli->cc_round); - is_root = &nrq->nr_node == cfs_binheap_root(net->cn_binheap); + is_root = &nrq->nr_node == binheap_root(net->cn_binheap); - cfs_binheap_remove(net->cn_binheap, &nrq->nr_node); + binheap_remove(net->cn_binheap, &nrq->nr_node); cli->cc_active--; /** @@ -539,7 +536,7 @@ static void nrs_crrn_req_del(struct ptlrpc_nrs_policy *policy, */ if (unlikely(is_root)) { /** Peek at the next request to be served */ - struct cfs_binheap_node *node = cfs_binheap_root(net->cn_binheap); + struct binheap_node *node = binheap_root(net->cn_binheap); /** No more requests */ if (unlikely(node == NULL)) { @@ -570,7 +567,7 @@ static void nrs_crrn_req_stop(struct ptlrpc_nrs_policy *policy, CDEBUG(D_RPCTRACE, "NRS: finished handling %s request from %s, with round %llu" "\n", NRS_POL_NAME_CRRN, - libcfs_id2str(req->rq_peer), nrq->nr_u.crr.cr_round); + libcfs_idstr(&req->rq_peer), nrq->nr_u.crr.cr_round); } /** @@ -665,7 +662,8 @@ ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file, size_t count, loff_t *off) { - struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; + struct seq_file *m = file->private_data; + struct ptlrpc_service *svc = m->private; enum ptlrpc_nrs_queue_type queue = 0; char kernbuf[LPROCFS_NRS_WR_QUANTUM_MAX_CMD]; char *val; @@ -785,17 +783,19 @@ LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_crrn_quantum); */ static int nrs_crrn_lprocfs_init(struct ptlrpc_service *svc) { - struct lprocfs_vars nrs_crrn_lprocfs_vars[] = { + struct ldebugfs_vars nrs_crrn_lprocfs_vars[] = { { .name = "nrs_crrn_quantum", .fops = &ptlrpc_lprocfs_nrs_crrn_quantum_fops, .data = svc }, { NULL } }; - if (IS_ERR_OR_NULL(svc->srv_debugfs_entry)) + if (!svc->srv_debugfs_entry) return 0; - return ldebugfs_add_vars(svc->srv_debugfs_entry, nrs_crrn_lprocfs_vars, NULL); + ldebugfs_add_vars(svc->srv_debugfs_entry, nrs_crrn_lprocfs_vars, NULL); + + return 0; } /** @@ -826,5 +826,3 @@ struct ptlrpc_nrs_pol_conf nrs_conf_crrn = { /** @} CRR-N policy */ /** @} nrs */ - -#endif /* HAVE_SERVER_SUPPORT */