Spdk/lib
Dariusz Stojaczyk 1eac307937 rte_vhost: fix deadlock on rte_vhost_driver_unregister()
2 locks are executed in 2 places in opposite orders.
Consider the following scenario, threads A and B:
(A)
 * fdset_event_dispatch() start
   * pfdentry->busy = 1; (lock #1)
   * vhost_user_read_cb() start
     * vhost_destroy_device() start
(B)
 * rte_vhost_driver_unregister() start
   * pthread_mutex_lock(&vsocket->conn_mutex); (lock #2)
   * fdset_del()
     * endless loop, waiting for pfdentry->busy == 0 (lock #1)
(A)
     * vhost_destroy_device() end
     * pthread_mutex_lock(&vsocket->conn_mutex); (lock #2)
       (mutex already locked - deadlock at this point)

Thread B has locked vsocket->conn_mutex and is in while(1)
loop waiting for given fd to change it's busy flag to 0.
Thread A would have to finish vhost_user_read_cb() in order
to set busy flag back to 0, but that can't happen due to
the vsocket->conn_mutex lock.

This patch defers the fdset_del(), so that it's called outside of
vsocket->conn_mutex.

Change-Id: Ifb5d4699bdafe96a573444c11ad4eae3adc359f5
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/375910
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-08-31 19:16:06 -04:00
..
bdev bdev/aio: Add support for blockdev_aio_get_spdk_running_config(). 2017-08-30 14:11:52 -04:00
blob log: rename SPDK_TRACELOG to SPDK_DEBUGLOG 2017-08-29 13:25:58 -04:00
blobfs log: rename SPDK_TRACELOG to SPDK_DEBUGLOG 2017-08-29 13:25:58 -04:00
conf log: Use SPDK_ERRLOG in lieu of fprintf(stderr 2017-05-09 11:28:28 -07:00
copy copy: Move asynchronous module init to event_copy 2017-06-20 13:46:37 -04:00
cunit include: Move the remainder of the code base to stdinc.h 2017-05-08 13:20:36 -07:00
env_dpdk env: Search DPDK memsegs before /proc/self/pagemap for phys addrs 2017-08-29 15:33:13 -04:00
event log: remove uses of SPDK_TRACE_DEBUG 2017-08-29 15:07:13 -04:00
ioat env: Rename spdk_malloc/zmalloc/realloc/free to spdk_dma_(func) 2017-05-31 15:30:27 -04:00
iscsi log: remove uses of SPDK_TRACE_DEBUG 2017-08-29 15:07:13 -04:00
json json: add function to write UTF-16LE strings 2017-07-12 18:12:52 -04:00
jsonrpc log: rename SPDK_TRACELOG to SPDK_DEBUGLOG 2017-08-29 13:25:58 -04:00
log log: remove uses of SPDK_TRACE_DEBUG 2017-08-29 15:07:13 -04:00
nbd lib: replace strerror with strerror_r 2017-08-15 16:47:01 -04:00
net log: remove uses of SPDK_TRACE_DEBUG 2017-08-29 15:07:13 -04:00
nvme log: remove uses of SPDK_TRACE_DEBUG 2017-08-29 15:07:13 -04:00
nvmf nvmf: Remove connect/disconnect_cb from subsystems 2017-08-30 15:07:22 -04:00
rocksdb io_channel: allow user to provide a thread name 2017-08-29 13:11:08 -04:00
rpc rpc: add get_rpc_methods RPC call 2017-08-01 13:43:14 -04:00
scsi log: remove uses of SPDK_TRACE_DEBUG 2017-08-29 15:07:13 -04:00
trace lib: replace strerror with strerror_r 2017-08-15 16:47:01 -04:00
ut_mock blob: add readv/writev support 2017-08-22 18:19:00 -04:00
util io_channel: allow user to provide a thread name 2017-08-29 13:11:08 -04:00
vhost rte_vhost: fix deadlock on rte_vhost_driver_unregister() 2017-08-31 19:16:06 -04:00
Makefile nbd: move nbd code to a new library 2017-08-02 13:27:21 -04:00