Lines Matching refs:ulist

47 void ulist_init(struct ulist *ulist)  in ulist_init()  argument
49 INIT_LIST_HEAD(&ulist->nodes); in ulist_init()
50 ulist->root = RB_ROOT; in ulist_init()
51 ulist->nnodes = 0; in ulist_init()
61 void ulist_release(struct ulist *ulist) in ulist_release() argument
66 list_for_each_entry_safe(node, next, &ulist->nodes, list) { in ulist_release()
69 ulist->root = RB_ROOT; in ulist_release()
70 INIT_LIST_HEAD(&ulist->nodes); in ulist_release()
80 void ulist_reinit(struct ulist *ulist) in ulist_reinit() argument
82 ulist_release(ulist); in ulist_reinit()
83 ulist_init(ulist); in ulist_reinit()
92 struct ulist *ulist_alloc(gfp_t gfp_mask) in ulist_alloc()
94 struct ulist *ulist = kmalloc(sizeof(*ulist), gfp_mask); in ulist_alloc() local
96 if (!ulist) in ulist_alloc()
99 ulist_init(ulist); in ulist_alloc()
101 return ulist; in ulist_alloc()
110 void ulist_free(struct ulist *ulist) in ulist_free() argument
112 if (!ulist) in ulist_free()
114 ulist_release(ulist); in ulist_free()
115 kfree(ulist); in ulist_free()
118 static struct ulist_node *ulist_rbtree_search(struct ulist *ulist, u64 val) in ulist_rbtree_search() argument
120 struct rb_node *n = ulist->root.rb_node; in ulist_rbtree_search()
135 static void ulist_rbtree_erase(struct ulist *ulist, struct ulist_node *node) in ulist_rbtree_erase() argument
137 rb_erase(&node->rb_node, &ulist->root); in ulist_rbtree_erase()
140 BUG_ON(ulist->nnodes == 0); in ulist_rbtree_erase()
141 ulist->nnodes--; in ulist_rbtree_erase()
144 static int ulist_rbtree_insert(struct ulist *ulist, struct ulist_node *ins) in ulist_rbtree_insert() argument
146 struct rb_node **p = &ulist->root.rb_node; in ulist_rbtree_insert()
162 rb_insert_color(&ins->rb_node, &ulist->root); in ulist_rbtree_insert()
186 int ulist_add(struct ulist *ulist, u64 val, u64 aux, gfp_t gfp_mask) in ulist_add() argument
188 return ulist_add_merge(ulist, val, aux, NULL, gfp_mask); in ulist_add()
191 int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux, in ulist_add_merge() argument
197 node = ulist_rbtree_search(ulist, val); in ulist_add_merge()
210 ret = ulist_rbtree_insert(ulist, node); in ulist_add_merge()
212 list_add_tail(&node->list, &ulist->nodes); in ulist_add_merge()
213 ulist->nnodes++; in ulist_add_merge()
228 int ulist_del(struct ulist *ulist, u64 val, u64 aux) in ulist_del() argument
232 node = ulist_rbtree_search(ulist, val); in ulist_del()
241 ulist_rbtree_erase(ulist, node); in ulist_del()
261 struct ulist_node *ulist_next(struct ulist *ulist, struct ulist_iterator *uiter) in ulist_next() argument
265 if (list_empty(&ulist->nodes)) in ulist_next()
267 if (uiter->cur_list && uiter->cur_list->next == &ulist->nodes) in ulist_next()
272 uiter->cur_list = ulist->nodes.next; in ulist_next()