Commit ebd8ef4b authored by Rafal Stefanowski's avatar Rafal Stefanowski Committed by Tomasz Zawadzki
Browse files

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: default avatarRafal Stefanowski <rafal.stefanowski@intel.com>
Change-Id: I77d2ae400110fcb4d491350e5fec334245f4bb90
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5030


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent b3a8025d
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -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);
	}

	/* 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 */