From ebd8ef4bc5b76430b226f762d4b3974725a4598f Mon Sep 17 00:00:00 2001 From: Rafal Stefanowski Date: Sun, 1 Nov 2020 04:05:24 +0100 Subject: [PATCH] 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 Change-Id: I77d2ae400110fcb4d491350e5fec334245f4bb90 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5030 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Reviewed-by: Tomasz Zawadzki --- module/bdev/ocf/ctx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/module/bdev/ocf/ctx.c b/module/bdev/ocf/ctx.c index 94060d033..ed9991752 100644 --- a/module/bdev/ocf/ctx.c +++ b/module/bdev/ocf/ctx.c @@ -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 */