Whamcloud - gitweb
LU-9859 libcfs: refactor libcfs initialization. 00/52700/6
authorMr. NeilBrown <neilb@suse.de>
Thu, 9 Nov 2023 02:15:09 +0000 (21:15 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 18 Nov 2023 21:45:12 +0000 (21:45 +0000)
commitf3494a6e9ffeb82bf1b34e557b4cfda1eaf8ef9d
tree540ea8ac2e4fbe7445e77cb3d2b8382ed0dbcf79
parentd0194a4b5f6efa26d5473c2793b525f5fdb77e67
LU-9859 libcfs: refactor libcfs initialization.

Many lustre modules depend on libcfs having initialized
properly, but do not explicit check that it did.
When lustre is built as discrete modules, this does not
cause a problem because if the libcfs module fails
initialization, the other modules don't even get loaded.

When lustre is compiled into the kernel, all module_init()
routines get run, so they need to check the required initialization
succeeded.

This patch splits out the initialization of libcfs into a new
libcfs_setup(), and has all modules call that.

The misc_register() call is kept separate as it does not allocate any
resources and if it fails, it fails hard - no point in retrying.
Other set-up allocates resources and so is best delayed until they
are needed, and can be worth retrying.

Ideally, the initialization would happen at mount time (or similar)
rather than at load time.  Doing this requires each module to
check dependencies when they are activated rather than when
they are loaded.  Achieving that is a much larger job that would
have to progress in stages.

For now, this change ensures that if some initialization in libcfs
fails, other modules will fail-safe.

Linux-commit: 64bf0b1a079d61e9e059b9dc7a58e064c7d994ae

Change-Id: I6b5ecdba0defc6e033f78d8fc2b9be9e26c7f720
Signed-off-by: Mr. NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52700
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>
32 files changed:
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/linux/linux-misc.h
libcfs/libcfs/linux/linux-prim.c
libcfs/libcfs/module.c
lnet/klnds/gnilnd/gnilnd.c
lnet/klnds/kfilnd/kfilnd.c
lnet/klnds/o2iblnd/o2iblnd.c
lnet/klnds/socklnd/socklnd.c
lnet/lnet/module.c
lnet/selftest/module.c
lustre/fid/fid_request.c
lustre/fld/fld_request.c
lustre/lfsck/lfsck_lib.c
lustre/llite/super25.c
lustre/lmv/lmv_obd.c
lustre/lod/lod_dev.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_request.c
lustre/mdd/mdd_device.c
lustre/mdt/mdt_handler.c
lustre/mgc/mgc_request.c
lustre/mgs/mgs_handler.c
lustre/obdclass/class_obd.c
lustre/obdecho/echo_client.c
lustre/ofd/ofd_dev.c
lustre/osc/osc_request.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-zfs/osd_handler.c
lustre/osp/osp_dev.c
lustre/ost/ost_handler.c
lustre/ptlrpc/ptlrpc_module.c
lustre/quota/lquota_lib.c