MCPcopy Create free account
hub / github.com/F-Stack/f-stack / unique_insert

Function unique_insert

freebsd/contrib/openzfs/module/zfs/unique.c:74–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74uint64_t
75unique_insert(uint64_t value)
76{
77 avl_index_t idx;
78 unique_t *un = kmem_alloc(sizeof (unique_t), KM_SLEEP);
79
80 un->un_value = value;
81
82 mutex_enter(&unique_mtx);
83 while (un->un_value == 0 || un->un_value & ~UNIQUE_MASK ||
84 avl_find(&unique_avl, un, &idx)) {
85 mutex_exit(&unique_mtx);
86 (void) random_get_pseudo_bytes((void*)&un->un_value,
87 sizeof (un->un_value));
88 un->un_value &= UNIQUE_MASK;
89 mutex_enter(&unique_mtx);
90 }
91
92 avl_insert(&unique_avl, un, idx);
93 mutex_exit(&unique_mtx);
94
95 return (un->un_value);
96}
97
98void
99unique_remove(uint64_t value)

Callers 2

unique_createFunction · 0.85
dsl_dataset_hold_objFunction · 0.85

Calls 5

mutex_enterFunction · 0.85
avl_findFunction · 0.85
mutex_exitFunction · 0.85
avl_insertFunction · 0.85
random_get_pseudo_bytesFunction · 0.50

Tested by

no test coverage detected