bdev/ocf: Fix metadata updater call

OCF metadata updater is handling all the requests at once and when
it finishes the cache can deinitialize, so in the rare circumstances
when the thread is not aware of cache not existing any more, there
is another metadata kick request and check for the random pointer
is performed instead of expected cache.
The solution is to increase/decrease cache ref count prior sending
a message to a thread and after metadata has been updated.

Fixes #1533

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
Change-Id: I77d2ae400110fcb4d491350e5fec334245f4bb90
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5030
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Rafal Stefanowski 2020-11-01 04:05:24 +01:00 committed by Tomasz Zawadzki
parent b3a8025d1e
commit ebd8ef4bc5

View File

@ -438,9 +438,10 @@ vbdev_ocf_md_kick(void *ctx)
ocf_metadata_updater_t mu = ctx;
ocf_cache_t cache = ocf_metadata_updater_get_cache(mu);
if (ocf_cache_is_running(cache)) {
ocf_metadata_updater_run(mu);
}
ocf_metadata_updater_run(mu);
/* Decrease cache ref count after metadata has been updated */
ocf_mngt_cache_put(cache);
}
static int
@ -463,6 +464,11 @@ static void
vbdev_ocf_volume_updater_kick(ocf_metadata_updater_t mu)
{
struct spdk_thread *md_thread = ocf_metadata_updater_get_priv(mu);
ocf_cache_t cache = ocf_metadata_updater_get_cache(mu);
/* Increase cache ref count prior sending a message to a thread
* for metadata update */
ocf_mngt_cache_get(cache);
/* We need to send message to updater thread because
* kick can happen from any thread */