Spdk/module/bdev
Kefu Chai 56d5ded6f2 bdev/null: call spdk_bdev_module_fini_done() even if not registered
in bdev subsystem, if any of the bdev module fails to initialize in
bdev_modules_init(), this function just stops immediately. in general,
the non-zero rc is returned to the callback func passed to spdk_subsystem_init().
if spdk app is used for building the spdk application, it's very
likely that app_start_rpc() is used as this very callback func.
in this case, app_start_rpc() would just pass the `rc` to spdk_app_stop()
which tears down all subsystems one after another.

bdev tears itself down by calling all its modules' module_fini(),
including those whose .module_init never gets called. the problem is,
if a bdev module marks its `.async_fini` true, and it calls
spdk_bdev_module_fini_done() only if spdk_io_device_unregister(),
then a bdev module which fails to initialize would leave us an spdk
application hanging in the air.

a typical logging message sequence looks like:

[2022-02-27 20:47:13.766578] bdev.c:1438:spdk_bdev_initialize: *ERROR*: bdev modules init failed
[2022-02-27 20:47:13.766622] subsystem.c: 169:spdk_subsystem_init_next: *ERROR*: Init subsystem bdev failed
[2022-02-27 20:47:13.766638] app.c: 691:spdk_app_stop: *WARNING*: spdk_app_stop'd on non-zero
[2022-02-27 20:47:13.766658] thread.c:2050:spdk_io_device_unregister: *ERROR*: io_device 0x10d3c30 not found

this is exactly the case we could run into if a bdev module fails to
initialize and bdev_null is unable to call spdk_bdev_module_fini_done()
when being teared down, because spdk_io_device_unregister() just refuses
to call the callback if the I/O device is never registered.

since `g_null_read_buf` is set in bdev_null_initialize(), in this change,
this pointer is checked for zero before calling spdk_io_device_unregister(),
if it is NULL, spdk_bdev_module_fini_done() is called directly instead
of calling spdk_io_device_unregister(). this helps to address the
hanging issue.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11750 (master)

(cherry picked from commit a7d174e2ef)
Change-Id: I3a41fcd2f1c986e416dacecd5ca352dfd1e379b7
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12475
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-06-30 13:32:31 -04:00
..
aio aio: add aio bdev rescan feature 2022-06-30 13:32:31 -04:00
compress vbdev_compress: reduce MAX_NUM_QP 2022-06-30 13:32:31 -04:00
crypto vbdev_crypto: skip handling QAT_ASYM devices 2022-06-30 13:32:31 -04:00
delay bdev/delay: zero-copy support 2022-06-30 13:32:30 -04:00
error bdev/error: properly initialize value of num for inject_error RPC 2021-04-15 21:41:05 +00:00
ftl spelling: module 2022-06-30 13:32:28 -04:00
gpt spelling: module 2022-06-30 13:32:28 -04:00
iscsi Lib/iSCSI: add the LUN Resize support 2022-06-30 13:32:31 -04:00
longhorn Cleanup log messages. 2022-04-05 17:41:49 -04:00
lvol bdev/lvol: asserting lvol ptr before dereference 2021-08-24 07:18:54 +00:00
malloc bdev_malloc: exit early in case of no acceleration task 2022-06-30 13:32:30 -04:00
null bdev/null: call spdk_bdev_module_fini_done() even if not registered 2022-06-30 13:32:31 -04:00
nvme bdev/nvme: Set ana_state_updating only after starting read ANA log page 2022-06-30 13:32:31 -04:00
ocf bdev/ocf: Improve OCF mpools 2022-06-30 13:32:31 -04:00
passthru bdev: Add API to get SPDK memory domains used by bdev 2021-08-20 07:26:10 +00:00
pmem lib/bdev: added spdk_bdev_module_fini_done() 2021-08-23 08:49:56 +00:00
raid spelling: module 2022-06-30 13:32:28 -04:00
rbd bdev/rbd: Support config_param and config_file simultaneously for rbd_register_cluster 2022-06-30 13:32:30 -04:00
split splite/vbdev_split: Free base part bdev on the error path. 2021-03-02 08:02:58 +00:00
uring so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
virtio lib/bdev: added spdk_bdev_module_fini_done() 2021-08-23 08:49:56 +00:00
zone_block spelling: module 2022-06-30 13:32:28 -04:00
Makefile Initial changes. 2022-02-08 15:51:30 -05:00