Change ctx lock to rmutex
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
@@ -704,7 +704,7 @@ static int _ocf_mngt_init_prepare_cache(struct ocf_cache_mngt_init_params *param
|
||||
char cache_name[OCF_CACHE_NAME_SIZE];
|
||||
int ret = 0;
|
||||
|
||||
ret = env_mutex_lock_interruptible(¶m->ctx->lock);
|
||||
ret = env_rmutex_lock_interruptible(¶m->ctx->lock);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -762,7 +762,7 @@ static int _ocf_mngt_init_prepare_cache(struct ocf_cache_mngt_init_params *param
|
||||
cache->metadata.is_volatile = cfg->metadata_volatile;
|
||||
|
||||
out:
|
||||
env_mutex_unlock(¶m->ctx->lock);
|
||||
env_rmutex_unlock(¶m->ctx->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1196,12 +1196,12 @@ static void _ocf_mngt_init_handle_error(ocf_ctx_t ctx,
|
||||
if (params->flags.metadata_inited)
|
||||
ocf_metadata_deinit(cache);
|
||||
|
||||
env_mutex_lock(&ctx->lock);
|
||||
env_rmutex_lock(&ctx->lock);
|
||||
|
||||
list_del(&cache->list);
|
||||
env_vfree(cache);
|
||||
|
||||
env_mutex_unlock(&ctx->lock);
|
||||
env_rmutex_unlock(&ctx->lock);
|
||||
}
|
||||
|
||||
static void _ocf_mngt_attach_handle_error(
|
||||
@@ -2028,12 +2028,12 @@ 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)
|
||||
{
|
||||
env_mutex_lock(&ctx->lock);
|
||||
env_rmutex_lock(&ctx->lock);
|
||||
/* Mark device uninitialized */
|
||||
ocf_refcnt_freeze(&cache->refcnt.cache);
|
||||
/* Remove cache from the list */
|
||||
list_del(&cache->list);
|
||||
env_mutex_unlock(&ctx->lock);
|
||||
env_rmutex_unlock(&ctx->lock);
|
||||
}
|
||||
|
||||
static void ocf_mngt_cache_stop_finish(ocf_pipeline_t pipeline,
|
||||
|
@@ -156,7 +156,7 @@ int ocf_mngt_cache_get_by_id(ocf_ctx_t ocf_ctx, ocf_cache_id_t id, ocf_cache_t *
|
||||
}
|
||||
|
||||
/* Lock caches list */
|
||||
env_mutex_lock(&ocf_ctx->lock);
|
||||
env_rmutex_lock(&ocf_ctx->lock);
|
||||
|
||||
list_for_each_entry(iter, &ocf_ctx->caches, list) {
|
||||
if (iter->cache_id == id) {
|
||||
@@ -173,7 +173,7 @@ int ocf_mngt_cache_get_by_id(ocf_ctx_t ocf_ctx, ocf_cache_id_t id, ocf_cache_t *
|
||||
}
|
||||
}
|
||||
|
||||
env_mutex_unlock(&ocf_ctx->lock);
|
||||
env_rmutex_unlock(&ocf_ctx->lock);
|
||||
|
||||
if (!instance)
|
||||
error = -OCF_ERR_CACHE_NOT_EXIST;
|
||||
@@ -363,7 +363,7 @@ static int _ocf_mngt_cache_get_list_cpy(ocf_ctx_t ocf_ctx, ocf_cache_t **list,
|
||||
*list = NULL;
|
||||
*size = 0;
|
||||
|
||||
env_mutex_lock(&ocf_ctx->lock);
|
||||
env_rmutex_lock(&ocf_ctx->lock);
|
||||
|
||||
list_for_each_entry(iter, &ocf_ctx->caches, list) {
|
||||
count++;
|
||||
@@ -392,7 +392,7 @@ static int _ocf_mngt_cache_get_list_cpy(ocf_ctx_t ocf_ctx, ocf_cache_t **list,
|
||||
}
|
||||
|
||||
END:
|
||||
env_mutex_unlock(&ocf_ctx->lock);
|
||||
env_rmutex_unlock(&ocf_ctx->lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -19,9 +19,9 @@ int ocf_mngt_core_pool_get_count(ocf_ctx_t ctx)
|
||||
{
|
||||
int count;
|
||||
OCF_CHECK_NULL(ctx);
|
||||
env_mutex_lock(&ctx->lock);
|
||||
env_rmutex_lock(&ctx->lock);
|
||||
count = ctx->core_pool.core_pool_count;
|
||||
env_mutex_unlock(&ctx->lock);
|
||||
env_rmutex_unlock(&ctx->lock);
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ int ocf_mngt_core_pool_add(ocf_ctx_t ctx, ocf_uuid_t uuid, uint8_t type)
|
||||
return result;
|
||||
}
|
||||
|
||||
env_mutex_lock(&ctx->lock);
|
||||
env_rmutex_lock(&ctx->lock);
|
||||
list_add(&volume->core_pool_item, &ctx->core_pool.core_pool_head);
|
||||
ctx->core_pool.core_pool_count++;
|
||||
env_mutex_unlock(&ctx->lock);
|
||||
env_rmutex_unlock(&ctx->lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -59,14 +59,14 @@ int ocf_mngt_core_pool_visit(ocf_ctx_t ctx,
|
||||
OCF_CHECK_NULL(ctx);
|
||||
OCF_CHECK_NULL(visitor);
|
||||
|
||||
env_mutex_lock(&ctx->lock);
|
||||
env_rmutex_lock(&ctx->lock);
|
||||
list_for_each_entry(svolume, &ctx->core_pool.core_pool_head,
|
||||
core_pool_item) {
|
||||
result = visitor(&svolume->uuid, visitor_ctx);
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
env_mutex_unlock(&ctx->lock);
|
||||
env_rmutex_unlock(&ctx->lock);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -94,10 +94,10 @@ void ocf_mngt_core_pool_remove(ocf_ctx_t ctx, ocf_volume_t volume)
|
||||
{
|
||||
OCF_CHECK_NULL(ctx);
|
||||
OCF_CHECK_NULL(volume);
|
||||
env_mutex_lock(&ctx->lock);
|
||||
env_rmutex_lock(&ctx->lock);
|
||||
ctx->core_pool.core_pool_count--;
|
||||
list_del(&volume->core_pool_item);
|
||||
env_mutex_unlock(&ctx->lock);
|
||||
env_rmutex_unlock(&ctx->lock);
|
||||
ocf_volume_destroy(volume);
|
||||
}
|
||||
|
||||
|
@@ -17,13 +17,13 @@ uint32_t ocf_mngt_cache_get_count(ocf_ctx_t ctx)
|
||||
|
||||
OCF_CHECK_NULL(ctx);
|
||||
|
||||
env_mutex_lock(&ctx->lock);
|
||||
env_rmutex_lock(&ctx->lock);
|
||||
|
||||
/* currently, there are no macros in list.h to get list size.*/
|
||||
list_for_each_entry(cache, &ctx->caches, list)
|
||||
count++;
|
||||
|
||||
env_mutex_unlock(&ctx->lock);
|
||||
env_rmutex_unlock(&ctx->lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
Reference in New Issue
Block a user