Whamcloud - gitweb
LU-12511 lnet: rework lnd module loading 46/57946/3
authorJames Simmons <jsimmons@infradead.org>
Mon, 3 Feb 2025 15:16:56 +0000 (10:16 -0500)
committerOleg Drokin <green@whamcloud.com>
Tue, 11 Feb 2025 05:33:13 +0000 (05:33 +0000)
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.

Test-Parameters: trivial testlist=sanity-lnet
Change-Id: Ie97b00b6b5c21d6e20acf72f796707630369251e
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57946
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Frank Sehr <fsehr@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/api-ni.c

index 19f191b..1b47621 100644 (file)
@@ -2606,21 +2606,22 @@ static const 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) {
+#ifdef HAVE_MODULE_LOADING_SUPPORT
                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("Your kernel must be compiled with kernel module loading support.");
-#endif
-                       return ERR_PTR(-EINVAL);
+                       lnd = ERR_PTR(rc);
                }
+#else
+               LCONSOLE_ERROR("Your kernel must be compiled with kernel module loading support.");
+               lnd = ERR_PTR(-EINVAL);
+#endif
        }
        mutex_unlock(&the_lnet.ln_lnd_mutex);