Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-6010 lnet: prevent assert on LNet module unload
[fs/lustre-release.git]
/
lnet
/
lnet
/
module.c
diff --git
a/lnet/lnet/module.c
b/lnet/lnet/module.c
index
197ff25
..
a8f39b3
100644
(file)
--- a/
lnet/lnet/module.c
+++ b/
lnet/lnet/module.c
@@
-53,13
+53,21
@@
lnet_configure(void *arg)
LNET_MUTEX_LOCK(&lnet_config_mutex);
if (!the_lnet.ln_niinit_self) {
LNET_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;
rc = LNetNIInit(LNET_PID_LUSTRE);
if (rc >= 0) {
the_lnet.ln_niinit_self = 1;
rc = 0;
+ } else {
+ module_put(THIS_MODULE);
}
}
}
}
+out:
LNET_MUTEX_UNLOCK(&lnet_config_mutex);
return rc;
}
LNET_MUTEX_UNLOCK(&lnet_config_mutex);
return rc;
}
@@
-67,21
+75,23
@@
lnet_configure(void *arg)
static int
lnet_unconfigure (void)
{
static int
lnet_unconfigure (void)
{
- int refcount;
+ int refcount;
+
+ LNET_MUTEX_LOCK(&lnet_config_mutex);
- LNET_MUTEX_LOCK(&lnet_config_mutex);
+ if (the_lnet.ln_niinit_self) {
+ the_lnet.ln_niinit_self = 0;
+ LNetNIFini();
+ module_put(THIS_MODULE);
+ }
- if (the_lnet.ln_niinit_self) {
- the_lnet.ln_niinit_self = 0;
- LNetNIFini();
- }
+ LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex);
+ refcount = the_lnet.ln_refcount;
+ LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
- LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex);
- refcount = the_lnet.ln_refcount;
- LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
+ LNET_MUTEX_UNLOCK(&lnet_config_mutex);
- LNET_MUTEX_UNLOCK(&lnet_config_mutex);
- return (refcount == 0) ? 0 : -EBUSY;
+ return (refcount == 0) ? 0 : -EBUSY;
}
static int
}
static int