Spdk/lib/bdev
Shuhei Matsumoto 284aca9e36 bdev/raid: Fix race issue among multiple threads to free RAID bdev
The following issue was observed.

The first thread returned the last IO channel and the second thread
then removed the first base device, but raid_bdev_cleanup() was
called before raid_bdev_destroy_cb() was called.

raid_bdev_destroy_cb() was accessed to the raid bdev already freed
by raid_bdev_cleanup() and caused segmentation fault.

The call sequence was as follows:

The first thread:
 spdk_put_io_channel() -> ch->destroy_cb -> raid_bdev_destroy_cb
-> access raid bdev

The second thread:
 raid_bdev_remove_base_devices() -> raid_bdev_deconfigure() ->
spdk_bdev_unregister() -> spdk_io_device_unregister() ->
spdk_bdev_destroy_cb() -> raid_bdev_destruct() -> raid_bdev_cleanup()
-> free raid bdev

The fix is to hold number of created channels in struct
raid_bdev_io_channel and use it in raid_bdev_destroy_cb().

Bdev layer, IO device/channel layer, and NVMe-oF layer  already
process this case correctly.

    Fixes #884.

Reported-by: yidong0635 <dongx.yi@intel.com>

Change-Id: Ie9d61bdddca479ce7f491ff9a08db45e71f16a8d
Signed-off-by: yidong0635 <dongx.yi@intel.com>
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463249
Reviewed-by: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Seth Howell <seth.howell@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-08-12 04:20:15 +00:00
..
aio bdev: replace spdk_mb with spdk_smp_mb 2019-07-29 20:54:27 +00:00
compress Remove remaining spdk_jsonrpc_begin_result() NULL checks 2019-08-09 16:35:00 +00:00
crypto crypto: Fix scanbuild issue on Fedora30. 2019-07-23 00:38:27 +00:00
delay Remove remaining spdk_jsonrpc_begin_result() NULL checks 2019-08-09 16:35:00 +00:00
error jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
gpt bdev/gpt: call get buffer function before forwarding read I/O to the base bdev 2019-07-12 02:25:57 +00:00
iscsi bdev_iscsi: fix crash when connecting to a non existing iqn 2019-07-29 03:18:33 +00:00
lvol jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
malloc jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
null jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
nvme nvme: fix json response on failed construct_nvme_bdev RPCs 2019-08-09 16:35:00 +00:00
ocf jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
passthru jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
pmem bdev/pmem: add more descriptive rpc error messages 2019-07-24 18:28:46 +00:00
raid bdev/raid: Fix race issue among multiple threads to free RAID bdev 2019-08-12 04:20:15 +00:00
rbd jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
rpc jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
split jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
uring bdev/uring: adjust to the latest io_uring API 2019-06-07 18:43:07 +00:00
virtio jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
bdev.c bdev: change error to warning 2019-08-05 00:24:05 +00:00
Makefile bdev: add uring in bdev Makefile 2019-06-11 00:26:48 +00:00
part.c bdev/part: Remap DIF reference tag for read/write I/O 2019-07-11 11:14:22 +00:00
scsi_nvme.c bdev: move error union to internal spdk_bdev_io struct 2018-06-26 20:04:07 +00:00
vtune.c mk: don't use '-include spdk/config.h' 2018-10-02 23:13:32 +00:00