Whamcloud - gitweb
LU-9679 llite: fix possible race with module unload. 20/37020/4
authorMr NeilBrown <neilb@suse.de>
Fri, 3 Jan 2020 00:50:55 +0000 (19:50 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 18 Jan 2020 04:03:53 +0000 (04:03 +0000)
commit89aff2f3a17d26f9b86f9afd1bd4631358586ce5
tree9611b11f2eef0ca7d6b67428cfd305f98f0d74cf
parentb86a2fc524681a9abfffd68c4516dc728e489e08
LU-9679 llite: fix possible race with module unload.

lustre_fill_super() calls client_fill_super() without holding a
reference to the module containing client_fill_super.  If that
module is unloaded at a bad time, this can crash.

To be able to get a reference to the module using
try_get_module(), we need a pointer to the module.

So replace
  lustre_register_client_fill_super() and
  lustre_register_kill_super_cb()
with a single
  lustre_register_super_ops()
which also passed a module pointer.

Then use a spinlock to ensure the module pointer isn't removed
while try_module_get() is running, and use try_module_get() to
ensure we have a reference before calling client_fill_super().

Now that we take the reference to the module before calling
luster_fill_super(), we don't need to take one inside
lustre_fill_super().

Linux-commit: d487fe31f49e78f3cdd826923bf0c340a839ffd8

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I9474622f2a253d9882eae3f0578c50782dd11ad4
Reviewed-on: https://review.whamcloud.com/37020
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_disk.h
lustre/llite/llite_lib.c
lustre/llite/super25.c
lustre/obdclass/obd_mount.c