From 8587508f5ddd7b8e764abb4c6fc078ba0f0bf1ad Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Mon, 1 Feb 2021 13:16:12 +1100 Subject: [PATCH] LU-14289 ptlrpc: rename cfs_binheap to simply binheap As the binheap code is no longer part of libcfs, the cfs_ prefix is misleading. As this code is local to one module and doesn't conflict with anything global, there is no need for a prefix at all. So change cfs_binheap to binheap. This patch was prepare using 'sed', then fixing a few text-alignment issues caused by the loss of those 4 characters. Signed-off-by: Mr NeilBrown Change-Id: I168bec50898ec7b9ab72dc91b080af4852ddb3a4 Reviewed-on: https://review.whamcloud.com/41375 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Tested-by: jenkins Tested-by: Maloo --- lustre/include/lustre_nrs.h | 6 +-- lustre/include/lustre_nrs_crr.h | 2 +- lustre/include/lustre_nrs_delay.h | 2 +- lustre/include/lustre_nrs_orr.h | 2 +- lustre/include/lustre_nrs_tbf.h | 4 +- lustre/ptlrpc/heap.c | 98 +++++++++++++++++++-------------------- lustre/ptlrpc/heap.h | 72 ++++++++++++++-------------- lustre/ptlrpc/nrs_crr.c | 26 +++++------ lustre/ptlrpc/nrs_delay.c | 22 ++++----- lustre/ptlrpc/nrs_orr.c | 26 +++++------ lustre/ptlrpc/nrs_tbf.c | 50 ++++++++++---------- 11 files changed, 155 insertions(+), 155 deletions(-) diff --git a/lustre/include/lustre_nrs.h b/lustre/include/lustre_nrs.h index 4f08eab..80f9f6b 100644 --- a/lustre/include/lustre_nrs.h +++ b/lustre/include/lustre_nrs.h @@ -676,9 +676,9 @@ enum { * Binary heap node. * * Objects of this type are embedded into objects of the ordered set that is to - * be maintained by a \e struct cfs_binheap instance. + * be maintained by a \e struct binheap instance. */ -struct cfs_binheap_node { +struct binheap_node { /** Index into the binary tree */ unsigned int chn_index; }; @@ -713,7 +713,7 @@ struct ptlrpc_nrs_request { unsigned nr_enqueued:1; unsigned nr_started:1; unsigned nr_finalized:1; - struct cfs_binheap_node nr_node; + struct binheap_node nr_node; /** * Policy-specific fields, used for determining a request's scheduling diff --git a/lustre/include/lustre_nrs_crr.h b/lustre/include/lustre_nrs_crr.h index 06be0ae..c4c217b 100644 --- a/lustre/include/lustre_nrs_crr.h +++ b/lustre/include/lustre_nrs_crr.h @@ -45,7 +45,7 @@ */ struct nrs_crrn_net { struct ptlrpc_nrs_resource cn_res; - struct cfs_binheap *cn_binheap; + struct binheap *cn_binheap; /* CRR-N NRS - NID hash body */ struct rhashtable cn_cli_hash; /** diff --git a/lustre/include/lustre_nrs_delay.h b/lustre/include/lustre_nrs_delay.h index 01605a7..9ffbc51 100644 --- a/lustre/include/lustre_nrs_delay.h +++ b/lustre/include/lustre_nrs_delay.h @@ -48,7 +48,7 @@ struct nrs_delay_data { * Delayed requests are stored in this binheap until they are * removed for handling. */ - struct cfs_binheap *delay_binheap; + struct binheap *delay_binheap; /** * Minimum service time diff --git a/lustre/include/lustre_nrs_orr.h b/lustre/include/lustre_nrs_orr.h index 3698a80..df3d16a 100644 --- a/lustre/include/lustre_nrs_orr.h +++ b/lustre/include/lustre_nrs_orr.h @@ -106,7 +106,7 @@ struct nrs_orr_key { */ struct nrs_orr_data { struct ptlrpc_nrs_resource od_res; - struct cfs_binheap *od_binheap; + struct binheap *od_binheap; struct cfs_hash *od_obj_hash; struct kmem_cache *od_cache; /** diff --git a/lustre/include/lustre_nrs_tbf.h b/lustre/include/lustre_nrs_tbf.h index e4bbf8a..32f959a 100644 --- a/lustre/include/lustre_nrs_tbf.h +++ b/lustre/include/lustre_nrs_tbf.h @@ -121,7 +121,7 @@ struct nrs_tbf_client { /** List of queued requests. */ struct list_head tc_list; /** Node in binary heap. */ - struct cfs_binheap_node tc_node; + struct binheap_node tc_node; /** Whether the client is in heap. */ bool tc_in_heap; /** Sequence of the newest rule. */ @@ -265,7 +265,7 @@ struct nrs_tbf_head { /** * Heap of queues. */ - struct cfs_binheap *th_binheap; + struct binheap *th_binheap; /** * Hash of clients. */ diff --git a/lustre/ptlrpc/heap.c b/lustre/ptlrpc/heap.c index ddeca8b..b96ea18 100644 --- a/lustre/ptlrpc/heap.c +++ b/lustre/ptlrpc/heap.c @@ -57,7 +57,7 @@ do { \ /** * Grows the capacity of a binary heap so that it can handle a larger number of - * \e struct cfs_binheap_node objects. + * \e struct binheap_node objects. * * \param[in] h The binary heap * @@ -65,10 +65,10 @@ do { \ * \retval -ENOMEM OOM error */ static int -cfs_binheap_grow(struct cfs_binheap *h) +binheap_grow(struct binheap *h) { - struct cfs_binheap_node ***frag1 = NULL; - struct cfs_binheap_node **frag2; + struct binheap_node ***frag1 = NULL; + struct binheap_node **frag2; int hwm = h->cbh_hwm; /* need a whole new chunk of pointers */ @@ -161,12 +161,12 @@ cfs_binheap_grow(struct cfs_binheap *h) * \retval valid-pointer A newly-created and initialized binary heap object * \retval NULL error */ -struct cfs_binheap * -cfs_binheap_create(struct cfs_binheap_ops *ops, unsigned int flags, +struct binheap * +binheap_create(struct binheap_ops *ops, unsigned int flags, unsigned int count, void *arg, struct cfs_cpt_table *cptab, int cptid) { - struct cfs_binheap *h; + struct binheap *h; LASSERT(ops != NULL); LASSERT(ops->hop_compare != NULL); @@ -189,8 +189,8 @@ cfs_binheap_create(struct cfs_binheap_ops *ops, unsigned int flags, h->cbh_cptid = cptid; while (h->cbh_hwm < count) { /* preallocate */ - if (cfs_binheap_grow(h) != 0) { - cfs_binheap_destroy(h); + if (binheap_grow(h) != 0) { + binheap_destroy(h); return NULL; } } @@ -199,7 +199,7 @@ cfs_binheap_create(struct cfs_binheap_ops *ops, unsigned int flags, return h; } -EXPORT_SYMBOL(cfs_binheap_create); +EXPORT_SYMBOL(binheap_create); /** * Releases all resources associated with a binary heap instance. @@ -210,7 +210,7 @@ EXPORT_SYMBOL(cfs_binheap_create); * \param[in] h The binary heap object */ void -cfs_binheap_destroy(struct cfs_binheap *h) +binheap_destroy(struct binheap *h) { int idx0; int idx1; @@ -250,7 +250,7 @@ cfs_binheap_destroy(struct cfs_binheap *h) LIBCFS_FREE(h, sizeof(*h)); } -EXPORT_SYMBOL(cfs_binheap_destroy); +EXPORT_SYMBOL(binheap_destroy); /** * Obtains a double pointer to a heap element, given its index into the binary @@ -261,8 +261,8 @@ EXPORT_SYMBOL(cfs_binheap_destroy); * * \retval valid-pointer A double pointer to a heap pointer entry */ -static struct cfs_binheap_node ** -cfs_binheap_pointer(struct cfs_binheap *h, unsigned int idx) +static struct binheap_node ** +binheap_pointer(struct binheap *h, unsigned int idx) { if (idx < CBH_SIZE) return &(h->cbh_elements1[idx]); @@ -286,15 +286,15 @@ cfs_binheap_pointer(struct cfs_binheap *h, unsigned int idx) * \retval valid-pointer The requested heap node * \retval NULL Supplied index is out of bounds */ -struct cfs_binheap_node * -cfs_binheap_find(struct cfs_binheap *h, unsigned int idx) +struct binheap_node * +binheap_find(struct binheap *h, unsigned int idx) { if (idx >= h->cbh_nelements) return NULL; - return *cfs_binheap_pointer(h, idx); + return *binheap_pointer(h, idx); } -EXPORT_SYMBOL(cfs_binheap_find); +EXPORT_SYMBOL(binheap_find); /** * Moves a node upwards, towards the root of the binary tree. @@ -306,21 +306,21 @@ EXPORT_SYMBOL(cfs_binheap_find); * \retval 0 The position of \a e in the tree was not changed */ static int -cfs_binheap_bubble(struct cfs_binheap *h, struct cfs_binheap_node *e) +binheap_bubble(struct binheap *h, struct binheap_node *e) { unsigned int cur_idx = e->chn_index; - struct cfs_binheap_node **cur_ptr; + struct binheap_node **cur_ptr; unsigned int parent_idx; - struct cfs_binheap_node **parent_ptr; + struct binheap_node **parent_ptr; int did_sth = 0; - cur_ptr = cfs_binheap_pointer(h, cur_idx); + cur_ptr = binheap_pointer(h, cur_idx); LASSERT(*cur_ptr == e); while (cur_idx > 0) { parent_idx = (cur_idx - 1) >> 1; - parent_ptr = cfs_binheap_pointer(h, parent_idx); + parent_ptr = binheap_pointer(h, parent_idx); LASSERT((*parent_ptr)->chn_index == parent_idx); if (h->cbh_ops->hop_compare(*parent_ptr, e)) @@ -349,21 +349,21 @@ cfs_binheap_bubble(struct cfs_binheap *h, struct cfs_binheap_node *e) * \retval 0 The position of \a e in the tree was not changed */ static int -cfs_binheap_sink(struct cfs_binheap *h, struct cfs_binheap_node *e) +binheap_sink(struct binheap *h, struct binheap_node *e) { unsigned int n = h->cbh_nelements; unsigned int child_idx; - struct cfs_binheap_node **child_ptr; - struct cfs_binheap_node *child; + struct binheap_node **child_ptr; + struct binheap_node *child; unsigned int child2_idx; - struct cfs_binheap_node **child2_ptr; - struct cfs_binheap_node *child2; + struct binheap_node **child2_ptr; + struct binheap_node *child2; unsigned int cur_idx; - struct cfs_binheap_node **cur_ptr; + struct binheap_node **cur_ptr; int did_sth = 0; cur_idx = e->chn_index; - cur_ptr = cfs_binheap_pointer(h, cur_idx); + cur_ptr = binheap_pointer(h, cur_idx); LASSERT(*cur_ptr == e); while (cur_idx < n) { @@ -371,12 +371,12 @@ cfs_binheap_sink(struct cfs_binheap *h, struct cfs_binheap_node *e) if (child_idx >= n) break; - child_ptr = cfs_binheap_pointer(h, child_idx); + child_ptr = binheap_pointer(h, child_idx); child = *child_ptr; child2_idx = child_idx + 1; if (child2_idx < n) { - child2_ptr = cfs_binheap_pointer(h, child2_idx); + child2_ptr = binheap_pointer(h, child2_idx); child2 = *child2_ptr; if (h->cbh_ops->hop_compare(child2, child)) { @@ -414,14 +414,14 @@ cfs_binheap_sink(struct cfs_binheap *h, struct cfs_binheap_node *e) * \retval != 0 error */ int -cfs_binheap_insert(struct cfs_binheap *h, struct cfs_binheap_node *e) +binheap_insert(struct binheap *h, struct binheap_node *e) { - struct cfs_binheap_node **new_ptr; + struct binheap_node **new_ptr; unsigned int new_idx = h->cbh_nelements; int rc; if (new_idx == h->cbh_hwm) { - rc = cfs_binheap_grow(h); + rc = binheap_grow(h); if (rc != 0) return rc; } @@ -433,15 +433,15 @@ cfs_binheap_insert(struct cfs_binheap *h, struct cfs_binheap_node *e) } e->chn_index = new_idx; - new_ptr = cfs_binheap_pointer(h, new_idx); + new_ptr = binheap_pointer(h, new_idx); h->cbh_nelements++; *new_ptr = e; - cfs_binheap_bubble(h, e); + binheap_bubble(h, e); return 0; } -EXPORT_SYMBOL(cfs_binheap_insert); +EXPORT_SYMBOL(binheap_insert); /** * Removes a node from the binary heap. @@ -450,34 +450,34 @@ EXPORT_SYMBOL(cfs_binheap_insert); * \param[in] e The node */ void -cfs_binheap_remove(struct cfs_binheap *h, struct cfs_binheap_node *e) +binheap_remove(struct binheap *h, struct binheap_node *e) { unsigned int n = h->cbh_nelements; unsigned int cur_idx = e->chn_index; - struct cfs_binheap_node **cur_ptr; - struct cfs_binheap_node *last; + struct binheap_node **cur_ptr; + struct binheap_node *last; LASSERT(cur_idx != CBH_POISON); LASSERT(cur_idx < n); - cur_ptr = cfs_binheap_pointer(h, cur_idx); + cur_ptr = binheap_pointer(h, cur_idx); LASSERT(*cur_ptr == e); n--; - last = *cfs_binheap_pointer(h, n); + last = *binheap_pointer(h, n); h->cbh_nelements = n; if (last == e) return; last->chn_index = cur_idx; *cur_ptr = last; - cfs_binheap_relocate(h, *cur_ptr); + binheap_relocate(h, *cur_ptr); e->chn_index = CBH_POISON; if (h->cbh_ops->hop_exit) h->cbh_ops->hop_exit(h, e); } -EXPORT_SYMBOL(cfs_binheap_remove); +EXPORT_SYMBOL(binheap_remove); /** * Relocate a node in the binary heap. @@ -488,10 +488,10 @@ EXPORT_SYMBOL(cfs_binheap_remove); * \param[in] e The node */ void -cfs_binheap_relocate(struct cfs_binheap *h, struct cfs_binheap_node *e) +binheap_relocate(struct binheap *h, struct binheap_node *e) { - if (!cfs_binheap_bubble(h, e)) - cfs_binheap_sink(h, e); + if (!binheap_bubble(h, e)) + binheap_sink(h, e); } -EXPORT_SYMBOL(cfs_binheap_relocate); +EXPORT_SYMBOL(binheap_relocate); /** @} heap */ diff --git a/lustre/ptlrpc/heap.h b/lustre/ptlrpc/heap.h index 36899a8..7cd5c1c 100644 --- a/lustre/ptlrpc/heap.h +++ b/lustre/ptlrpc/heap.h @@ -39,9 +39,9 @@ * the tree (as this is an implementation of a min-heap) to be removed by users * for consumption. * - * Users of the heap should embed a \e struct cfs_binheap_node object instance + * Users of the heap should embed a \e struct binheap_node object instance * on every object of the set that they wish the binary heap instance to handle, - * and (at a minimum) provide a struct cfs_binheap_ops::hop_compare() + * and (at a minimum) provide a struct binheap_ops::hop_compare() * implementation which is used by the heap as the binary predicate during its * internal sorting operations. * @@ -56,7 +56,7 @@ #define CBH_SHIFT 9 #define CBH_SIZE (1 << CBH_SHIFT) /* # ptrs per level */ #define CBH_MASK (CBH_SIZE - 1) -#define CBH_NOB (CBH_SIZE * sizeof(struct cfs_binheap_node *)) +#define CBH_NOB (CBH_SIZE * sizeof(struct binheap_node *)) #define CBH_POISON 0xdeadbeef @@ -67,12 +67,12 @@ enum { CBH_FLAG_ATOMIC_GROW = 1, }; -struct cfs_binheap; +struct binheap; /** * Binary heap operations. */ -struct cfs_binheap_ops { +struct binheap_ops { /** * Called right before inserting a node into the binary heap. * @@ -84,8 +84,8 @@ struct cfs_binheap_ops { * \retval 0 success * \retval != 0 error */ - int (*hop_enter)(struct cfs_binheap *h, - struct cfs_binheap_node *e); + int (*hop_enter)(struct binheap *h, + struct binheap_node *e); /** * Called right after removing a node from the binary heap. * @@ -94,8 +94,8 @@ struct cfs_binheap_ops { * \param[in] h The heap * \param[in] e The node */ - void (*hop_exit)(struct cfs_binheap *h, - struct cfs_binheap_node *e); + void (*hop_exit)(struct binheap *h, + struct binheap_node *e); /** * A binary predicate which is called during internal heap sorting * operations, and used in order to determine the relevant ordering of @@ -109,25 +109,25 @@ struct cfs_binheap_ops { * \retval 0 Node a > node b * \retval 1 Node a < node b * - * \see cfs_binheap_bubble() + * \see binheap_bubble() * \see cfs_biheap_sink() */ - int (*hop_compare)(struct cfs_binheap_node *a, - struct cfs_binheap_node *b); + int (*hop_compare)(struct binheap_node *a, + struct binheap_node *b); }; /** * Binary heap object. * - * Sorts elements of type \e struct cfs_binheap_node + * Sorts elements of type \e struct binheap_node */ -struct cfs_binheap { +struct binheap { /** Triple indirect */ - struct cfs_binheap_node ****cbh_elements3; + struct binheap_node ****cbh_elements3; /** double indirect */ - struct cfs_binheap_node ***cbh_elements2; + struct binheap_node ***cbh_elements2; /** single indirect */ - struct cfs_binheap_node **cbh_elements1; + struct binheap_node **cbh_elements1; /** # elements referenced */ unsigned int cbh_nelements; /** high water mark */ @@ -135,51 +135,51 @@ struct cfs_binheap { /** user flags */ unsigned int cbh_flags; /** operations table */ - struct cfs_binheap_ops *cbh_ops; + struct binheap_ops *cbh_ops; /** private data */ void *cbh_private; /** associated CPT table */ struct cfs_cpt_table *cbh_cptab; - /** associated CPT id of this struct cfs_binheap::cbh_cptab */ + /** associated CPT id of this struct binheap::cbh_cptab */ int cbh_cptid; }; -void cfs_binheap_destroy(struct cfs_binheap *h); -struct cfs_binheap * -cfs_binheap_create(struct cfs_binheap_ops *ops, unsigned int flags, +void binheap_destroy(struct binheap *h); +struct binheap * +binheap_create(struct binheap_ops *ops, unsigned int flags, unsigned int count, void *arg, struct cfs_cpt_table *cptab, int cptid); -struct cfs_binheap_node * -cfs_binheap_find(struct cfs_binheap *h, unsigned int idx); -int cfs_binheap_insert(struct cfs_binheap *h, struct cfs_binheap_node *e); -void cfs_binheap_remove(struct cfs_binheap *h, struct cfs_binheap_node *e); -void cfs_binheap_relocate(struct cfs_binheap *h, struct cfs_binheap_node *e); +struct binheap_node * +binheap_find(struct binheap *h, unsigned int idx); +int binheap_insert(struct binheap *h, struct binheap_node *e); +void binheap_remove(struct binheap *h, struct binheap_node *e); +void binheap_relocate(struct binheap *h, struct binheap_node *e); static inline int -cfs_binheap_size(struct cfs_binheap *h) +binheap_size(struct binheap *h) { return h->cbh_nelements; } static inline int -cfs_binheap_is_empty(struct cfs_binheap *h) +binheap_is_empty(struct binheap *h) { return h->cbh_nelements == 0; } -static inline struct cfs_binheap_node * -cfs_binheap_root(struct cfs_binheap *h) +static inline struct binheap_node * +binheap_root(struct binheap *h) { - return cfs_binheap_find(h, 0); + return binheap_find(h, 0); } -static inline struct cfs_binheap_node * -cfs_binheap_remove_root(struct cfs_binheap *h) +static inline struct binheap_node * +binheap_remove_root(struct binheap *h) { - struct cfs_binheap_node *e = cfs_binheap_find(h, 0); + struct binheap_node *e = binheap_find(h, 0); if (e != NULL) - cfs_binheap_remove(h, e); + binheap_remove(h, e); return e; } diff --git a/lustre/ptlrpc/nrs_crr.c b/lustre/ptlrpc/nrs_crr.c index ec0f5fc..dc41970 100644 --- a/lustre/ptlrpc/nrs_crr.c +++ b/lustre/ptlrpc/nrs_crr.c @@ -72,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; @@ -88,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, @@ -153,7 +153,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)); @@ -182,7 +182,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); @@ -205,10 +205,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); } @@ -376,7 +376,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 : @@ -393,7 +393,7 @@ 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, @@ -402,7 +402,7 @@ struct ptlrpc_nrs_request *nrs_crrn_req_get(struct ptlrpc_nrs_policy *policy, libcfs_id2str(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)) { @@ -497,7 +497,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) @@ -527,9 +527,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--; /** @@ -538,7 +538,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)) { diff --git a/lustre/ptlrpc/nrs_delay.c b/lustre/ptlrpc/nrs_delay.c index 7222c09..a39a9cf 100644 --- a/lustre/ptlrpc/nrs_delay.c +++ b/lustre/ptlrpc/nrs_delay.c @@ -76,8 +76,8 @@ * \retval 0 start_time(e1) > start_time(e2) * \retval 1 start_time(e1) <= start_time(e2) */ -static int delay_req_compare(struct cfs_binheap_node *e1, - struct cfs_binheap_node *e2) +static int delay_req_compare(struct binheap_node *e1, + struct binheap_node *e2) { struct ptlrpc_nrs_request *nrq1; struct ptlrpc_nrs_request *nrq2; @@ -89,7 +89,7 @@ static int delay_req_compare(struct cfs_binheap_node *e1, nrq2->nr_u.delay.req_start_time; } -static struct cfs_binheap_ops nrs_delay_heap_ops = { +static struct binheap_ops nrs_delay_heap_ops = { .hop_enter = NULL, .hop_exit = NULL, .hop_compare = delay_req_compare, @@ -120,7 +120,7 @@ static int nrs_delay_start(struct ptlrpc_nrs_policy *policy, char *arg) if (delay_data == NULL) RETURN(-ENOMEM); - delay_data->delay_binheap = cfs_binheap_create(&nrs_delay_heap_ops, + delay_data->delay_binheap = binheap_create(&nrs_delay_heap_ops, CBH_FLAG_ATOMIC_GROW, 4096, NULL, nrs_pol2cptab(policy), @@ -155,9 +155,9 @@ static void nrs_delay_stop(struct ptlrpc_nrs_policy *policy) LASSERT(delay_data != NULL); LASSERT(delay_data->delay_binheap != NULL); - LASSERT(cfs_binheap_is_empty(delay_data->delay_binheap)); + LASSERT(binheap_is_empty(delay_data->delay_binheap)); - cfs_binheap_destroy(delay_data->delay_binheap); + binheap_destroy(delay_data->delay_binheap); OBD_FREE_PTR(delay_data); } @@ -212,10 +212,10 @@ struct ptlrpc_nrs_request *nrs_delay_req_get(struct ptlrpc_nrs_policy *policy, bool peek, bool force) { struct nrs_delay_data *delay_data = policy->pol_private; - struct cfs_binheap_node *node; + struct binheap_node *node; struct ptlrpc_nrs_request *nrq; - node = cfs_binheap_root(delay_data->delay_binheap); + node = binheap_root(delay_data->delay_binheap); nrq = unlikely(node == NULL) ? NULL : container_of(node, struct ptlrpc_nrs_request, nr_node); @@ -224,7 +224,7 @@ struct ptlrpc_nrs_request *nrs_delay_req_get(struct ptlrpc_nrs_policy *policy, ktime_get_real_seconds() < nrq->nr_u.delay.req_start_time) nrq = NULL; else if (likely(!peek)) - cfs_binheap_remove(delay_data->delay_binheap, + binheap_remove(delay_data->delay_binheap, &nrq->nr_node); } @@ -262,7 +262,7 @@ static int nrs_delay_req_add(struct ptlrpc_nrs_policy *policy, prandom_u32_max(delay_data->max_delay - delay_data->min_delay + 1) + delay_data->min_delay; - return cfs_binheap_insert(delay_data->delay_binheap, &nrq->nr_node); + return binheap_insert(delay_data->delay_binheap, &nrq->nr_node); } /** @@ -276,7 +276,7 @@ static void nrs_delay_req_del(struct ptlrpc_nrs_policy *policy, { struct nrs_delay_data *delay_data = policy->pol_private; - cfs_binheap_remove(delay_data->delay_binheap, &nrq->nr_node); + binheap_remove(delay_data->delay_binheap, &nrq->nr_node); } /** diff --git a/lustre/ptlrpc/nrs_orr.c b/lustre/ptlrpc/nrs_orr.c index 4fcc6bb..a81609a 100644 --- a/lustre/ptlrpc/nrs_orr.c +++ b/lustre/ptlrpc/nrs_orr.c @@ -523,7 +523,7 @@ static struct cfs_hash_ops nrs_trr_hash_ops = { * \retval 1 e1 < e2 */ static int -orr_req_compare(struct cfs_binheap_node *e1, struct cfs_binheap_node *e2) +orr_req_compare(struct binheap_node *e1, struct binheap_node *e2) { struct ptlrpc_nrs_request *nrq1; struct ptlrpc_nrs_request *nrq2; @@ -578,7 +578,7 @@ orr_req_compare(struct cfs_binheap_node *e1, struct cfs_binheap_node *e2) /** * ORR binary heap operations */ -static struct cfs_binheap_ops nrs_orr_heap_ops = { +static struct binheap_ops nrs_orr_heap_ops = { .hop_enter = NULL, .hop_exit = NULL, .hop_compare = orr_req_compare, @@ -631,7 +631,7 @@ static int nrs_orr_start(struct ptlrpc_nrs_policy *policy, char *arg) /* * Binary heap instance for sorted incoming requests. */ - orrd->od_binheap = cfs_binheap_create(&nrs_orr_heap_ops, + orrd->od_binheap = binheap_create(&nrs_orr_heap_ops, CBH_FLAG_ATOMIC_GROW, 4096, NULL, nrs_pol2cptab(policy), nrs_pol2cptid(policy)); @@ -694,7 +694,7 @@ static int nrs_orr_start(struct ptlrpc_nrs_policy *policy, char *arg) out_cache: kmem_cache_destroy(orrd->od_cache); out_binheap: - cfs_binheap_destroy(orrd->od_binheap); + binheap_destroy(orrd->od_binheap); out_orrd: OBD_FREE_PTR(orrd); @@ -719,9 +719,9 @@ static void nrs_orr_stop(struct ptlrpc_nrs_policy *policy) LASSERT(orrd->od_binheap != NULL); LASSERT(orrd->od_obj_hash != NULL); LASSERT(orrd->od_cache != NULL); - LASSERT(cfs_binheap_is_empty(orrd->od_binheap)); + LASSERT(binheap_is_empty(orrd->od_binheap)); - cfs_binheap_destroy(orrd->od_binheap); + binheap_destroy(orrd->od_binheap); cfs_hash_putref(orrd->od_obj_hash); kmem_cache_destroy(orrd->od_cache); @@ -942,7 +942,7 @@ struct ptlrpc_nrs_request *nrs_orr_req_get(struct ptlrpc_nrs_policy *policy, bool peek, bool force) { struct nrs_orr_data *orrd = policy->pol_private; - struct cfs_binheap_node *node = cfs_binheap_root(orrd->od_binheap); + struct binheap_node *node = binheap_root(orrd->od_binheap); struct ptlrpc_nrs_request *nrq; nrq = unlikely(node == NULL) ? NULL : @@ -956,7 +956,7 @@ struct ptlrpc_nrs_request *nrs_orr_req_get(struct ptlrpc_nrs_policy *policy, LASSERT(nrq->nr_u.orr.or_round <= orro->oo_round); - cfs_binheap_remove(orrd->od_binheap, &nrq->nr_node); + binheap_remove(orrd->od_binheap, &nrq->nr_node); orro->oo_active--; if (strncmp(policy->pol_desc->pd_name, NRS_POL_NAME_ORR, @@ -976,7 +976,7 @@ struct ptlrpc_nrs_request *nrs_orr_req_get(struct ptlrpc_nrs_policy *policy, nrq->nr_u.orr.or_round); /** Peek at the next request to be served */ - node = cfs_binheap_root(orrd->od_binheap); + node = binheap_root(orrd->od_binheap); /** No more requests */ if (unlikely(node == NULL)) { @@ -1076,7 +1076,7 @@ static int nrs_orr_req_add(struct ptlrpc_nrs_policy *policy, nrq->nr_u.orr.or_round = orro->oo_round; nrq->nr_u.orr.or_sequence = orro->oo_sequence; - rc = cfs_binheap_insert(orrd->od_binheap, &nrq->nr_node); + rc = binheap_insert(orrd->od_binheap, &nrq->nr_node); if (rc == 0) { orro->oo_active++; if (--orro->oo_quantum == 0) @@ -1106,9 +1106,9 @@ static void nrs_orr_req_del(struct ptlrpc_nrs_policy *policy, LASSERT(nrq->nr_u.orr.or_round <= orro->oo_round); - is_root = &nrq->nr_node == cfs_binheap_root(orrd->od_binheap); + is_root = &nrq->nr_node == binheap_root(orrd->od_binheap); - cfs_binheap_remove(orrd->od_binheap, &nrq->nr_node); + binheap_remove(orrd->od_binheap, &nrq->nr_node); orro->oo_active--; /** @@ -1117,7 +1117,7 @@ static void nrs_orr_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(orrd->od_binheap); + struct binheap_node *node = binheap_root(orrd->od_binheap); /** No more requests */ if (unlikely(node == NULL)) { diff --git a/lustre/ptlrpc/nrs_tbf.c b/lustre/ptlrpc/nrs_tbf.c index b922583..32adf79 100644 --- a/lustre/ptlrpc/nrs_tbf.c +++ b/lustre/ptlrpc/nrs_tbf.c @@ -138,8 +138,8 @@ nrs_tbf_cli_reset_value(struct nrs_tbf_head *head, cli->tc_rule_generation = rule->tr_generation; if (cli->tc_in_heap) - cfs_binheap_relocate(head->th_binheap, - &cli->tc_node); + binheap_relocate(head->th_binheap, + &cli->tc_node); } static void @@ -511,7 +511,7 @@ nrs_tbf_command(struct ptlrpc_nrs_policy *policy, * \retval 1 e1 < e2 */ static int -tbf_cli_compare(struct cfs_binheap_node *e1, struct cfs_binheap_node *e2) +tbf_cli_compare(struct binheap_node *e1, struct binheap_node *e2) { struct nrs_tbf_client *cli1; struct nrs_tbf_client *cli2; @@ -536,7 +536,7 @@ tbf_cli_compare(struct cfs_binheap_node *e1, struct cfs_binheap_node *e2) /** * TBF binary heap operations */ -static struct cfs_binheap_ops nrs_tbf_heap_ops = { +static struct binheap_ops nrs_tbf_heap_ops = { .hop_enter = NULL, .hop_exit = NULL, .hop_compare = tbf_cli_compare, @@ -2784,10 +2784,10 @@ static int nrs_tbf_start(struct ptlrpc_nrs_policy *policy, char *arg) head->th_ops = ops; head->th_type_flag = type; - head->th_binheap = cfs_binheap_create(&nrs_tbf_heap_ops, - CBH_FLAG_ATOMIC_GROW, 4096, NULL, - nrs_pol2cptab(policy), - nrs_pol2cptid(policy)); + head->th_binheap = binheap_create(&nrs_tbf_heap_ops, + CBH_FLAG_ATOMIC_GROW, 4096, NULL, + nrs_pol2cptab(policy), + nrs_pol2cptid(policy)); if (head->th_binheap == NULL) GOTO(out_free_head, rc = -ENOMEM); @@ -2803,7 +2803,7 @@ static int nrs_tbf_start(struct ptlrpc_nrs_policy *policy, char *arg) policy->pol_private = head; return 0; out_free_heap: - cfs_binheap_destroy(head->th_binheap); + binheap_destroy(head->th_binheap); out_free_head: OBD_FREE_PTR(head); out: @@ -2836,8 +2836,8 @@ static void nrs_tbf_stop(struct ptlrpc_nrs_policy *policy) } LASSERT(list_empty(&head->th_list)); LASSERT(head->th_binheap != NULL); - LASSERT(cfs_binheap_is_empty(head->th_binheap)); - cfs_binheap_destroy(head->th_binheap); + LASSERT(binheap_is_empty(head->th_binheap)); + binheap_destroy(head->th_binheap); OBD_FREE_PTR(head); nrs->nrs_throttling = 0; wake_up(&policy->pol_nrs->nrs_svcpt->scp_waitq); @@ -3042,14 +3042,14 @@ struct ptlrpc_nrs_request *nrs_tbf_req_get(struct ptlrpc_nrs_policy *policy, struct nrs_tbf_head *head = policy->pol_private; struct ptlrpc_nrs_request *nrq = NULL; struct nrs_tbf_client *cli; - struct cfs_binheap_node *node; + struct binheap_node *node; assert_spin_locked(&policy->pol_nrs->nrs_svcpt->scp_req_lock); if (!peek && policy->pol_nrs->nrs_throttling) return NULL; - node = cfs_binheap_root(head->th_binheap); + node = binheap_root(head->th_binheap); if (unlikely(node == NULL)) return NULL; @@ -3099,14 +3099,14 @@ struct ptlrpc_nrs_request *nrs_tbf_req_get(struct ptlrpc_nrs_policy *policy, cli->tc_check_time = now; list_del_init(&nrq->nr_u.tbf.tr_list); if (list_empty(&cli->tc_list)) { - cfs_binheap_remove(head->th_binheap, - &cli->tc_node); + binheap_remove(head->th_binheap, + &cli->tc_node); cli->tc_in_heap = false; } else { if (!(rule->tr_flags & NTRS_REALTIME)) cli->tc_deadline = now + cli->tc_nsecs; - cfs_binheap_relocate(head->th_binheap, - &cli->tc_node); + binheap_relocate(head->th_binheap, + &cli->tc_node); } CDEBUG(D_RPCTRACE, "TBF dequeues: class@%p rate %u gen %llu " @@ -3121,9 +3121,9 @@ struct ptlrpc_nrs_request *nrs_tbf_req_get(struct ptlrpc_nrs_policy *policy, if (rule->tr_flags & NTRS_REALTIME) { cli->tc_deadline = deadline; cli->tc_nsecs_resid = old_resid; - cfs_binheap_relocate(head->th_binheap, - &cli->tc_node); - if (node != cfs_binheap_root(head->th_binheap)) + binheap_relocate(head->th_binheap, + &cli->tc_node); + if (node != binheap_root(head->th_binheap)) return nrs_tbf_req_get(policy, peek, force); } @@ -3163,7 +3163,7 @@ static int nrs_tbf_req_add(struct ptlrpc_nrs_policy *policy, if (list_empty(&cli->tc_list)) { LASSERT(!cli->tc_in_heap); cli->tc_deadline = cli->tc_check_time + cli->tc_nsecs; - rc = cfs_binheap_insert(head->th_binheap, &cli->tc_node); + rc = binheap_insert(head->th_binheap, &cli->tc_node); if (rc == 0) { cli->tc_in_heap = true; nrq->nr_u.tbf.tr_sequence = head->th_sequence++; @@ -3224,12 +3224,12 @@ static void nrs_tbf_req_del(struct ptlrpc_nrs_policy *policy, LASSERT(!list_empty(&nrq->nr_u.tbf.tr_list)); list_del_init(&nrq->nr_u.tbf.tr_list); if (list_empty(&cli->tc_list)) { - cfs_binheap_remove(head->th_binheap, - &cli->tc_node); + binheap_remove(head->th_binheap, + &cli->tc_node); cli->tc_in_heap = false; } else { - cfs_binheap_relocate(head->th_binheap, - &cli->tc_node); + binheap_relocate(head->th_binheap, + &cli->tc_node); } } -- 1.8.3.1