[lustre-devel] [PATCH 02/27] lnet: rework module loading
James Simmons
jsimmons at infradead.org
Fri Mar 21 06:06:45 PDT 2025
The kernel IS_MODULE() only works in the positive, ie no ifndef.
So rework the LND module loading code to handle if modules are
enabled and use the proper macro. Also don't use request_module
in obdclass module as well unless IS_MODULE is true for Lustre.
WC-bug-id: https://jira.whamcloud.com/browse/LU-12511
Lustre-commit: 6e76d3569bf602d71 ("LU-12511 lnet: rework lnd module loading")
Signed-off-by: James Simmons <jsimmons at infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57946
Reviewed-by: Frank Sehr <fsehr at whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov at whamcloud.com>
Reviewed-by: Chris Horn <chris.horn at hpe.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
---
fs/lustre/obdclass/genops.c | 4 +++-
net/lnet/lnet/api-ni.c | 12 ++++++------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/fs/lustre/obdclass/genops.c b/fs/lustre/obdclass/genops.c
index a3f7b59db47f..0cbc2c7c393d 100644
--- a/fs/lustre/obdclass/genops.c
+++ b/fs/lustre/obdclass/genops.c
@@ -36,6 +36,7 @@
*/
#define DEBUG_SUBSYSTEM S_CLASS
+#include <linux/kconfig.h>
#include <linux/libcfs/libcfs_cpu.h>
#include <obd_class.h>
#include <lustre_log.h>
@@ -97,7 +98,7 @@ static struct obd_type *class_get_type(const char *name)
rcu_read_lock();
type = class_search_type(name);
-
+#if IS_MODULE(CONFIG_LUSTRE_FS)
if (!type) {
const char *modname = name;
@@ -111,6 +112,7 @@ static struct obd_type *class_get_type(const char *name)
rcu_read_lock();
type = class_search_type(name);
}
+#endif
if (type) {
/*
* Holding rcu_read_lock() matches the synchronize_rcu() call
diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c
index 870ae4312d78..d65ccb4e78aa 100644
--- a/net/lnet/lnet/api-ni.c
+++ b/net/lnet/lnet/api-ni.c
@@ -2556,22 +2556,22 @@ static struct lnet_lnd *lnet_load_lnd(u32 lnd_type)
mutex_lock(&the_lnet.ln_lnd_mutex);
lnd = lnet_find_lnd_by_type(lnd_type);
if (!lnd) {
+#if IS_MODULE(CONFIG_LNET)
mutex_unlock(&the_lnet.ln_lnd_mutex);
rc = request_module("%s", libcfs_lnd2modname(lnd_type));
mutex_lock(&the_lnet.ln_lnd_mutex);
lnd = lnet_find_lnd_by_type(lnd_type);
if (!lnd) {
- mutex_unlock(&the_lnet.ln_lnd_mutex);
CERROR("Can't load LND %s, module %s, rc=%d\n",
libcfs_lnd2str(lnd_type),
libcfs_lnd2modname(lnd_type), rc);
-#ifndef HAVE_MODULE_LOADING_SUPPORT
- LCONSOLE_ERROR_MSG(0x104,
- "Your kernel must be compiled with kernel module loading support.");
-#endif
- return ERR_PTR(-EINVAL);
+ lnd = ERR_PTR(-EINVAL);
}
+#else
+ LCONSOLE_ERROR("Could not find LND %s\n", libcfs_lnd2str(lnd_type));
+ lnd = ERR_PTR(-EINVAL);
+#endif
}
mutex_unlock(&the_lnet.ln_lnd_mutex);
--
2.39.3
More information about the lustre-devel
mailing list