Deinitialize locks on cache stop instead of put

Cache lock waiters hold cache refcount. Because of that,
if there were some waiters, deinitialization of cache
lock on the last put did never happen and putting the
cache was effectively impossible.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2019-09-27 12:02:04 +02:00
parent 75569ecaba
commit 96a1fdb17e
2 changed files with 6 additions and 3 deletions

View File

@ -1986,10 +1986,15 @@ static void ocf_mngt_cache_stop_put_io_queues(ocf_pipeline_t pipeline,
static void ocf_mngt_cache_remove(ocf_ctx_t ctx, ocf_cache_t cache) static void ocf_mngt_cache_remove(ocf_ctx_t ctx, ocf_cache_t cache)
{ {
env_rmutex_lock(&ctx->lock);
/* Mark device uninitialized */ /* Mark device uninitialized */
ocf_refcnt_freeze(&cache->refcnt.cache); ocf_refcnt_freeze(&cache->refcnt.cache);
/* Deinitialize locks */
ocf_mngt_cache_lock_deinit(cache);
env_mutex_destroy(&cache->flush_mutex);
/* Remove cache from the list */ /* Remove cache from the list */
env_rmutex_lock(&ctx->lock);
list_del(&cache->list); list_del(&cache->list);
env_rmutex_unlock(&ctx->lock); env_rmutex_unlock(&ctx->lock);
} }

View File

@ -135,8 +135,6 @@ void ocf_mngt_cache_put(ocf_cache_t cache)
if (ocf_refcnt_dec(&cache->refcnt.cache) == 0) { if (ocf_refcnt_dec(&cache->refcnt.cache) == 0) {
ctx = cache->owner; ctx = cache->owner;
ocf_metadata_deinit(cache); ocf_metadata_deinit(cache);
ocf_mngt_cache_lock_deinit(cache);
env_mutex_destroy(&cache->flush_mutex);
env_vfree(cache); env_vfree(cache);
ocf_ctx_put(ctx); ocf_ctx_put(ctx);
} }