diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index de4afdc..4fd6e22 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -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, diff --git a/src/mngt/ocf_mngt_common.c b/src/mngt/ocf_mngt_common.c index 68d0070..158a07d 100644 --- a/src/mngt/ocf_mngt_common.c +++ b/src/mngt/ocf_mngt_common.c @@ -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; } diff --git a/src/mngt/ocf_mngt_core_pool.c b/src/mngt/ocf_mngt_core_pool.c index a80bb57..8e28463 100644 --- a/src/mngt/ocf_mngt_core_pool.c +++ b/src/mngt/ocf_mngt_core_pool.c @@ -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); } diff --git a/src/mngt/ocf_mngt_misc.c b/src/mngt/ocf_mngt_misc.c index 002b23c..d7a8623 100644 --- a/src/mngt/ocf_mngt_misc.c +++ b/src/mngt/ocf_mngt_misc.c @@ -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; } diff --git a/src/ocf_ctx.c b/src/ocf_ctx.c index 113d631..08914e7 100644 --- a/src/ocf_ctx.c +++ b/src/ocf_ctx.c @@ -24,10 +24,10 @@ int ocf_ctx_register_volume_type_extended(ocf_ctx_t ctx, uint8_t type_id, if (!ctx || !properties) return -EINVAL; - env_mutex_lock(&ctx->lock); + env_rmutex_lock(&ctx->lock); if (type_id >= OCF_VOLUME_TYPE_MAX || ctx->volume_type[type_id]) { - env_mutex_unlock(&ctx->lock); + env_rmutex_unlock(&ctx->lock); result = -EINVAL; goto err; } @@ -36,7 +36,7 @@ int ocf_ctx_register_volume_type_extended(ocf_ctx_t ctx, uint8_t type_id, if (!ctx->volume_type[type_id]) result = -EINVAL; - env_mutex_unlock(&ctx->lock); + env_rmutex_unlock(&ctx->lock); if (result) goto err; @@ -65,14 +65,14 @@ void ocf_ctx_unregister_volume_type(ocf_ctx_t ctx, uint8_t type_id) { OCF_CHECK_NULL(ctx); - env_mutex_lock(&ctx->lock); + env_rmutex_lock(&ctx->lock); if (type_id < OCF_VOLUME_TYPE_MAX && ctx->volume_type[type_id]) { ocf_volume_type_deinit(ctx->volume_type[type_id]); ctx->volume_type[type_id] = NULL; } - env_mutex_unlock(&ctx->lock); + env_rmutex_unlock(&ctx->lock); } /* @@ -160,7 +160,7 @@ int ocf_ctx_create(ocf_ctx_t *ctx, const struct ocf_ctx_config *cfg) INIT_LIST_HEAD(&ocf_ctx->caches); env_atomic_set(&ocf_ctx->ref_count, 1); - ret = env_mutex_init(&ocf_ctx->lock); + ret = env_rmutex_init(&ocf_ctx->lock); if (ret) goto err_ctx; @@ -216,9 +216,9 @@ void ocf_ctx_put(ocf_ctx_t ctx) if (env_atomic_dec_return(&ctx->ref_count)) return; - env_mutex_lock(&ctx->lock); + env_rmutex_lock(&ctx->lock); ENV_BUG_ON(!list_empty(&ctx->caches)); - env_mutex_unlock(&ctx->lock); + env_rmutex_unlock(&ctx->lock); ocf_mngt_core_pool_deinit(ctx); ocf_core_volume_type_deinit(ctx); diff --git a/src/ocf_ctx_priv.h b/src/ocf_ctx_priv.h index e3a2153..f7a41d2 100644 --- a/src/ocf_ctx_priv.h +++ b/src/ocf_ctx_priv.h @@ -22,7 +22,7 @@ struct ocf_ctx { struct ocf_logger logger; struct ocf_volume_type *volume_type[OCF_VOLUME_TYPE_MAX]; env_atomic ref_count; - env_mutex lock; + env_rmutex lock; struct list_head caches; struct { struct list_head core_pool_head;