Merge pull request #1071 from pdebski21/1022

When core exported object name exists activation fails and cache is stopped
This commit is contained in:
Robert Baldyga 2022-03-07 10:56:57 +01:00 committed by GitHub
commit b533a40cff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2297,7 +2297,7 @@ int cache_mngt_activate(struct ocf_mngt_cache_standby_activate_config *cfg,
ocf_cache_t cache; ocf_cache_t cache;
struct cache_priv *cache_priv; struct cache_priv *cache_priv;
char cache_name[OCF_CACHE_NAME_SIZE]; char cache_name[OCF_CACHE_NAME_SIZE];
int result = 0; int result = 0, rollback_result = 0;
if (!try_module_get(THIS_MODULE)) if (!try_module_get(THIS_MODULE))
return -KCAS_ERR_SYSTEM; return -KCAS_ERR_SYSTEM;
@ -2352,13 +2352,14 @@ int cache_mngt_activate(struct ocf_mngt_cache_standby_activate_config *cfg,
result = _cache_mngt_async_caller_set_result(&context->async, result); result = _cache_mngt_async_caller_set_result(&context->async, result);
if (result == -KCAS_ERR_WAITING_INTERRUPTED) if (result == -KCAS_ERR_WAITING_INTERRUPTED)
goto out_cache_put; goto out_cache_put;
cas_lazy_thread_stop(context->rollback_thread);
if (result) if (result)
goto err_free_context; goto err;
result = _cache_start_finalize(cache, -1, true); result = _cache_start_finalize(cache, -1, true);
if (result)
goto err;
cas_lazy_thread_stop(context->rollback_thread);
err_free_context: err_free_context:
kfree(context); kfree(context);
@ -2371,6 +2372,21 @@ out_cache_put:
out_module_put: out_module_put:
module_put(THIS_MODULE); module_put(THIS_MODULE);
return result; return result;
err:
reinit_completion(&context->async.cmpl);
context->async.result = 0;
ocf_mngt_cache_stop(cache, _cache_mngt_cache_stop_rollback_complete,
context);
rollback_result = wait_for_completion_interruptible(&context->async.cmpl);
rollback_result = _cache_mngt_async_caller_set_result(&context->async,
rollback_result);
if (rollback_result != -KCAS_ERR_WAITING_INTERRUPTED)
kfree(context);
return result;
} }
int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg, int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,