Spdk/module/bdev/ocf
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
..
ctx.c pollers: Fix pollers to return correct busy status 2020-07-07 07:29:31 +00:00
ctx.h lib/bdev/ocf: fix potential issue around base->management_channel 2019-10-18 17:31:39 +00:00
data.c mk: move the bdev modules under module directory. 2019-08-22 16:29:49 +00:00
data.h mk: move the bdev modules under module directory. 2019-08-22 16:29:49 +00:00
Makefile mk/lib: add a check that major and minor version is set for libs. 2020-05-21 09:19:00 +00:00
stats.c ocf: update ocf submodule to v20.3 2020-04-17 07:32:48 +00:00
stats.h ocf: update ocf submodule to v20.3 2020-04-17 07:32:48 +00:00
utils.c lib/bdev/ocf: remove unused code related to polling utils 2019-10-22 17:22:41 +00:00
utils.h lib/bdev/ocf: increase capabilites of vbdev_ocf_mngt_stop function 2019-10-22 17:22:41 +00:00
vbdev_ocf_rpc.c module/bdev_ocf: remove spdk prefix from static functions. 2020-05-15 07:58:03 +00:00
vbdev_ocf.c bdev/ocf: take additional reference for ocf_cache 2020-07-30 04:02:08 +00:00
vbdev_ocf.h bdev/ocf: Fix typo about vbdev_ocf_qctx. 2020-04-29 06:42:55 +00:00
volume.c bdev/ocf: Fix typo about vbdev_ocf_qctx. 2020-04-29 06:42:55 +00:00
volume.h mk: move the bdev modules under module directory. 2019-08-22 16:29:49 +00:00