Spdk/module/bdev
Tomasz Zawadzki 1350922d09 bdev/ocf: take additional reference for ocf_cache
Fixes #1498

When shutting down the application, it was possible to
reference stale ocf_cache pointer. This was the case
when two or more vbdev_ocf devices were based on top
of single cache bdev.

This issue did not occur outside of the shutdown case,
since RPC only allows deletion of the vbdev_ocf.
This erases on disk metadata and next run of the application,
would not detect such vbdev_ocf.

Shutdown meanwhile works different, by first stopping
the instance of running "ocf_mngt_cache" and later detaching
"core" devices (the ones being cached). This prevented
erasing the on disk metadata and allowed for restarted
application to detect vbdev_ocf.
See patch (1292ef2) for details.

Since references to ocf_cache are copied between vbdev_ocf
[see start_cache()], the reference count inside ocf_cache
was limited to original ocf_mngt_cache_start() and
management queue creation. First call into ocf_mngt_cache_stop()
released all references to ocf_cache. Leaving other
vbdev_ocfs pointing to released memory.

This patch works around this issue by increasing ref cnt
on ocf_cache for each vbdev based on top of it.
It allows to call into ocf_mngt_cache_stop(), but not
release the memory for ocf_cache until last vbdev.

Note:
A proper redesign here is in order:
- either rearranging structures to be based around single ocf_cache,
rather than multiple vbdev_ocf instances
- better use of OCF API to reduce book keeping logic in vbdev

There are plans to implement detach/attach in RPC,
so it should be a focus during that effort.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I560a7fbb1c052bf53970e655bdb60803c561a252
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3574
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2020-07-30 04:02:08 +00:00
..
aio bdev/aio: use detected block size as AIO block device data alignment 2020-07-24 09:41:30 +00:00
compress module/compress: add new parm to RPC for create compress vol 2020-07-27 22:39:29 +00:00
crypto bdev/crypto: Stop access bdev_io->internal from bdev module and fix an issue 2020-05-21 09:19:23 +00:00
delay bdev/delay: Return poller status based on completions number 2020-07-08 07:54:38 +00:00
error lib and module: remove remaining _spdk prefixes. 2020-06-01 13:07:30 +00:00
ftl mk/lib: add a check that major and minor version is set for libs. 2020-05-21 09:19:00 +00:00
gpt mk/lib: add a check that major and minor version is set for libs. 2020-05-21 09:19:00 +00:00
iscsi pollers: Fix pollers to return correct busy status 2020-07-07 07:29:31 +00:00
lvol lvol: report io_unit_size as block_size instead of page size 2020-07-17 07:20:14 +00:00
malloc lib/accel: remove the need for the app to allocate an accel_task 2020-07-24 19:38:46 +00:00
null pollers: Fix pollers to return correct busy status 2020-07-07 07:29:31 +00:00
nvme bdev/nvme: Support abort IO by using spdk_nvme_ctrlr_cmd_abort_ext() 2020-07-14 07:54:42 +00:00
ocf bdev/ocf: take additional reference for ocf_cache 2020-07-30 04:02:08 +00:00
passthru bdev/passthru: Support I/O type ABORT 2020-06-09 07:37:29 +00:00
pmem mk/lib: add a check that major and minor version is set for libs. 2020-05-21 09:19:00 +00:00
raid all: Fix warnings found by gcc 9.3.0 and 9.3.1 2020-06-02 09:51:57 +00:00
rbd pollers: Fix pollers to return correct busy status 2020-07-07 07:29:31 +00:00
rpc mk/lib: add a check that major and minor version is set for libs. 2020-05-21 09:19:00 +00:00
split mk/lib: add a check that major and minor version is set for libs. 2020-05-21 09:19:00 +00:00
uring pollers: Fix pollers to return correct busy status 2020-07-07 07:29:31 +00:00
virtio pollers: Fix pollers to return correct busy status 2020-07-07 07:29:31 +00:00
zone_block mk/lib: add a check that major and minor version is set for libs. 2020-05-21 09:19:00 +00:00
Makefile bdev/ftl: Remove NVMe dependencies 2020-01-15 12:24:44 +00:00