Whamcloud - gitweb
EX-8270 ptlrpc: improve usage of PAGES_POOL
authorPatrick Farrell <pfarrell@whamcloud.com>
Sat, 16 Sep 2023 03:48:15 +0000 (23:48 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 22 Sep 2023 23:53:14 +0000 (23:53 +0000)
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 <pfarrell@whamcloud.com>
Change-Id: Ifed59db63d15d61d15712e6df6b8dbae56f2f5b7
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52429
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/ptlrpc/sec_bulk.c

index 689f736..84383b2 100644 (file)
@@ -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;