Give ocf_ctx get/put semantics

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga
2019-05-22 16:29:42 +02:00
parent 76bcac5b45
commit c903d13ad2
8 changed files with 42 additions and 28 deletions

View File

@@ -1216,6 +1216,8 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
if (result)
goto _cache_mng_init_instance_ERROR;
ocf_ctx_get(ctx);
if (params.locked) {
/* Increment reference counter to match cache_lock /
cache_unlock convention. User is expected to call

View File

@@ -119,11 +119,15 @@ void cache_mng_core_remove_from_cache(struct ocf_cache *cache, int core_id)
void ocf_mngt_cache_put(ocf_cache_t cache)
{
ocf_ctx_t ctx;
OCF_CHECK_NULL(cache);
if (ocf_refcnt_dec(&cache->refcnt.cache) == 0) {
ctx = cache->owner;
ocf_metadata_deinit(cache);
env_vfree(cache);
ocf_ctx_put(ctx);
}
}