Lines Matching full:pool

23 	/* The number of objects managed by the pool */
27 /* The queue of requestors waiting for objects from the pool */
33 /* The ID of the thread on which this pool may be used */
35 /* The buffer backing the pool's vios */
37 /* The pool entries */
129 * Metadata vios should use direct allocation and not use the buffer pool, which is
309 * make_vio_pool() - Create a new vio pool.
311 * @pool_size: The number of vios in the pool.
313 * @thread_id: The ID of the thread using this pool.
314 * @vio_type: The type of vios in the pool.
315 * @priority: The priority with which vios from the pool should be enqueued.
317 * @pool_ptr: The resulting pool.
325 struct vio_pool *pool;
330 result = vdo_allocate_extended(pool_size, vios, __func__, &pool);
334 pool->thread_id = thread_id;
335 INIT_LIST_HEAD(&pool->available);
336 INIT_LIST_HEAD(&pool->busy);
338 result = vdo_allocate(pool_size * per_vio_size, "VIO pool buffer", &pool->buffer);
340 free_vio_pool(pool);
344 ptr = pool->buffer;
345 for (pool->size = 0; pool->size < pool_size; pool->size++, ptr += per_vio_size) {
346 struct pooled_vio *pooled = &pool->vios[pool->size];
351 free_vio_pool(pool);
356 pooled->pool = pool;
357 list_add_tail(&pooled->pool_entry, &pool->available);
360 *pool_ptr = pool;
365 * free_vio_pool() - Destroy a vio pool.
366 * @pool: The pool to free.
368 void free_vio_pool(struct vio_pool *pool)
372 if (pool == NULL)
375 /* Remove all available vios from the object pool. */
376 VDO_ASSERT_LOG_ONLY(!vdo_waitq_has_waiters(&pool->waiting),
377 "VIO pool must not have any waiters when being freed");
378 VDO_ASSERT_LOG_ONLY((pool->busy_count == 0),
379 "VIO pool must not have %zu busy entries when being freed",
380 pool->busy_count);
381 VDO_ASSERT_LOG_ONLY(list_empty(&pool->busy),
382 "VIO pool must not have busy entries when being freed");
384 list_for_each_entry_safe(pooled, tmp, &pool->available, pool_entry) {
387 pool->size--;
390 VDO_ASSERT_LOG_ONLY(pool->size == 0,
391 "VIO pool must not have missing entries when being freed");
393 vdo_free(vdo_forget(pool->buffer));
394 vdo_free(pool);
398 * is_vio_pool_busy() - Check whether an vio pool has outstanding entries.
399 * @pool: The vio pool.
401 * Return: True if the pool is busy.
403 bool is_vio_pool_busy(struct vio_pool *pool)
405 return (pool->busy_count != 0);
409 * acquire_vio_from_pool() - Acquire a vio and buffer from the pool (asynchronous).
410 * @pool: The vio pool.
413 void acquire_vio_from_pool(struct vio_pool *pool, struct vdo_waiter *waiter)
417 VDO_ASSERT_LOG_ONLY((pool->thread_id == vdo_get_callback_thread_id()),
420 if (list_empty(&pool->available)) {
421 vdo_waitq_enqueue_waiter(&pool->waiting, waiter);
425 pooled = list_first_entry(&pool->available, struct pooled_vio, pool_entry);
426 pool->busy_count++;
427 list_move_tail(&pooled->pool_entry, &pool->busy);
432 * return_vio_to_pool() - Return a vio to its pool
437 struct vio_pool *pool = vio->pool;
439 VDO_ASSERT_LOG_ONLY((pool->thread_id == vdo_get_callback_thread_id()),
440 "vio pool entry returned on same thread as it was acquired");
444 if (vdo_waitq_has_waiters(&pool->waiting)) {
445 vdo_waitq_notify_next_waiter(&pool->waiting, NULL, vio);
449 list_move_tail(&vio->pool_entry, &pool->available);
450 --pool->busy_count;