From a254a9df03d629ef23d66947bbc1da32db00a34c Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 15 Sep 2023 23:48:15 -0400 Subject: [PATCH] EX-8270 ptlrpc: improve usage of PAGES_POOL PAGES_POOL isn't always used when it should be, let's improve that a bit (and start renaming a function). Test-Parameters: trivial Signed-off-by: Patrick Farrell Change-Id: Ifed59db63d15d61d15712e6df6b8dbae56f2f5b7 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52429 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/ptlrpc/sec_bulk.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lustre/ptlrpc/sec_bulk.c b/lustre/ptlrpc/sec_bulk.c index 689f736..84383b2 100644 --- a/lustre/ptlrpc/sec_bulk.c +++ b/lustre/ptlrpc/sec_bulk.c @@ -263,7 +263,7 @@ static void enc_pools_release_free_pages(long npages, unsigned int pool_idx) LASSERT(pool->epp_pools[p_idx]); LASSERT(pool->epp_pools[p_idx][g_idx] != NULL); - if (pool_idx == 0) + if (pool_idx == PAGES_POOL) __free_page(pool->epp_pools[p_idx][g_idx]); else OBD_FREE_LARGE(pool->epp_pools[p_idx][g_idx], @@ -388,7 +388,7 @@ static unsigned long enc_pools_cleanup(void ***pools, int npools, int pool_idx) if (pools[i]) { for (j = 0; j < PAGES_PER_POOL; j++) { if (pools[i][j]) { - if (pool_idx == 0) { + if (pool_idx == PAGES_POOL) { __free_page(pools[i][j]); } else { OBD_FREE_LARGE(pools[i][j], @@ -509,14 +509,14 @@ static void enc_pools_insert(void ***pools, int npools, int npages, } #define POOL_INIT_SIZE (PTLRPC_MAX_BRW_SIZE / 4) -static int enc_pools_add_pages(int npages, int pool_index) +static int pool_add_pages(int npages, int pool_index) { void ***pools; int npools, alloced = 0; int i, j, rc = -ENOMEM; struct ptlrpc_enc_page_pool *page_pool = page_pools[pool_index]; - if (pool_index == 0) { + if (pool_index == PAGES_POOL) { if (npages < POOL_INIT_SIZE >> PAGE_SHIFT) npages = POOL_INIT_SIZE >> PAGE_SHIFT; } else { @@ -543,7 +543,7 @@ static int enc_pools_add_pages(int npages, int pool_index) goto out_pools; for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) { - if (pool_index == 0) + if (pool_index == PAGES_POOL) pools[i][j] = alloc_page(GFP_NOFS | __GFP_HIGHMEM); else { @@ -678,7 +678,7 @@ static inline int __sptlrpc_enc_pool_get_pages(void *array, unsigned int count, int p_idx, g_idx; int i, rc = 0; - if (pool_idx) + if (pool_idx != PAGES_POOL) count = 1; if (!array || count <= 0 || count > page_pool->epp_max_pages) @@ -703,7 +703,7 @@ again: spin_unlock(&page_pool->epp_lock); CDEBUG(D_SEC, "epp_pages_short: %lu\n", page_pool->epp_pages_short); - enc_pools_add_pages(8, pool_idx); + pool_add_pages(8, pool_idx); spin_lock(&page_pool->epp_lock); page_pool->epp_growing = 0; @@ -952,8 +952,7 @@ int sptlrpc_enc_pool_add_user(void) if (need_grow) { - enc_pools_add_pages(PTLRPC_MAX_BRW_PAGES + - PTLRPC_MAX_BRW_PAGES, 0); + pool_add_pages(PTLRPC_MAX_BRW_PAGES * 2, PAGES_POOL); spin_lock(&page_pools[PAGES_POOL]->epp_lock); page_pools[PAGES_POOL]->epp_growing = 0; -- 1.8.3.1