Lines Matching refs:ulist

49 void ulist_init(struct ulist *ulist)  in ulist_init()  argument
51 INIT_LIST_HEAD(&ulist->nodes); in ulist_init()
52 ulist->root = RB_ROOT; in ulist_init()
53 ulist->nnodes = 0; in ulist_init()
64 void ulist_release(struct ulist *ulist) in ulist_release() argument
69 list_for_each_entry_safe(node, next, &ulist->nodes, list) { in ulist_release()
72 ulist->root = RB_ROOT; in ulist_release()
73 INIT_LIST_HEAD(&ulist->nodes); in ulist_release()
84 void ulist_reinit(struct ulist *ulist) in ulist_reinit() argument
86 ulist_release(ulist); in ulist_reinit()
87 ulist_init(ulist); in ulist_reinit()
97 struct ulist *ulist_alloc(gfp_t gfp_mask) in ulist_alloc()
99 struct ulist *ulist = kmalloc(sizeof(*ulist), gfp_mask); in ulist_alloc() local
101 if (!ulist) in ulist_alloc()
104 ulist_init(ulist); in ulist_alloc()
106 return ulist; in ulist_alloc()
116 void ulist_free(struct ulist *ulist) in ulist_free() argument
118 if (!ulist) in ulist_free()
120 ulist_release(ulist); in ulist_free()
121 kfree(ulist); in ulist_free()
124 static struct ulist_node *ulist_rbtree_search(struct ulist *ulist, u64 val) in ulist_rbtree_search() argument
126 struct rb_node *n = ulist->root.rb_node; in ulist_rbtree_search()
141 static void ulist_rbtree_erase(struct ulist *ulist, struct ulist_node *node) in ulist_rbtree_erase() argument
143 rb_erase(&node->rb_node, &ulist->root); in ulist_rbtree_erase()
146 BUG_ON(ulist->nnodes == 0); in ulist_rbtree_erase()
147 ulist->nnodes--; in ulist_rbtree_erase()
150 static int ulist_rbtree_insert(struct ulist *ulist, struct ulist_node *ins) in ulist_rbtree_insert() argument
152 struct rb_node **p = &ulist->root.rb_node; in ulist_rbtree_insert()
168 rb_insert_color(&ins->rb_node, &ulist->root); in ulist_rbtree_insert()
193 int ulist_add(struct ulist *ulist, u64 val, u64 aux, gfp_t gfp_mask) in ulist_add() argument
195 return ulist_add_merge(ulist, val, aux, NULL, gfp_mask); in ulist_add()
198 int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux, in ulist_add_merge() argument
204 node = ulist_rbtree_search(ulist, val); in ulist_add_merge()
217 ret = ulist_rbtree_insert(ulist, node); in ulist_add_merge()
219 list_add_tail(&node->list, &ulist->nodes); in ulist_add_merge()
220 ulist->nnodes++; in ulist_add_merge()
235 int ulist_del(struct ulist *ulist, u64 val, u64 aux) in ulist_del() argument
239 node = ulist_rbtree_search(ulist, val); in ulist_del()
248 ulist_rbtree_erase(ulist, node); in ulist_del()
269 struct ulist_node *ulist_next(const struct ulist *ulist, struct ulist_iterator *uiter) in ulist_next() argument
273 if (list_empty(&ulist->nodes)) in ulist_next()
275 if (uiter->cur_list && uiter->cur_list->next == &ulist->nodes) in ulist_next()
280 uiter->cur_list = ulist->nodes.next; in ulist_next()