Spdk/lib
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
..
bdev bdev/raid: Fix race issue among multiple threads to free RAID bdev 2019-08-12 04:20:15 +00:00
blob blobstore: don't realloc any memory under scan-build 2019-07-23 22:56:23 +00:00
blobfs blobfs: free sync request if got error with flush request allocation 2019-08-12 02:59:24 +00:00
conf string: spdk_strtol to delegate additional error checking 2019-01-29 00:10:57 +00:00
copy jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
env_dpdk env_dpdk: upgrade to C11 atomics 2019-08-05 23:56:32 +00:00
event Remove remaining spdk_jsonrpc_begin_result() NULL checks 2019-08-09 16:35:00 +00:00
ftl lib/ftl: eliminate PAGE_SIZE 2019-08-07 12:36:05 +00:00
ioat ioat: allocate device struct using regular calloc 2019-04-09 06:30:42 +00:00
iscsi Remove remaining spdk_jsonrpc_begin_result() NULL checks 2019-08-09 16:35:00 +00:00
json json_util: fix typo in debug message. 2019-05-31 14:39:53 +00:00
jsonrpc jsonrpc: tolerate null json value for parameters in json-rpc call 2019-07-26 19:30:57 +00:00
log log/rpc: Add logs with more information about rpc error. 2019-08-05 22:48:01 +00:00
lvol lvol: Fix for lvol failed deletion flow 2019-04-02 19:23:22 +00:00
nbd jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
net net/rpc: Add logs with more information about rpc error. 2019-08-05 06:14:58 +00:00
notify lib/notify: rename spdk_notify_get_events to spdk_notify_foreach_event 2019-05-07 06:11:27 +00:00
nvme nvme: move SPDK_NVME_DEFAULT_RETRY_COUNT out from nvme.h 2019-08-09 00:44:50 +00:00
nvmf nvmf: move the assigment of pdu outside the switch 2019-08-09 07:37:12 +00:00
reduce lib/reduce: change and move the max IOVEC define for reduce 2019-07-29 04:36:59 +00:00
rocksdb RocksDB: Remove static and assert for SpdkInitializeThread 2019-07-05 04:19:11 +00:00
rpc Remove remaining spdk_jsonrpc_begin_result() NULL checks 2019-08-09 16:35:00 +00:00
scsi scsi: fail invalid MODE_SELECT requests 2019-08-05 23:15:08 +00:00
sock sock: Fix return value of spdk_sock_group_poll to return number of events 2019-08-02 00:19:43 +00:00
thread thread: Assign not pointer but instance of spdk_cpuset in struct spdk_thread 2019-07-04 00:30:22 +00:00
trace jsonrpc: don't check returned value from spdk_jsonrpc_begin_result() 2019-07-22 05:13:30 +00:00
ut_mock thread: Eliminate use of pthread_self and thread_ids 2019-01-15 16:53:12 +00:00
util dif: Add spdk_dix_remap_ref_tag to remap ref. tag for separate metadata payload 2019-07-11 11:14:22 +00:00
vhost Remove remaining spdk_jsonrpc_begin_result() NULL checks 2019-08-09 16:35:00 +00:00
virtio lib/virtio: change the definition of cookie 2019-06-26 08:03:37 +00:00
vmd lib/vmd: check header_type after the vmd_adapter structure is verified 2019-07-23 19:55:04 +00:00
Makefile configure: unset CONFIG_VHOST on BSD 2019-07-16 11:06:03 +00:00