Don't bug on cache init

Even if locking the new cache should never fail it's not an unrecoverable
state.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
Michal Mielewczyk 2024-10-04 14:05:25 +02:00
parent 1d1561649c
commit f6bdd354d0

View File

@ -840,7 +840,9 @@ static int _ocf_mngt_init_new_cache(struct ocf_cache_mngt_init_params *params)
} }
/* Lock cache during setup - this trylock should always succeed */ /* Lock cache during setup - this trylock should always succeed */
ENV_BUG_ON(ocf_mngt_cache_trylock(cache)); result = ocf_mngt_cache_trylock(cache);
if (result)
goto lock_init_err;
if (env_mutex_init(&cache->flush_mutex)) { if (env_mutex_init(&cache->flush_mutex)) {
result = -OCF_ERR_NO_MEM; result = -OCF_ERR_NO_MEM;
@ -852,7 +854,9 @@ static int _ocf_mngt_init_new_cache(struct ocf_cache_mngt_init_params *params)
if (result) if (result)
goto mutex_err; goto mutex_err;
ENV_BUG_ON(!ocf_refcnt_inc(&cache->refcnt.cache)); result = !ocf_refcnt_inc(&cache->refcnt.cache);
if (result)
goto cache_refcnt_inc_err;
/* start with freezed metadata ref counter to indicate detached device*/ /* start with freezed metadata ref counter to indicate detached device*/
ocf_refcnt_freeze(&cache->refcnt.metadata); ocf_refcnt_freeze(&cache->refcnt.metadata);
@ -869,10 +873,13 @@ static int _ocf_mngt_init_new_cache(struct ocf_cache_mngt_init_params *params)
return 0; return 0;
cache_refcnt_inc_err:
env_spinlock_destroy(&cache->io_queues_lock);
mutex_err: mutex_err:
env_mutex_destroy(&cache->flush_mutex); env_mutex_destroy(&cache->flush_mutex);
lock_err: lock_err:
ocf_mngt_cache_unlock(cache); ocf_mngt_cache_unlock(cache);
lock_init_err:
ocf_mngt_cache_lock_deinit(cache); ocf_mngt_cache_lock_deinit(cache);
alloc_err: alloc_err:
env_vfree(cache); env_vfree(cache);