Lines Matching refs:pool

217     smb_idpool_t	*pool)  in smb_idpool_increment()  argument
222 ASSERT(pool->id_magic == SMB_IDPOOL_MAGIC); in smb_idpool_increment()
224 new_size = pool->id_size * 2; in smb_idpool_increment()
229 bcopy(pool->id_pool, new_pool, pool->id_size / 8); in smb_idpool_increment()
230 kmem_free(pool->id_pool, pool->id_size / 8); in smb_idpool_increment()
231 pool->id_pool = new_pool; in smb_idpool_increment()
232 pool->id_free_counter += new_size - pool->id_size; in smb_idpool_increment()
233 pool->id_max_free_counter += new_size - pool->id_size; in smb_idpool_increment()
234 pool->id_size = new_size; in smb_idpool_increment()
235 pool->id_idx_msk = (new_size / 8) - 1; in smb_idpool_increment()
238 pool->id_pool[pool->id_idx_msk] = 0x80; in smb_idpool_increment()
239 pool->id_free_counter--; in smb_idpool_increment()
240 pool->id_max_free_counter--; in smb_idpool_increment()
255 smb_idpool_t *pool) in smb_idpool_constructor() argument
258 ASSERT(pool->id_magic != SMB_IDPOOL_MAGIC); in smb_idpool_constructor()
260 pool->id_size = SMB_IDPOOL_MIN_SIZE; in smb_idpool_constructor()
261 pool->id_idx_msk = (SMB_IDPOOL_MIN_SIZE / 8) - 1; in smb_idpool_constructor()
262 pool->id_free_counter = SMB_IDPOOL_MIN_SIZE - 1; in smb_idpool_constructor()
263 pool->id_max_free_counter = SMB_IDPOOL_MIN_SIZE - 1; in smb_idpool_constructor()
264 pool->id_bit = 0x02; in smb_idpool_constructor()
265 pool->id_bit_idx = 1; in smb_idpool_constructor()
266 pool->id_idx = 0; in smb_idpool_constructor()
267 pool->id_pool = (uint8_t *)kmem_alloc((SMB_IDPOOL_MIN_SIZE / 8), in smb_idpool_constructor()
269 bzero(pool->id_pool, (SMB_IDPOOL_MIN_SIZE / 8)); in smb_idpool_constructor()
271 pool->id_pool[0] = 0x01; /* id 0 made unavailable */ in smb_idpool_constructor()
272 mutex_init(&pool->id_mutex, NULL, MUTEX_DEFAULT, NULL); in smb_idpool_constructor()
273 pool->id_magic = SMB_IDPOOL_MAGIC; in smb_idpool_constructor()
285 smb_idpool_t *pool) in smb_idpool_destructor() argument
287 ASSERT(pool->id_magic == SMB_IDPOOL_MAGIC); in smb_idpool_destructor()
288 ASSERT(pool->id_free_counter == pool->id_max_free_counter); in smb_idpool_destructor()
289 pool->id_magic = (uint32_t)~SMB_IDPOOL_MAGIC; in smb_idpool_destructor()
290 mutex_destroy(&pool->id_mutex); in smb_idpool_destructor()
291 kmem_free(pool->id_pool, (size_t)(pool->id_size / 8)); in smb_idpool_destructor()
301 smb_idpool_t *pool, in smb_idpool_alloc() argument
309 ASSERT(pool->id_magic == SMB_IDPOOL_MAGIC); in smb_idpool_alloc()
311 mutex_enter(&pool->id_mutex); in smb_idpool_alloc()
312 if ((pool->id_free_counter == 0) && smb_idpool_increment(pool)) { in smb_idpool_alloc()
313 mutex_exit(&pool->id_mutex); in smb_idpool_alloc()
317 i = pool->id_size; in smb_idpool_alloc()
319 bit = pool->id_bit; in smb_idpool_alloc()
320 bit_idx = pool->id_bit_idx; in smb_idpool_alloc()
321 byte = pool->id_pool[pool->id_idx]; in smb_idpool_alloc()
328 pool->id_pool[pool->id_idx] |= bit; in smb_idpool_alloc()
329 *id = (uint16_t)(pool->id_idx * 8 + (uint32_t)bit_idx); in smb_idpool_alloc()
330 pool->id_free_counter--; in smb_idpool_alloc()
338 pool->id_bit = 1; in smb_idpool_alloc()
339 pool->id_bit_idx = 0; in smb_idpool_alloc()
340 pool->id_idx++; in smb_idpool_alloc()
341 pool->id_idx &= pool->id_idx_msk; in smb_idpool_alloc()
343 pool->id_bit = (bit << 1); in smb_idpool_alloc()
344 pool->id_bit_idx = bit_idx + 1; in smb_idpool_alloc()
347 mutex_exit(&pool->id_mutex); in smb_idpool_alloc()
350 pool->id_bit = 1; in smb_idpool_alloc()
351 pool->id_bit_idx = 0; in smb_idpool_alloc()
352 pool->id_idx++; in smb_idpool_alloc()
353 pool->id_idx &= pool->id_idx_msk; in smb_idpool_alloc()
361 mutex_exit(&pool->id_mutex); in smb_idpool_alloc()
372 smb_idpool_t *pool, in smb_idpool_free() argument
375 ASSERT(pool->id_magic == SMB_IDPOOL_MAGIC); in smb_idpool_free()
379 mutex_enter(&pool->id_mutex); in smb_idpool_free()
380 if (pool->id_pool[id >> 3] & (1 << (id & 7))) { in smb_idpool_free()
381 pool->id_pool[id >> 3] &= ~(1 << (id & 7)); in smb_idpool_free()
382 pool->id_free_counter++; in smb_idpool_free()
383 ASSERT(pool->id_free_counter <= pool->id_max_free_counter); in smb_idpool_free()
384 mutex_exit(&pool->id_mutex); in smb_idpool_free()
389 mutex_exit(&pool->id_mutex); in smb_idpool_free()