Lines Matching refs:rc

71 zfs_refcount_create(zfs_refcount_t *rc)  in zfs_refcount_create()  argument
73 mutex_init(&rc->rc_mtx, NULL, MUTEX_DEFAULT, NULL); in zfs_refcount_create()
74 avl_create(&rc->rc_tree, zfs_refcount_compare, sizeof (reference_t), in zfs_refcount_create()
76 list_create(&rc->rc_removed, sizeof (reference_t), in zfs_refcount_create()
78 rc->rc_count = 0; in zfs_refcount_create()
79 rc->rc_removed_count = 0; in zfs_refcount_create()
80 rc->rc_tracked = reference_tracking_enable; in zfs_refcount_create()
84 zfs_refcount_create_tracked(zfs_refcount_t *rc) in zfs_refcount_create_tracked() argument
86 zfs_refcount_create(rc); in zfs_refcount_create_tracked()
87 rc->rc_tracked = B_TRUE; in zfs_refcount_create_tracked()
91 zfs_refcount_create_untracked(zfs_refcount_t *rc) in zfs_refcount_create_untracked() argument
93 zfs_refcount_create(rc); in zfs_refcount_create_untracked()
94 rc->rc_tracked = B_FALSE; in zfs_refcount_create_untracked()
98 zfs_refcount_destroy_many(zfs_refcount_t *rc, uint64_t number) in zfs_refcount_destroy_many() argument
103 ASSERT3U(rc->rc_count, ==, number); in zfs_refcount_destroy_many()
104 while ((ref = avl_destroy_nodes(&rc->rc_tree, &cookie)) != NULL) in zfs_refcount_destroy_many()
106 avl_destroy(&rc->rc_tree); in zfs_refcount_destroy_many()
108 while ((ref = list_remove_head(&rc->rc_removed))) { in zfs_refcount_destroy_many()
112 list_destroy(&rc->rc_removed); in zfs_refcount_destroy_many()
113 mutex_destroy(&rc->rc_mtx); in zfs_refcount_destroy_many()
117 zfs_refcount_destroy(zfs_refcount_t *rc) in zfs_refcount_destroy() argument
119 zfs_refcount_destroy_many(rc, 0); in zfs_refcount_destroy()
123 zfs_refcount_is_zero(zfs_refcount_t *rc) in zfs_refcount_is_zero() argument
125 return (zfs_refcount_count(rc) == 0); in zfs_refcount_is_zero()
129 zfs_refcount_count(zfs_refcount_t *rc) in zfs_refcount_count() argument
131 return (atomic_load_64(&rc->rc_count)); in zfs_refcount_count()
135 zfs_refcount_add_many(zfs_refcount_t *rc, uint64_t number, const void *holder) in zfs_refcount_add_many() argument
140 if (likely(!rc->rc_tracked)) { in zfs_refcount_add_many()
141 count = atomic_add_64_nv(&(rc)->rc_count, number); in zfs_refcount_add_many()
150 mutex_enter(&rc->rc_mtx); in zfs_refcount_add_many()
151 avl_add(&rc->rc_tree, ref); in zfs_refcount_add_many()
152 rc->rc_count += number; in zfs_refcount_add_many()
153 count = rc->rc_count; in zfs_refcount_add_many()
154 mutex_exit(&rc->rc_mtx); in zfs_refcount_add_many()
160 zfs_refcount_add(zfs_refcount_t *rc, const void *holder) in zfs_refcount_add() argument
162 return (zfs_refcount_add_many(rc, 1, holder)); in zfs_refcount_add()
166 zfs_refcount_add_few(zfs_refcount_t *rc, uint64_t number, const void *holder) in zfs_refcount_add_few() argument
168 if (likely(!rc->rc_tracked)) { in zfs_refcount_add_few()
169 (void) zfs_refcount_add_many(rc, number, holder); in zfs_refcount_add_few()
172 (void) zfs_refcount_add(rc, holder); in zfs_refcount_add_few()
177 zfs_refcount_remove_many(zfs_refcount_t *rc, uint64_t number, in zfs_refcount_remove_many() argument
183 if (likely(!rc->rc_tracked)) { in zfs_refcount_remove_many()
184 count = atomic_add_64_nv(&(rc)->rc_count, -number); in zfs_refcount_remove_many()
192 mutex_enter(&rc->rc_mtx); in zfs_refcount_remove_many()
193 ASSERT3U(rc->rc_count, >=, number); in zfs_refcount_remove_many()
194 ref = avl_find(&rc->rc_tree, &s, NULL); in zfs_refcount_remove_many()
197 holder, number, (u_longlong_t)(uintptr_t)rc); in zfs_refcount_remove_many()
199 avl_remove(&rc->rc_tree, ref); in zfs_refcount_remove_many()
203 list_insert_head(&rc->rc_removed, ref); in zfs_refcount_remove_many()
204 if (rc->rc_removed_count >= reference_history) { in zfs_refcount_remove_many()
205 ref = list_remove_tail(&rc->rc_removed); in zfs_refcount_remove_many()
210 rc->rc_removed_count++; in zfs_refcount_remove_many()
215 rc->rc_count -= number; in zfs_refcount_remove_many()
216 count = rc->rc_count; in zfs_refcount_remove_many()
217 mutex_exit(&rc->rc_mtx); in zfs_refcount_remove_many()
222 zfs_refcount_remove(zfs_refcount_t *rc, const void *holder) in zfs_refcount_remove() argument
224 return (zfs_refcount_remove_many(rc, 1, holder)); in zfs_refcount_remove()
228 zfs_refcount_remove_few(zfs_refcount_t *rc, uint64_t number, const void *holder) in zfs_refcount_remove_few() argument
230 if (likely(!rc->rc_tracked)) { in zfs_refcount_remove_few()
231 (void) zfs_refcount_remove_many(rc, number, holder); in zfs_refcount_remove_few()
234 (void) zfs_refcount_remove(rc, holder); in zfs_refcount_remove_few()
277 zfs_refcount_transfer_ownership_many(zfs_refcount_t *rc, uint64_t number, in zfs_refcount_transfer_ownership_many() argument
282 if (likely(!rc->rc_tracked)) in zfs_refcount_transfer_ownership_many()
288 mutex_enter(&rc->rc_mtx); in zfs_refcount_transfer_ownership_many()
289 ref = avl_find(&rc->rc_tree, &s, NULL); in zfs_refcount_transfer_ownership_many()
292 avl_update(&rc->rc_tree, ref); in zfs_refcount_transfer_ownership_many()
293 mutex_exit(&rc->rc_mtx); in zfs_refcount_transfer_ownership_many()
297 zfs_refcount_transfer_ownership(zfs_refcount_t *rc, const void *current_holder, in zfs_refcount_transfer_ownership() argument
300 zfs_refcount_transfer_ownership_many(rc, 1, current_holder, in zfs_refcount_transfer_ownership()
310 zfs_refcount_held(zfs_refcount_t *rc, const void *holder) in zfs_refcount_held() argument
316 if (likely(!rc->rc_tracked)) in zfs_refcount_held()
317 return (zfs_refcount_count(rc) > 0); in zfs_refcount_held()
322 mutex_enter(&rc->rc_mtx); in zfs_refcount_held()
323 ref = avl_find(&rc->rc_tree, &s, &idx); in zfs_refcount_held()
325 ref = avl_nearest(&rc->rc_tree, idx, AVL_AFTER); in zfs_refcount_held()
327 mutex_exit(&rc->rc_mtx); in zfs_refcount_held()
337 zfs_refcount_not_held(zfs_refcount_t *rc, const void *holder) in zfs_refcount_not_held() argument
343 if (likely(!rc->rc_tracked)) in zfs_refcount_not_held()
346 mutex_enter(&rc->rc_mtx); in zfs_refcount_not_held()
350 ref = avl_find(&rc->rc_tree, &s, &idx); in zfs_refcount_not_held()
352 ref = avl_nearest(&rc->rc_tree, idx, AVL_AFTER); in zfs_refcount_not_held()
354 mutex_exit(&rc->rc_mtx); in zfs_refcount_not_held()