105 for (actual_size = 16; actual_size < requested_size; actual_size <<= 1)
113 tipc_ref_table.entries =
table;
114 tipc_ref_table.capacity = requested_size;
115 tipc_ref_table.init_point = 1;
116 tipc_ref_table.first_free = 0;
117 tipc_ref_table.last_free = 0;
118 tipc_ref_table.index_mask = actual_size - 1;
119 tipc_ref_table.start_mask = start & ~tipc_ref_table.index_mask;
129 if (!tipc_ref_table.entries)
132 vfree(tipc_ref_table.entries);
133 tipc_ref_table.entries =
NULL;
156 pr_err(
"Attempt to acquire ref. to non-existent obj\n");
159 if (!tipc_ref_table.entries) {
160 pr_err(
"Ref. table not found in acquisition attempt\n");
166 if (tipc_ref_table.first_free) {
167 index = tipc_ref_table.first_free;
168 entry = &(tipc_ref_table.entries[
index]);
169 index_mask = tipc_ref_table.index_mask;
170 next_plus_upper = entry->
ref;
171 tipc_ref_table.first_free = next_plus_upper & index_mask;
172 ref = (next_plus_upper & ~index_mask) + index;
173 }
else if (tipc_ref_table.init_point < tipc_ref_table.capacity) {
174 index = tipc_ref_table.init_point++;
175 entry = &(tipc_ref_table.entries[
index]);
177 ref = tipc_ref_table.start_mask +
index;
188 spin_lock_bh(&entry->
lock);
191 *lock = &entry->
lock;
213 if (!tipc_ref_table.entries) {
214 pr_err(
"Ref. table not found during discard attempt\n");
218 index_mask = tipc_ref_table.index_mask;
219 index = ref & index_mask;
220 entry = &(tipc_ref_table.entries[
index]);
225 pr_err(
"Attempt to discard ref. to non-existent obj\n");
228 if (entry->
ref != ref) {
229 pr_err(
"Attempt to discard non-existent reference\n");
238 entry->
ref = (ref & ~index_mask) + (index_mask + 1);
241 if (tipc_ref_table.first_free == 0)
242 tipc_ref_table.first_free =
index;
244 tipc_ref_table.entries[tipc_ref_table.last_free].ref |=
index;
245 tipc_ref_table.last_free =
index;
256 if (
likely(tipc_ref_table.entries)) {
259 entry = &tipc_ref_table.entries[ref &
260 tipc_ref_table.index_mask];
262 spin_lock_bh(&entry->
lock);
265 spin_unlock_bh(&entry->
lock);
277 if (
likely(tipc_ref_table.entries)) {
280 entry = &tipc_ref_table.entries[ref &
281 tipc_ref_table.index_mask];