diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index c3ba7bb..408639b 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -826,37 +826,59 @@ static void _ocf_mngt_load_metadata(ocf_pipeline_t pipeline, * @brief allocate memory for new cache, add it to cache queue, set initial * values and running state */ -static int _ocf_mngt_init_new_cache(struct ocf_cache_mngt_init_params *params) +static int _ocf_mngt_init_new_cache(struct ocf_cache_mngt_init_params *params, + char *new_cache_name) { ocf_cache_t cache = env_vzalloc(sizeof(*cache)); int result; - if (!cache) + if (!cache) { + ocf_log(params->ctx, log_err, "Failed to allocate cache %s\n", + new_cache_name); return -OCF_ERR_NO_MEM; + } if (ocf_mngt_cache_lock_init(cache)) { + ocf_log(params->ctx, log_err, + "Failed to allocate cache %s lock\n", + new_cache_name); result = -OCF_ERR_NO_MEM; goto alloc_err; } /* Lock cache during setup - this trylock should always succeed */ result = ocf_mngt_cache_trylock(cache); - if (result) + if (result) { + ocf_log(params->ctx, log_crit, + "Failed to lock the newly created cache %s\n", + new_cache_name); goto lock_init_err; + } if (env_mutex_init(&cache->flush_mutex)) { + ocf_log(params->ctx, log_err, + "Failed to allocate cache %s flush lock\n", + new_cache_name); result = -OCF_ERR_NO_MEM; goto lock_err; } INIT_LIST_HEAD(&cache->io_queues); result = env_spinlock_init(&cache->io_queues_lock); - if (result) + if (result) { + ocf_log(params->ctx, log_err, + "Failed to allocate cache %s queue lock\n", + new_cache_name); goto mutex_err; + } result = !ocf_refcnt_inc(&cache->refcnt.cache); - if (result) + if (result) { + ocf_log(params->ctx, log_crit, + "Failed to increment %s refcnt\n", + new_cache_name); goto cache_refcnt_inc_err; + } /* start with freezed metadata ref counter to indicate detached device*/ ocf_refcnt_freeze(&cache->refcnt.metadata); @@ -957,7 +979,7 @@ static int _ocf_mngt_init_prepare_cache(struct ocf_cache_mngt_init_params *param ocf_log(param->ctx, log_info, "Inserting cache %s\n", cfg->name); - ret = _ocf_mngt_init_new_cache(param); + ret = _ocf_mngt_init_new_cache(param, cfg->name); if (ret) goto out; @@ -1510,6 +1532,8 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, result = _ocf_mngt_init_prepare_cache(¶ms, cfg); if (result) { env_rmutex_unlock(&ctx->lock); + ocf_log(ctx, log_err, "Failed to prepare cache %s\n", + cfg->name); goto _cache_mngt_init_instance_ERROR; } @@ -1523,6 +1547,8 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, result = ocf_metadata_init(tmp_cache, params.metadata.line_size); if (result) { env_rmutex_unlock(&ctx->lock); + ocf_log(ctx, log_err, "Failed to initialize cache %s " + "metadata\n", cfg->name); result = -OCF_ERR_NO_MEM; goto _cache_mngt_init_instance_ERROR; } @@ -1530,6 +1556,8 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache, result = ocf_cache_set_name(tmp_cache, cfg->name, OCF_CACHE_NAME_SIZE); if (result) { + ocf_log(ctx, log_err, "Failed to set cache %s name\n", + cfg->name); env_rmutex_unlock(&ctx->lock); goto _cache_mngt_init_instance_ERROR; }