Spdk/module/bdev
Kefu Chai a7d174e2ef 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>
Change-Id: I3a41fcd2f1c986e416dacecd5ca352dfd1e379b7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11750
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2022-03-02 08:39:40 +00:00
..
aio bdev/aio: Correct error message when IO fails 2022-02-22 09:03:51 +00:00
compress thread: add spdk_thread_exec_msg() 2022-02-23 10:06:49 +00:00
crypto so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
delay so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
error so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
ftl so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
gpt so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
iscsi so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
lvol so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
malloc so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
null bdev/null: call spdk_bdev_module_fini_done() even if not registered 2022-03-02 08:39:40 +00:00
nvme bdev/nvme: add additional DEBUGLOGs for discovery 2022-02-28 11:06:16 +00:00
ocf bdev/ocf: Improve OCF mpools 2022-03-02 08:34:39 +00:00
passthru so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
pmem so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
raid so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
rbd so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
split so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
uring so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
virtio so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
zone_block so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
Makefile bdev: move bdev_rpc library contents 2020-09-25 11:43:42 +00:00