Introduce "remove inactive core" to cas_cache module
Create module-side handling of inactive core removal. Extract core functionality of core removal that applies to inactive core and copy it to `cache_mngt_remove_inactive_core` function. Return proper error if core is active. Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
This commit is contained in:
parent
696a2e175c
commit
461a4f2d96
@ -1484,6 +1484,60 @@ put:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cache_mngt_remove_inactive_core(struct kcas_remove_inactive *cmd)
|
||||||
|
{
|
||||||
|
struct _cache_mngt_sync_context context;
|
||||||
|
int result = 0;
|
||||||
|
ocf_cache_t cache;
|
||||||
|
ocf_core_t core;
|
||||||
|
|
||||||
|
result = mngt_get_cache_by_id(cas_ctx, cmd->cache_id, &cache);
|
||||||
|
if (result)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
result = _cache_mngt_lock_sync(cache);
|
||||||
|
if (result)
|
||||||
|
goto put;
|
||||||
|
|
||||||
|
result = get_core_by_id(cache, cmd->core_id, &core);
|
||||||
|
if (result < 0) {
|
||||||
|
goto unlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = (ocf_core_get_state(core) == ocf_core_state_active);
|
||||||
|
if (result) {
|
||||||
|
result = -KCAS_ERR_CORE_IN_ACTIVE_STATE;
|
||||||
|
goto unlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destroy exported object - in case of error during destruction of
|
||||||
|
* exported object, instead of trying rolling this back we rather
|
||||||
|
* inform user about error.
|
||||||
|
*/
|
||||||
|
result = block_dev_destroy_exported_object(core);
|
||||||
|
if (result)
|
||||||
|
goto unlock;
|
||||||
|
|
||||||
|
init_completion(&context.cmpl);
|
||||||
|
context.result = &result;
|
||||||
|
|
||||||
|
ocf_mngt_cache_remove_core(core, _cache_mngt_remove_core_complete,
|
||||||
|
&context);
|
||||||
|
|
||||||
|
wait_for_completion(&context.cmpl);
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
mark_core_id_free(cache, cmd->core_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
unlock:
|
||||||
|
ocf_mngt_cache_unlock(cache);
|
||||||
|
put:
|
||||||
|
ocf_mngt_cache_put(cache);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int cache_mngt_reset_stats(const char *cache_name, size_t cache_name_len,
|
int cache_mngt_reset_stats(const char *cache_name, size_t cache_name_len,
|
||||||
const char *core_name, size_t core_name_len)
|
const char *core_name, size_t core_name_len)
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,8 @@ int cache_mngt_add_core_to_cache(const char *cache_name, size_t name_len,
|
|||||||
|
|
||||||
int cache_mngt_remove_core_from_cache(struct kcas_remove_core *cmd);
|
int cache_mngt_remove_core_from_cache(struct kcas_remove_core *cmd);
|
||||||
|
|
||||||
|
int cache_mngt_remove_inactive_core(struct kcas_remove_inactive *cmd);
|
||||||
|
|
||||||
int cache_mngt_reset_stats(const char *cache_name, size_t cache_name_len,
|
int cache_mngt_reset_stats(const char *cache_name, size_t cache_name_len,
|
||||||
const char *core_name, size_t core_name_len);
|
const char *core_name, size_t core_name_len);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user