static struct ptlrpc_page_pool {
unsigned long ppp_max_pages; /* maximum pages can hold, const */
- unsigned int ppp_max_ptr_pages; /* number of pools, const */
+ unsigned int ppp_max_ptr_pages; /* number of ptr_pages, const */
/*
* wait queue in case of not enough free pages.
*/
/*
- * indicating how idle the pools are, from 0 to MAX_IDLE_IDX
+ * indicating how idle the pool is, from 0 to MAX_IDLE_IDX
* this is counted based on each time when getting pages from
- * the pools, not based on time. which means in case that system
+ * the pool, not based on time. which means in case that system
* is idled for a while but the idle_idx might still be low if no
- * activities happened in the pools.
+ * activities happened in the pool.
*/
unsigned long ppp_idle_idx;
/* in-pool pages bookkeeping */
spinlock_t ppp_lock; /* protect following fields */
- unsigned long ppp_total_pages; /* total pages in pools */
+ unsigned long ppp_total_pages; /* total pages in pool */
unsigned long ppp_free_pages; /* current pages available */
/* statistics */
}
}
- /* free unused pools */
+ /* free unused ptr_pages */
while (p_idx_max1 < p_idx_max2) {
LASSERT(pool->ppp_ptr_pages[p_idx_max2]);
OBD_FREE(pool->ppp_ptr_pages[p_idx_max2], PAGE_SIZE);
/*
* return how many pages cleaned up.
*/
-static unsigned long pool_cleanup(void ***pools, int nptr_pages,
+static unsigned long pool_cleanup(void ***ptr_pages, int nptr_pages,
struct ptlrpc_page_pool *pool)
{
unsigned long cleaned = 0;
int i, j;
for (i = 0; i < nptr_pages; i++) {
- if (pools[i]) {
+ if (ptr_pages[i]) {
for (j = 0; j < PTRS_PER_PAGE; j++) {
- if (pools[i][j]) {
+ if (ptr_pages[i][j]) {
if (pool->ppp_order == 0) {
- __free_page(pools[i][j]);
+ __free_page(ptr_pages[i][j]);
} else {
- OBD_FREE_LARGE(pools[i][j],
+ OBD_FREE_LARGE(ptr_pages[i][j],
element_size(pool));
}
cleaned++;
}
}
- OBD_FREE(pools[i], PAGE_SIZE);
- pools[i] = NULL;
+ OBD_FREE(ptr_pages[i], PAGE_SIZE);
+ ptr_pages[i] = NULL;
}
}
}
/*
- * merge @nptr_pages pointed by @pools which contains @npages new pages
+ * merge @nptr_pages pointed by @ptr_pages which contains @npages new pages
* into current pool.
*
* we have options to avoid most memory copy with some tricks. but we choose
* the simplest way to avoid complexity. It's not frequently called.
*/
-static void pool_insert(void ***pools, int nptr_pages, int npages,
- struct ptlrpc_page_pool *page_pool)
+static void pool_insert_ptrs(void ***ptr_pages, int nptr_pages, int npages,
+ struct ptlrpc_page_pool *page_pool)
{
int freeslot;
int op_idx, np_idx, og_idx, ng_idx;
spin_lock(&page_pool->ppp_lock);
/*
- * (1) fill all the free slots of current pools.
+ * (1) fill all the free slots in current pool ptr_pages
*/
/*
* free slots are those left by rent pages, and the extra ones with
while (freeslot) {
LASSERT(page_pool->ppp_ptr_pages[op_idx][og_idx] == NULL);
- LASSERT(pools[np_idx][ng_idx] != NULL);
+ LASSERT(ptr_pages[np_idx][ng_idx] != NULL);
- page_pool->ppp_ptr_pages[op_idx][og_idx] = pools[np_idx][ng_idx];
- pools[np_idx][ng_idx] = NULL;
+ page_pool->ppp_ptr_pages[op_idx][og_idx] =
+ ptr_pages[np_idx][ng_idx];
+ ptr_pages[np_idx][ng_idx] = NULL;
freeslot--;
}
/*
- * (2) add pools if needed.
+ * (2) add ptr pages if needed.
*/
cur_nptr_page = (page_pool->ppp_total_pages + PTRS_PER_PAGE - 1) /
PTRS_PER_PAGE;
while (cur_nptr_page < end_nptr_page) {
LASSERT(page_pool->ppp_ptr_pages[cur_nptr_page] == NULL);
LASSERT(np_idx < nptr_pages);
- LASSERT(pools[np_idx] != NULL);
+ LASSERT(ptr_pages[np_idx] != NULL);
- page_pool->ppp_ptr_pages[cur_nptr_page++] = pools[np_idx];
- pools[np_idx++] = NULL;
+ page_pool->ppp_ptr_pages[cur_nptr_page++] = ptr_pages[np_idx];
+ ptr_pages[np_idx++] = NULL;
}
/*
- * (3) free useless source pools
+ * (3) free useless source ptr pages
*/
while (np_idx < nptr_pages) {
- LASSERT(pools[np_idx] != NULL);
- CDEBUG(D_SEC, "Free useless pool buffer: %i, %p\n", np_idx,
- pools[np_idx]);
- OBD_FREE(pools[np_idx], PAGE_SIZE);
- pools[np_idx++] = NULL;
+ LASSERT(ptr_pages[np_idx] != NULL);
+ CDEBUG(D_SEC, "Free useless ptr pages: %i, %p\n", np_idx,
+ ptr_pages[np_idx]);
+ OBD_FREE(ptr_pages[np_idx], PAGE_SIZE);
+ ptr_pages[np_idx++] = NULL;
}
page_pool->ppp_total_pages += npages;
#define POOL_INIT_SIZE (PTLRPC_MAX_BRW_SIZE / 4)
static int pool_add_pages(int npages, struct ptlrpc_page_pool *page_pool)
{
- void ***pools;
+ void ***ptr_pages;
int nptr_pages, alloced = 0;
int i, j, rc = -ENOMEM;
unsigned int pool_order = page_pool->ppp_order;
page_pool->ppp_st_grows++;
nptr_pages = npages_to_nptr_pages(npages);
- OBD_ALLOC_PTR_ARRAY(pools, nptr_pages);
- if (pools == NULL)
+ OBD_ALLOC_PTR_ARRAY(ptr_pages, nptr_pages);
+ if (ptr_pages == NULL)
goto out;
for (i = 0; i < nptr_pages; i++) {
- OBD_ALLOC(pools[i], PAGE_SIZE);
- if (pools[i] == NULL)
- goto out_pools;
+ OBD_ALLOC(ptr_pages[i], PAGE_SIZE);
+ if (ptr_pages[i] == NULL)
+ goto out_ptr_pages;
for (j = 0; j < PTRS_PER_PAGE && alloced < npages; j++) {
if (pool_order == 0)
- pools[i][j] = alloc_page(GFP_NOFS |
+ ptr_pages[i][j] = alloc_page(GFP_NOFS |
__GFP_HIGHMEM);
else {
- OBD_ALLOC_LARGE(pools[i][j],
+ OBD_ALLOC_LARGE(ptr_pages[i][j],
element_size(page_pool));
}
- if (pools[i][j] == NULL)
- goto out_pools;
+ if (ptr_pages[i][j] == NULL)
+ goto out_ptr_pages;
alloced++;
}
}
LASSERT(alloced == npages);
- pool_insert(pools, nptr_pages, npages, page_pool);
- CDEBUG(D_SEC, "added %d pages into pools\n", npages);
- OBD_FREE_PTR_ARRAY(pools, nptr_pages);
+ pool_insert_ptrs(ptr_pages, nptr_pages, npages, page_pool);
+ CDEBUG(D_SEC, "added %d pages into pool\n", npages);
+ OBD_FREE_PTR_ARRAY(ptr_pages, nptr_pages);
rc = 0;
-out_pools:
+out_ptr_pages:
if (rc) {
- pool_cleanup(pools, nptr_pages, page_pool);
+ pool_cleanup(ptr_pages, nptr_pages, page_pool);
}
out:
if (rc) {
static int pool_should_grow(int needed, struct ptlrpc_page_pool *pool)
{
/*
- * don't grow if someone else is growing the pools right now,
- * or the pools has reached its full capacity
+ * don't grow if someone else is growing the pool right now,
+ * or the pool has reached its full capacity
*/
if (pool->ppp_growing || pool->ppp_total_pages == pool->ppp_max_pages)
return 0;
* length, idle index, etc. ?
*/
- /* grow the pools in any other cases */
+ /* grow the pool in any other cases */
return 1;
}
/*
* we don't do much stuff for add_user/del_user anymore, except adding some
- * initial pages in add_user() if current pools are empty, rest would be
- * handled by the pools's self-adaption.
+ * initial pages in add_user() if current pool is empty, rest would be
+ * handled by the pool self-adaption.
*/
void sptlrpc_pool_add_user(void)
{