numam-spdk/module
Tomasz Zawadzki ab691e3d5a 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>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3574 (master)

(cherry picked from commit 1350922d09)
Change-Id: I560a7fbb1c052bf53970e655bdb60803c561a252
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3593
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-07-31 07:07:10 +00:00
..
accel accel: add API to cancel a batch sequence 2020-07-30 06:58:50 +00:00
bdev bdev/ocf: take additional reference for ocf_cache 2020-07-31 07:07:10 +00:00
blob lib/bdev: Add spdk_bdev_abort API 2020-06-08 09:28:27 +00:00
blobfs mk/lib: add a check that major and minor version is set for libs. 2020-05-21 09:19:00 +00:00
env_dpdk mk/lib: add a check that major and minor version is set for libs. 2020-05-21 09:19:00 +00:00
event sock: Save socket subsystem configuration in JSON format 2020-07-13 08:40:15 +00:00
sock sock: Add sock_impl option to disable zero copy on send 2020-07-24 00:30:45 +00:00
Makefile global: rename copy to accel 2020-02-18 08:05:34 +00:00