Whamcloud - gitweb
LU-8066 obdclass: fix module load locking. 43/36043/9
authorMr. NeilBrown <neilb@suse.de>
Fri, 23 Feb 2024 21:07:35 +0000 (16:07 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 13 Mar 2024 03:22:50 +0000 (03:22 +0000)
commit76325fbb0d60b3b6524f101d5c1faa5e004610ec
tree7d0af0b42284eba2dae347c75aca428f24725186
parentea0a44657681c1dc8bf70b77b7e4347ce80ad52c
LU-8066 obdclass: fix module load locking.

Safe module loading requires that we try_module_get() in a context
where the module cannot be unloaded, typically protected by
a spinlock that module-unload has to take.
This doesn't currently happen in class_get_type().

As free_module() calls synchronize_rcu() between calling the
exit function and freeing the module, we can use rcu_read_lock()
to check if the exit function has been called, and try_module_get()
if it hasn't.

We must also check the return status of try_module_get().

Linux-commit: 71707c276e0acff160e7f2bd38d5b61eb1f61ab2

Change-Id: Ia551a951db8fd97db51140123d340b1649a159cd
Signed-off-by: Mr. NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/36043
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/genops.c