numam-spdk/test
Darek Stojaczyk a33e0943b0 memory: forbid registering a memory region more than once
Removed the reference count from the registrations map.

Although technically supported, registering a single memory
region more than once had a lot of unhandled cases and could
easily lead to a segfault.

RDMA maps require all memory to be unregistered in the same
chunks the memory was registered, which is often impossible
to achieve if a region was registered more than once:

1. register region    0x0 - 0x3 -> it gets mapped to
                                   a single ibv_mr
2. register region    0x1 - 0x2 -> nothing happens, this region
                                   is already registered
3. unregister region  0x0 - 0x3 -> 0x0-0x1 gets unregistered as
                                   one region. 0x2-0x3 gets
                                   unregistered as another
                                   (leading to segfault in the
                                   the current RDMA implementation)

The problem is that the last two regions share the same ibv_mr,
which SPDK tries to free twice. The second free causes a segfault.
vtophys map handles this case by registering each 2MB chunk
separately, but this solution cannot be applied for RDMA, as
NICs put a limitation (~2048) on the number of regions registered.

Another option is to keep a refcount of each ibv_mr allocated,
and free it only when the entire region was unregistered from the
SPDK mem map. This is however very tricky and RDMAmojo mentions
that freeing a memory buffer before unregistering its ibv_mr
may lead to a segfault.

Change-Id: I545c56e24ffa55bda211dea22aeb8a55d9631fe5
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/426085
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
2018-10-11 18:59:11 +00:00
..
app make: simplify rdma dependency linking 2018-09-14 22:56:46 +00:00
bdev Check file permissions in the check_format script 2018-10-04 23:08:12 +00:00
blobfs scripts: use python3 in all scripts 2018-09-14 22:24:30 +00:00
blobstore blobstore: Add tests for bdev_blob_queue_io in blobstore 2018-09-18 16:38:49 +00:00
common Check file permissions in the check_format script 2018-10-04 23:08:12 +00:00
config_converter scripts: add config converter 2018-09-18 15:24:40 +00:00
cpp_headers build: add @: to remaining 'all' targets 2018-02-14 17:38:25 -05:00
env memory: forbid registering a memory region more than once 2018-10-11 18:59:11 +00:00
event test/event_perf: use less memory 2018-07-26 05:28:52 +00:00
ioat ioat: remove ioat kperf kernel driver test harness 2018-04-30 17:11:53 +00:00
iscsi_tgt QoS/Bdev: add the RPC support for the bandwidth rate limit 2018-10-09 18:26:44 +00:00
json_config Check file permissions in the check_format script 2018-10-04 23:08:12 +00:00
lvol Check file permissions in the check_format script 2018-10-04 23:08:12 +00:00
nvme CONFIG: add missing CONFIG_ options 2018-10-04 21:31:42 +00:00
nvmf test/nvmf: Expand shutdown test 2018-10-04 22:59:57 +00:00
pmem Check file permissions in the check_format script 2018-10-04 23:08:12 +00:00
spdkcli QoS/Bdev: add the RPC support for the bandwidth rate limit 2018-10-09 18:26:44 +00:00
unit sock: Update the spdk_sock_getaddr function. 2018-10-11 04:58:49 +00:00
vhost test/vhost: test vm booting from vhost controller 2018-10-04 23:27:40 +00:00
Makefile test: move lib/json up to test app directory 2018-03-29 00:31:24 -04:00
spdk_cunit.h test: remove leftover spdk_cunit declaration 2018-07-06 22:47:56 +00:00