From 5e0287258c03cac4a7ace3ef5dba6aada3ded089 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Sat, 11 Nov 2023 15:21:01 -0500 Subject: [PATCH] EX-7601 obd: move module load to function This is a trivial code change to make alloc_compr a bit shorter. Test-Parameters: trivial Signed-off-by: Patrick Farrell Change-Id: I0a790afe7afebde1d223420d9a578529da6ff7e5 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53102 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/obdclass/lustre_compr.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lustre/obdclass/lustre_compr.c b/lustre/obdclass/lustre_compr.c index 0eb2840..b900c88 100644 --- a/lustre/obdclass/lustre_compr.c +++ b/lustre/obdclass/lustre_compr.c @@ -59,6 +59,24 @@ static inline const char *crypto_name_from_type(enum ll_compr_type type, } } +void load_crypto_module(enum ll_compr_type type) +{ + /* Always try to use our built-in modules. + * Do not check request_module ret code, this is best effort + * as it will fail back to kernel's modules. + */ + if ((type == LL_COMPR_TYPE_LZ4FAST || type == LL_COMPR_TYPE_LZ4HC) && + unlikely(!tried_llz4_load)) { + /* lz4 and lz4hc are siblings, treat them together */ + request_module(LLZ4FAST_MOD_NAME); + request_module(LLZ4HC_MOD_NAME); + tried_llz4_load = true; + } else if (type == LL_COMPR_TYPE_GZIP && unlikely(!tried_lgzip_load)) { + request_module(LGZIP_MOD_NAME); + tried_lgzip_load = true; + } +} + int alloc_compr(enum ll_compr_type *type, unsigned int lvl, struct crypto_comp **cc) { @@ -74,20 +92,8 @@ int alloc_compr(enum ll_compr_type *type, unsigned int lvl, LASSERT(*type != LL_COMPR_TYPE_BEST); LASSERT(*type != LL_COMPR_TYPE_FAST); - /* Always try to use our built-in modules. - * Do not check request_module ret code, this is best effort - * as it will fail back to kernel's modules. - */ - if ((*type == LL_COMPR_TYPE_LZ4FAST || *type == LL_COMPR_TYPE_LZ4HC) && - unlikely(!tried_llz4_load)) { - /* lz4 and lz4hc are siblings, treat them together */ - request_module(LLZ4FAST_MOD_NAME); - request_module(LLZ4HC_MOD_NAME); - tried_llz4_load = true; - } else if (*type == LL_COMPR_TYPE_GZIP && unlikely(!tried_lgzip_load)) { - request_module(LGZIP_MOD_NAME); - tried_lgzip_load = true; - } + load_crypto_module(*type); + *cc = crypto_alloc_comp(crypto_name_from_type(*type, lvl), 0, 0); if (IS_ERR(*cc)) { int ret = PTR_ERR(*cc); -- 1.8.3.1