From 037a9e2cf6d5b8d6fdbcde02c1c22e22272c5c07 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Mon, 12 Apr 2021 12:53:07 -0600 Subject: [PATCH] LU-13212 osc: fall back to vmalloc for large RPCs For large RPC sizes (16MB+) the page array (4096 brw_page) can become very large (128KB+ with fscrypt) and should fall back to vmalloc() if kmalloc() fails due to memory fragmentation. The mdc/mdt allocations are currently limited to 1MB for readdir RPCs, but it doesn't hurt to prepare them for larger RPCs from clients in the future if this limit is increased. Fixes: 51b32ac2b9b8 ("LU-7990 rpc: increase bulk size") Signed-off-by: Andreas Dilger Change-Id: I56805f5701d6850412664ce0681a1456b9405580 Reviewed-on: https://review.whamcloud.com/43281 Tested-by: jenkins Reviewed-by: Bobi Jam Reviewed-by: Wang Shilong Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/mdc/mdc_request.c | 4 ++-- lustre/mdt/mdt_handler.c | 4 ++-- lustre/mgc/mgc_request.c | 4 ++-- lustre/mgs/mgs_nids.c | 4 ++-- lustre/obdecho/echo_client.c | 10 +++++----- lustre/osc/osc_request.c | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 3ac4b82..0ce7833 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1307,7 +1307,7 @@ static int mdc_read_page_remote(void *data, struct page *page0) fid = &op_data->op_fid1; LASSERT(inode != NULL); - OBD_ALLOC_PTR_ARRAY(page_pool, max_pages); + OBD_ALLOC_PTR_ARRAY_LARGE(page_pool, max_pages); if (page_pool != NULL) { page_pool[0] = page0; } else { @@ -1376,7 +1376,7 @@ static int mdc_read_page_remote(void *data, struct page *page0) } if (page_pool != &page0) - OBD_FREE_PTR_ARRAY(page_pool, max_pages); + OBD_FREE_PTR_ARRAY_LARGE(page_pool, max_pages); RETURN(rc); } diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index e953635..e8d9582 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2535,7 +2535,7 @@ static int mdt_readpage(struct tgt_session_info *tsi) exp_max_brw_size(tsi->tsi_exp)); rdpg->rp_npages = (rdpg->rp_count + PAGE_SIZE - 1) >> PAGE_SHIFT; - OBD_ALLOC_PTR_ARRAY(rdpg->rp_pages, rdpg->rp_npages); + OBD_ALLOC_PTR_ARRAY_LARGE(rdpg->rp_pages, rdpg->rp_npages); if (rdpg->rp_pages == NULL) RETURN(-ENOMEM); @@ -2559,7 +2559,7 @@ free_rdpg: for (i = 0; i < rdpg->rp_npages; i++) if (rdpg->rp_pages[i] != NULL) __free_page(rdpg->rp_pages[i]); - OBD_FREE_PTR_ARRAY(rdpg->rp_pages, rdpg->rp_npages); + OBD_FREE_PTR_ARRAY_LARGE(rdpg->rp_pages, rdpg->rp_npages); if (OBD_FAIL_CHECK(OBD_FAIL_MDS_SENDPAGE)) RETURN(0); diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index ecce505..ba91824 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -1654,7 +1654,7 @@ static int mgc_process_recover_nodemap_log(struct obd_device *obd, if (cfg->cfg_last_idx == 0 || cld_is_nodemap(cld)) nrpages = CONFIG_READ_NRPAGES_INIT; - OBD_ALLOC_PTR_ARRAY(pages, nrpages); + OBD_ALLOC_PTR_ARRAY_LARGE(pages, nrpages); if (pages == NULL) GOTO(out, rc = -ENOMEM); @@ -1824,7 +1824,7 @@ out: break; __free_page(pages[i]); } - OBD_FREE_PTR_ARRAY(pages, nrpages); + OBD_FREE_PTR_ARRAY_LARGE(pages, nrpages); } return rc; } diff --git a/lustre/mgs/mgs_nids.c b/lustre/mgs/mgs_nids.c index 94149c5..42b7309 100644 --- a/lustre/mgs/mgs_nids.c +++ b/lustre/mgs/mgs_nids.c @@ -636,7 +636,7 @@ int mgs_get_ir_logs(struct ptlrpc_request *req) CDEBUG(D_MGS, "Reading IR log %s bufsize %ld.\n", body->mcb_name, bufsize); - OBD_ALLOC_PTR_ARRAY(pages, nrpages); + OBD_ALLOC_PTR_ARRAY_LARGE(pages, nrpages); if (!pages) GOTO(out, rc = -ENOMEM); @@ -682,7 +682,7 @@ out: __free_page(pages[i]); } - OBD_FREE_PTR_ARRAY(pages, nrpages); + OBD_FREE_PTR_ARRAY_LARGE(pages, nrpages); } if (fsdb) diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index d35fbb9..d6cc549 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -2576,13 +2576,13 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, if (rw == OBD_BRW_WRITE) brw_flags = OBD_BRW_ASYNC; - OBD_ALLOC_PTR_ARRAY(pga, npages); + OBD_ALLOC_PTR_ARRAY_LARGE(pga, npages); if (!pga) RETURN(-ENOMEM); - OBD_ALLOC_PTR_ARRAY(pages, npages); + OBD_ALLOC_PTR_ARRAY_LARGE(pages, npages); if (!pages) { - OBD_FREE_PTR_ARRAY(pga, npages); + OBD_FREE_PTR_ARRAY_LARGE(pga, npages); RETURN(-ENOMEM); } @@ -2634,8 +2634,8 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, } __free_page(pgp->pg); } - OBD_FREE_PTR_ARRAY(pga, npages); - OBD_FREE_PTR_ARRAY(pages, npages); + OBD_FREE_PTR_ARRAY_LARGE(pga, npages); + OBD_FREE_PTR_ARRAY_LARGE(pages, npages); RETURN(rc); } diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 6cd0a2c..97062a2 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2301,7 +2301,7 @@ static void sort_brw_pages(struct brw_page **array, int num) static void osc_release_ppga(struct brw_page **ppga, size_t count) { LASSERT(ppga != NULL); - OBD_FREE_PTR_ARRAY(ppga, count); + OBD_FREE_PTR_ARRAY_LARGE(ppga, count); } static int brw_interpret(const struct lu_env *env, @@ -2501,7 +2501,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, if (mem_tight) mpflag = memalloc_noreclaim_save(); - OBD_ALLOC_PTR_ARRAY(pga, page_count); + OBD_ALLOC_PTR_ARRAY_LARGE(pga, page_count); if (pga == NULL) GOTO(out, rc = -ENOMEM); -- 1.8.3.1