Use cleaning ops wrapper functions
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
@@ -202,29 +202,20 @@ static ocf_error_t __init_cleaning_policy(ocf_cache_t cache)
|
||||
{
|
||||
ocf_cleaning_t cleaning_policy = ocf_cleaning_default;
|
||||
int i;
|
||||
ocf_error_t result = 0;
|
||||
|
||||
OCF_ASSERT_PLUGGED(cache);
|
||||
|
||||
for (i = 0; i < ocf_cleaning_max; i++) {
|
||||
if (cleaning_policy_ops[i].setup)
|
||||
cleaning_policy_ops[i].setup(cache);
|
||||
}
|
||||
for (i = 0; i < ocf_cleaning_max; i++)
|
||||
ocf_cleaning_setup(cache, i);
|
||||
|
||||
cache->conf_meta->cleaning_policy_type = ocf_cleaning_default;
|
||||
if (cleaning_policy_ops[cleaning_policy].initialize)
|
||||
result = cleaning_policy_ops[cleaning_policy].initialize(cache, 1);
|
||||
|
||||
return result;
|
||||
return ocf_cleaning_initialize(cache, cleaning_policy, 1);
|
||||
}
|
||||
|
||||
static void __deinit_cleaning_policy(ocf_cache_t cache)
|
||||
{
|
||||
ocf_cleaning_t cleaning_policy;
|
||||
|
||||
cleaning_policy = cache->conf_meta->cleaning_policy_type;
|
||||
if (cleaning_policy_ops[cleaning_policy].deinitialize)
|
||||
cleaning_policy_ops[cleaning_policy].deinitialize(cache);
|
||||
ocf_cleaning_deinitialize(cache);
|
||||
}
|
||||
|
||||
static void __setup_promotion_policy(ocf_cache_t cache)
|
||||
@@ -470,13 +461,11 @@ void _ocf_mngt_load_init_instance_complete(void *priv, int error)
|
||||
__populate_free(cache);
|
||||
|
||||
cleaning_policy = cache->conf_meta->cleaning_policy_type;
|
||||
if (!cleaning_policy_ops[cleaning_policy].initialize)
|
||||
goto out;
|
||||
|
||||
if (context->metadata.shutdown_status == ocf_metadata_clean_shutdown)
|
||||
result = cleaning_policy_ops[cleaning_policy].initialize(cache, 0);
|
||||
result = ocf_cleaning_initialize(cache, cleaning_policy, 0);
|
||||
else
|
||||
result = cleaning_policy_ops[cleaning_policy].initialize(cache, 1);
|
||||
result = ocf_cleaning_initialize(cache, cleaning_policy, 1);
|
||||
|
||||
if (result) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
@@ -484,7 +473,6 @@ void _ocf_mngt_load_init_instance_complete(void *priv, int error)
|
||||
OCF_PL_FINISH_RET(context->pipeline, result);
|
||||
}
|
||||
|
||||
out:
|
||||
ocf_pipeline_next(context->pipeline);
|
||||
}
|
||||
|
||||
@@ -2074,7 +2062,7 @@ static void _ocf_mngt_cache_load_log(ocf_cache_t cache)
|
||||
ocf_cache_log(cache, log_info, "Cache mode : %s\n",
|
||||
_ocf_cache_mode_get_name(cache_mode));
|
||||
ocf_cache_log(cache, log_info, "Cleaning policy : %s\n",
|
||||
cleaning_policy_ops[cleaning_type].name);
|
||||
ocf_cleaning_get_name(cleaning_type));
|
||||
ocf_cache_log(cache, log_info, "Promotion policy : %s\n",
|
||||
ocf_promotion_policies[promotion_type].name);
|
||||
ocf_core_visit(cache, _ocf_mngt_cache_load_core_log,
|
||||
|
@@ -36,15 +36,10 @@ void cache_mngt_core_remove_from_cleaning_pol(ocf_core_t core)
|
||||
{
|
||||
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||
ocf_core_id_t core_id = ocf_core_get_id(core);
|
||||
ocf_cleaning_t clean_pol_type;
|
||||
|
||||
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
|
||||
|
||||
clean_pol_type = cache->conf_meta->cleaning_policy_type;
|
||||
if (cleaning_policy_ops[clean_pol_type].remove_core) {
|
||||
cleaning_policy_ops[clean_pol_type].
|
||||
remove_core(cache, core_id);
|
||||
}
|
||||
ocf_cleaning_remove_core(cache, core_id);
|
||||
|
||||
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#include "../utils/utils_pipeline.h"
|
||||
#include "../ocf_stats_priv.h"
|
||||
#include "../ocf_def_priv.h"
|
||||
#include "../cleaning/cleaning_ops.c"
|
||||
#include "../cleaning/cleaning_ops.h"
|
||||
|
||||
static ocf_seq_no_t _ocf_mngt_get_core_seq_no(ocf_cache_t cache)
|
||||
{
|
||||
@@ -124,14 +124,12 @@ static void _ocf_mngt_cache_add_core_handle_error(
|
||||
ocf_core_t core = context->core;
|
||||
ocf_core_id_t core_id;
|
||||
ocf_volume_t volume;
|
||||
ocf_cleaning_t clean_type;
|
||||
|
||||
if (!core)
|
||||
return;
|
||||
|
||||
core_id = ocf_core_get_id(core);
|
||||
volume = &core->volume;
|
||||
clean_type = cache->conf_meta->cleaning_policy_type;
|
||||
|
||||
if (context->flags.counters_allocated) {
|
||||
env_bit_clear(core_id,
|
||||
@@ -144,11 +142,8 @@ static void _ocf_mngt_cache_add_core_handle_error(
|
||||
core->counters = NULL;
|
||||
}
|
||||
|
||||
if (context->flags.clean_pol_added) {
|
||||
if (cleaning_policy_ops[clean_type].remove_core)
|
||||
cleaning_policy_ops[clean_type].remove_core(cache,
|
||||
core_id);
|
||||
}
|
||||
if (context->flags.clean_pol_added)
|
||||
ocf_cleaning_remove_core(cache, core_id);
|
||||
|
||||
if (context->flags.cutoff_initialized)
|
||||
ocf_core_seq_cutoff_deinit(core);
|
||||
@@ -376,7 +371,6 @@ static void ocf_mngt_cache_add_core_insert(ocf_pipeline_t pipeline,
|
||||
ocf_volume_t volume;
|
||||
ocf_volume_type_t type;
|
||||
ocf_seq_no_t core_sequence_no;
|
||||
ocf_cleaning_t clean_type;
|
||||
uint64_t length;
|
||||
int i, result = 0;
|
||||
|
||||
@@ -428,11 +422,8 @@ static void ocf_mngt_cache_add_core_insert(ocf_pipeline_t pipeline,
|
||||
|
||||
core->conf_meta->length = length;
|
||||
|
||||
clean_type = cache->conf_meta->cleaning_policy_type;
|
||||
if (ocf_cache_is_device_attached(cache) &&
|
||||
cleaning_policy_ops[clean_type].add_core) {
|
||||
result = cleaning_policy_ops[clean_type].add_core(cache,
|
||||
core_id);
|
||||
if (ocf_cache_is_device_attached(cache)) {
|
||||
result = ocf_cleaning_add_core(cache, core_id);
|
||||
if (result)
|
||||
OCF_PL_FINISH_RET(pipeline, result);
|
||||
|
||||
|
@@ -915,24 +915,21 @@ int ocf_mngt_cache_cleaning_set_policy(ocf_cache_t cache, ocf_cleaning_t type)
|
||||
|
||||
if (type == old_type) {
|
||||
ocf_cache_log(cache, log_info, "Cleaning policy %s is already "
|
||||
"set\n", cleaning_policy_ops[old_type].name);
|
||||
"set\n", ocf_cleaning_get_name(old_type));
|
||||
return 0;
|
||||
}
|
||||
|
||||
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
|
||||
|
||||
if (cleaning_policy_ops[old_type].deinitialize)
|
||||
cleaning_policy_ops[old_type].deinitialize(cache);
|
||||
ocf_cleaning_deinitialize(cache);
|
||||
|
||||
if (cleaning_policy_ops[type].initialize) {
|
||||
if (cleaning_policy_ops[type].initialize(cache, 1)) {
|
||||
/*
|
||||
* If initialization of new cleaning policy failed,
|
||||
* we set cleaning policy to nop.
|
||||
*/
|
||||
type = ocf_cleaning_nop;
|
||||
ret = -OCF_ERR_INVAL;
|
||||
}
|
||||
if (ocf_cleaning_initialize(cache, type, 1)) {
|
||||
/*
|
||||
* If initialization of new cleaning policy failed,
|
||||
* we set cleaning policy to nop.
|
||||
*/
|
||||
type = ocf_cleaning_nop;
|
||||
ret = -OCF_ERR_INVAL;
|
||||
}
|
||||
|
||||
cache->conf_meta->cleaning_policy_type = type;
|
||||
@@ -940,8 +937,8 @@ int ocf_mngt_cache_cleaning_set_policy(ocf_cache_t cache, ocf_cleaning_t type)
|
||||
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
|
||||
|
||||
ocf_cache_log(cache, log_info, "Changing cleaning policy from "
|
||||
"%s to %s\n", cleaning_policy_ops[old_type].name,
|
||||
cleaning_policy_ops[type].name);
|
||||
"%s to %s\n", ocf_cleaning_get_name(old_type),
|
||||
ocf_cleaning_get_name(type));
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -966,13 +963,9 @@ int ocf_mngt_cache_cleaning_set_param(ocf_cache_t cache, ocf_cleaning_t type,
|
||||
if (type < 0 || type >= ocf_cleaning_max)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (!cleaning_policy_ops[type].set_cleaning_param)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
ocf_metadata_start_exclusive_access(&cache->metadata.lock);
|
||||
|
||||
ret = cleaning_policy_ops[type].set_cleaning_param(cache,
|
||||
param_id, param_value);
|
||||
ret = ocf_cleaning_set_param(cache, type, param_id, param_value);
|
||||
|
||||
ocf_metadata_end_exclusive_access(&cache->metadata.lock);
|
||||
|
||||
@@ -982,19 +975,11 @@ int ocf_mngt_cache_cleaning_set_param(ocf_cache_t cache, ocf_cleaning_t type,
|
||||
int ocf_mngt_cache_cleaning_get_param(ocf_cache_t cache, ocf_cleaning_t type,
|
||||
uint32_t param_id, uint32_t *param_value)
|
||||
{
|
||||
int ret;
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
OCF_CHECK_NULL(param_value);
|
||||
|
||||
if (type < 0 || type >= ocf_cleaning_max)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
if (!cleaning_policy_ops[type].get_cleaning_param)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
ret = cleaning_policy_ops[type].get_cleaning_param(cache,
|
||||
param_id, param_value);
|
||||
|
||||
return ret;
|
||||
return ocf_cleaning_get_param(cache, type, param_id, param_value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user