summaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lnet/lnet/module.c
diff options
context:
space:
mode:
authorAmir Shehata <amir.shehata@intel.com>2016-02-22 17:29:18 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-22 18:05:49 -0800
commit341bc96085f4dfbc2427d746753faf9edf789f90 (patch)
treef6292ba8717405a9be8971c2794d4d8e2084fede /drivers/staging/lustre/lnet/lnet/module.c
parent94bfb3cff238514d4049f719bfe99116f51d1c8c (diff)
downloadop-kernel-dev-341bc96085f4dfbc2427d746753faf9edf789f90.zip
op-kernel-dev-341bc96085f4dfbc2427d746753faf9edf789f90.tar.gz
staging: lustre: prevent assert on LNet module unload
There is a use case where lnet can be unloaded while there are no NIs configured. Removing lnet in this case will cause LNetFini() to be called without a prior call to LNetNIFini(). This will cause the LASSERT(the_lnet.ln_refcount == 0) to be triggered. To deal with this use case when LNet is configured a reference count on the module is taken using try_module_get(). This way LNet must be unconfigured before it could be removed; therefore avoiding the above case. When LNet is unconfigured module_put() is called to return the reference count. Signed-off-by: Amir Shehata <amir.shehata@intel.com> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6010 Reviewed-on: http://review.whamcloud.com/13110 Reviewed-by: James Simmons <uja.ornl@gmail.com> Reviewed-by: Doug Oucharek <doug.s.oucharek@intel.com> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre/lnet/lnet/module.c')
-rw-r--r--drivers/staging/lustre/lnet/lnet/module.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c
index 8f053d7..e12fe37 100644
--- a/drivers/staging/lustre/lnet/lnet/module.c
+++ b/drivers/staging/lustre/lnet/lnet/module.c
@@ -53,13 +53,21 @@ lnet_configure(void *arg)
mutex_lock(&lnet_config_mutex);
if (!the_lnet.ln_niinit_self) {
+ rc = try_module_get(THIS_MODULE);
+
+ if (rc != 1)
+ goto out;
+
rc = LNetNIInit(LNET_PID_LUSTRE);
if (rc >= 0) {
the_lnet.ln_niinit_self = 1;
rc = 0;
+ } else {
+ module_put(THIS_MODULE);
}
}
+out:
mutex_unlock(&lnet_config_mutex);
return rc;
}
@@ -74,6 +82,7 @@ lnet_unconfigure(void)
if (the_lnet.ln_niinit_self) {
the_lnet.ln_niinit_self = 0;
LNetNIFini();
+ module_put(THIS_MODULE);
}
mutex_lock(&the_lnet.ln_api_mutex);
OpenPOWER on IntegriCloud