Lines Matching refs:rc
66 zfs_refcount_create(zfs_refcount_t *rc) in zfs_refcount_create() argument
68 mutex_init(&rc->rc_mtx, NULL, MUTEX_DEFAULT, NULL); in zfs_refcount_create()
69 avl_create(&rc->rc_tree, zfs_refcount_compare, sizeof (reference_t), in zfs_refcount_create()
71 list_create(&rc->rc_removed, sizeof (reference_t), in zfs_refcount_create()
73 rc->rc_count = 0; in zfs_refcount_create()
74 rc->rc_removed_count = 0; in zfs_refcount_create()
75 rc->rc_tracked = reference_tracking_enable; in zfs_refcount_create()
79 zfs_refcount_create_tracked(zfs_refcount_t *rc) in zfs_refcount_create_tracked() argument
81 zfs_refcount_create(rc); in zfs_refcount_create_tracked()
82 rc->rc_tracked = B_TRUE; in zfs_refcount_create_tracked()
86 zfs_refcount_create_untracked(zfs_refcount_t *rc) in zfs_refcount_create_untracked() argument
88 zfs_refcount_create(rc); in zfs_refcount_create_untracked()
89 rc->rc_tracked = B_FALSE; in zfs_refcount_create_untracked()
93 zfs_refcount_destroy_many(zfs_refcount_t *rc, uint64_t number) in zfs_refcount_destroy_many() argument
98 ASSERT3U(rc->rc_count, ==, number); in zfs_refcount_destroy_many()
99 while ((ref = avl_destroy_nodes(&rc->rc_tree, &cookie)) != NULL) in zfs_refcount_destroy_many()
101 avl_destroy(&rc->rc_tree); in zfs_refcount_destroy_many()
103 while ((ref = list_remove_head(&rc->rc_removed))) in zfs_refcount_destroy_many()
105 list_destroy(&rc->rc_removed); in zfs_refcount_destroy_many()
106 mutex_destroy(&rc->rc_mtx); in zfs_refcount_destroy_many()
110 zfs_refcount_destroy(zfs_refcount_t *rc) in zfs_refcount_destroy() argument
112 zfs_refcount_destroy_many(rc, 0); in zfs_refcount_destroy()
116 zfs_refcount_is_zero(zfs_refcount_t *rc) in zfs_refcount_is_zero() argument
118 return (zfs_refcount_count(rc) == 0); in zfs_refcount_is_zero()
122 zfs_refcount_count(zfs_refcount_t *rc) in zfs_refcount_count() argument
124 return (atomic_load_64(&rc->rc_count)); in zfs_refcount_count()
128 zfs_refcount_add_many(zfs_refcount_t *rc, uint64_t number, const void *holder) in zfs_refcount_add_many() argument
133 if (likely(!rc->rc_tracked)) { in zfs_refcount_add_many()
134 count = atomic_add_64_nv(&(rc)->rc_count, number); in zfs_refcount_add_many()
143 mutex_enter(&rc->rc_mtx); in zfs_refcount_add_many()
144 avl_add(&rc->rc_tree, ref); in zfs_refcount_add_many()
145 rc->rc_count += number; in zfs_refcount_add_many()
146 count = rc->rc_count; in zfs_refcount_add_many()
147 mutex_exit(&rc->rc_mtx); in zfs_refcount_add_many()
153 zfs_refcount_add(zfs_refcount_t *rc, const void *holder) in zfs_refcount_add() argument
155 return (zfs_refcount_add_many(rc, 1, holder)); in zfs_refcount_add()
159 zfs_refcount_add_few(zfs_refcount_t *rc, uint64_t number, const void *holder) in zfs_refcount_add_few() argument
161 if (likely(!rc->rc_tracked)) in zfs_refcount_add_few()
162 (void) zfs_refcount_add_many(rc, number, holder); in zfs_refcount_add_few()
164 (void) zfs_refcount_add(rc, holder); in zfs_refcount_add_few()
168 zfs_refcount_remove_many(zfs_refcount_t *rc, uint64_t number, in zfs_refcount_remove_many() argument
174 if (likely(!rc->rc_tracked)) { in zfs_refcount_remove_many()
175 count = atomic_add_64_nv(&(rc)->rc_count, -number); in zfs_refcount_remove_many()
183 mutex_enter(&rc->rc_mtx); in zfs_refcount_remove_many()
184 ASSERT3U(rc->rc_count, >=, number); in zfs_refcount_remove_many()
185 ref = avl_find(&rc->rc_tree, &s, NULL); in zfs_refcount_remove_many()
188 (u_longlong_t)(uintptr_t)rc); in zfs_refcount_remove_many()
191 avl_remove(&rc->rc_tree, ref); in zfs_refcount_remove_many()
193 list_insert_head(&rc->rc_removed, ref); in zfs_refcount_remove_many()
194 if (rc->rc_removed_count >= reference_history) { in zfs_refcount_remove_many()
195 ref = list_remove_tail(&rc->rc_removed); in zfs_refcount_remove_many()
198 rc->rc_removed_count++; in zfs_refcount_remove_many()
203 rc->rc_count -= number; in zfs_refcount_remove_many()
204 count = rc->rc_count; in zfs_refcount_remove_many()
205 mutex_exit(&rc->rc_mtx); in zfs_refcount_remove_many()
210 zfs_refcount_remove(zfs_refcount_t *rc, const void *holder) in zfs_refcount_remove() argument
212 return (zfs_refcount_remove_many(rc, 1, holder)); in zfs_refcount_remove()
216 zfs_refcount_remove_few(zfs_refcount_t *rc, uint64_t number, const void *holder) in zfs_refcount_remove_few() argument
218 if (likely(!rc->rc_tracked)) in zfs_refcount_remove_few()
219 (void) zfs_refcount_remove_many(rc, number, holder); in zfs_refcount_remove_few()
221 (void) zfs_refcount_remove(rc, holder); in zfs_refcount_remove_few()
263 zfs_refcount_transfer_ownership_many(zfs_refcount_t *rc, uint64_t number, in zfs_refcount_transfer_ownership_many() argument
268 if (likely(!rc->rc_tracked)) in zfs_refcount_transfer_ownership_many()
274 mutex_enter(&rc->rc_mtx); in zfs_refcount_transfer_ownership_many()
275 ref = avl_find(&rc->rc_tree, &s, NULL); in zfs_refcount_transfer_ownership_many()
278 avl_update(&rc->rc_tree, ref); in zfs_refcount_transfer_ownership_many()
279 mutex_exit(&rc->rc_mtx); in zfs_refcount_transfer_ownership_many()
283 zfs_refcount_transfer_ownership(zfs_refcount_t *rc, const void *current_holder, in zfs_refcount_transfer_ownership() argument
286 return (zfs_refcount_transfer_ownership_many(rc, 1, current_holder, in zfs_refcount_transfer_ownership()
296 zfs_refcount_held(zfs_refcount_t *rc, const void *holder) in zfs_refcount_held() argument
302 if (likely(!rc->rc_tracked)) in zfs_refcount_held()
303 return (zfs_refcount_count(rc) > 0); in zfs_refcount_held()
308 mutex_enter(&rc->rc_mtx); in zfs_refcount_held()
309 ref = avl_find(&rc->rc_tree, &s, &idx); in zfs_refcount_held()
311 ref = avl_nearest(&rc->rc_tree, idx, AVL_AFTER); in zfs_refcount_held()
313 mutex_exit(&rc->rc_mtx); in zfs_refcount_held()
323 zfs_refcount_not_held(zfs_refcount_t *rc, const void *holder) in zfs_refcount_not_held() argument
329 if (likely(!rc->rc_tracked)) in zfs_refcount_not_held()
332 mutex_enter(&rc->rc_mtx); in zfs_refcount_not_held()
336 ref = avl_find(&rc->rc_tree, &s, &idx); in zfs_refcount_not_held()
338 ref = avl_nearest(&rc->rc_tree, idx, AVL_AFTER); in zfs_refcount_not_held()
340 mutex_exit(&rc->rc_mtx); in zfs_refcount_not_held()