Use cleaning ops wrapper functions
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
00aa56dd28
commit
26194fc536
@ -13,7 +13,7 @@
|
||||
#include "../mngt/ocf_mngt_common.h"
|
||||
#include "../metadata/metadata.h"
|
||||
#include "../ocf_queue_priv.h"
|
||||
#include "cleaning_ops.c"
|
||||
#include "cleaning_ops.h"
|
||||
|
||||
int ocf_start_cleaner(ocf_cache_t cache)
|
||||
{
|
||||
@ -82,7 +82,6 @@ static void ocf_cleaner_run_complete(ocf_cleaner_t cleaner, uint32_t interval)
|
||||
void ocf_cleaner_run(ocf_cleaner_t cleaner, ocf_queue_t queue)
|
||||
{
|
||||
ocf_cache_t cache;
|
||||
ocf_cleaning_t clean_type;
|
||||
|
||||
OCF_CHECK_NULL(cleaner);
|
||||
OCF_CHECK_NULL(queue);
|
||||
@ -110,13 +109,8 @@ void ocf_cleaner_run(ocf_cleaner_t cleaner, ocf_queue_t queue)
|
||||
return;
|
||||
}
|
||||
|
||||
clean_type = cache->conf_meta->cleaning_policy_type;
|
||||
|
||||
ENV_BUG_ON(clean_type >= ocf_cleaning_max);
|
||||
|
||||
ocf_queue_get(queue);
|
||||
cleaner->io_queue = queue;
|
||||
|
||||
cleaning_policy_ops[clean_type].perform_cleaning(cache,
|
||||
ocf_cleaner_run_complete);
|
||||
ocf_cleaning_perform_cleaning(cache, ocf_cleaner_run_complete);
|
||||
}
|
||||
|
@ -38,27 +38,6 @@ struct cleaning_policy_meta {
|
||||
} meta;
|
||||
};
|
||||
|
||||
struct cleaning_policy_ops {
|
||||
void (*setup)(ocf_cache_t cache);
|
||||
int (*initialize)(ocf_cache_t cache, int init_metadata);
|
||||
void (*deinitialize)(ocf_cache_t cache);
|
||||
int (*add_core)(ocf_cache_t cache, ocf_core_id_t core_id);
|
||||
void (*remove_core)(ocf_cache_t cache, ocf_core_id_t core_id);
|
||||
void (*init_cache_block)(ocf_cache_t cache, uint32_t cache_line);
|
||||
void (*purge_cache_block)(ocf_cache_t cache, uint32_t cache_line);
|
||||
int (*purge_range)(ocf_cache_t cache, int core_id,
|
||||
uint64_t start_byte, uint64_t end_byte);
|
||||
void (*set_hot_cache_line)(ocf_cache_t cache, uint32_t cache_line);
|
||||
int (*set_cleaning_param)(ocf_cache_t cache, uint32_t param_id,
|
||||
uint32_t param_value);
|
||||
int (*get_cleaning_param)(ocf_cache_t cache, uint32_t param_id,
|
||||
uint32_t *param_value);
|
||||
void (*perform_cleaning)(ocf_cache_t cache, ocf_cleaner_end_t cmpl);
|
||||
const char *name;
|
||||
};
|
||||
|
||||
extern struct cleaning_policy_ops cleaning_policy_ops[ocf_cleaning_max];
|
||||
|
||||
struct ocf_cleaner {
|
||||
void *cleaning_policy_context;
|
||||
ocf_queue_t io_queue;
|
||||
|
@ -300,7 +300,6 @@ void ocf_map_cache_line(struct ocf_request *req,
|
||||
{
|
||||
ocf_cache_t cache = req->cache;
|
||||
ocf_core_id_t core_id = ocf_core_get_id(req->core);
|
||||
ocf_cleaning_t clean_policy_type;
|
||||
unsigned int hash_index = req->map[idx].hash;
|
||||
uint64_t core_line = req->core_line_first + idx;
|
||||
|
||||
@ -311,13 +310,8 @@ void ocf_map_cache_line(struct ocf_request *req,
|
||||
ocf_metadata_end_collision_shared_access(cache, cache_line);
|
||||
|
||||
/* Update dirty cache-block list */
|
||||
clean_policy_type = cache->conf_meta->cleaning_policy_type;
|
||||
|
||||
ENV_BUG_ON(clean_policy_type >= ocf_cleaning_max);
|
||||
|
||||
if (cleaning_policy_ops[clean_policy_type].init_cache_block != NULL)
|
||||
cleaning_policy_ops[clean_policy_type].
|
||||
init_cache_block(cache, cache_line);
|
||||
ocf_cleaning_init_cache_block(cache, cache_line);
|
||||
|
||||
req->map[idx].coll_idx = cache_line;
|
||||
}
|
||||
|
@ -1200,19 +1200,12 @@ static void _recovery_invalidate_clean_sec(struct ocf_cache *cache,
|
||||
static void _recovery_reset_cline_metadata(struct ocf_cache *cache,
|
||||
ocf_cache_line_t cline)
|
||||
{
|
||||
ocf_cleaning_t clean_policy_type;
|
||||
|
||||
ocf_metadata_set_core_info(cache, cline, OCF_CORE_MAX, ULLONG_MAX);
|
||||
|
||||
metadata_clear_valid(cache, cline);
|
||||
|
||||
clean_policy_type = cache->conf_meta->cleaning_policy_type;
|
||||
|
||||
ENV_BUG_ON(clean_policy_type >= ocf_cleaning_max);
|
||||
|
||||
if (cleaning_policy_ops[clean_policy_type].init_cache_block != NULL)
|
||||
cleaning_policy_ops[clean_policy_type].
|
||||
init_cache_block(cache, cline);
|
||||
ocf_cleaning_init_cache_block(cache, cline);
|
||||
}
|
||||
|
||||
static void _recovery_rebuild_metadata(ocf_pipeline_t pipeline,
|
||||
|
@ -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,17 +915,15 @@ 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 (ocf_cleaning_initialize(cache, type, 1)) {
|
||||
/*
|
||||
* If initialization of new cleaning policy failed,
|
||||
* we set cleaning policy to nop.
|
||||
@ -933,15 +931,14 @@ int ocf_mngt_cache_cleaning_set_policy(ocf_cache_t cache, ocf_cleaning_t type)
|
||||
type = ocf_cleaning_nop;
|
||||
ret = -OCF_ERR_INVAL;
|
||||
}
|
||||
}
|
||||
|
||||
cache->conf_meta->cleaning_policy_type = 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);
|
||||
}
|
||||
|
@ -6,19 +6,6 @@
|
||||
#include "utils_cache_line.h"
|
||||
#include "../promotion/promotion.h"
|
||||
|
||||
void ocf_cleaning_set_hot_cache_line(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line)
|
||||
{
|
||||
ocf_cleaning_t cleaning_type = cache->conf_meta->cleaning_policy_type;
|
||||
|
||||
ENV_BUG_ON(cleaning_type >= ocf_cleaning_max);
|
||||
|
||||
if (cleaning_policy_ops[cleaning_type].set_hot_cache_line) {
|
||||
cleaning_policy_ops[cleaning_type].
|
||||
set_hot_cache_line(cache, line);
|
||||
}
|
||||
}
|
||||
|
||||
static void __set_cache_line_invalid(struct ocf_cache *cache, uint8_t start_bit,
|
||||
uint8_t end_bit, ocf_cache_line_t line,
|
||||
ocf_core_id_t core_id, ocf_part_id_t part_id)
|
||||
@ -178,6 +165,5 @@ void set_cache_line_dirty(struct ocf_cache *cache, uint8_t start_bit,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ocf_cleaning_set_hot_cache_line(cache, line);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "../engine/cache_engine.h"
|
||||
#include "../ocf_request.h"
|
||||
#include "../ocf_def_priv.h"
|
||||
#include "../cleaning/cleaning_ops.c"
|
||||
#include "../cleaning/cleaning_ops.h"
|
||||
|
||||
/**
|
||||
* @file utils_cache_line.h
|
||||
@ -69,9 +69,6 @@ static inline uint64_t ocf_lines_2_bytes(struct ocf_cache *cache,
|
||||
return lines * ocf_line_size(cache);
|
||||
}
|
||||
|
||||
void ocf_cleaning_set_hot_cache_line(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line);
|
||||
|
||||
/**
|
||||
* @brief Set cache line invalid
|
||||
*
|
||||
@ -162,13 +159,8 @@ void set_cache_line_dirty(struct ocf_cache *cache, uint8_t start_bit,
|
||||
static inline void ocf_purge_cleaning_policy(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line)
|
||||
{
|
||||
ocf_cleaning_t clean_type = cache->conf_meta->cleaning_policy_type;
|
||||
|
||||
ENV_BUG_ON(clean_type >= ocf_cleaning_max);
|
||||
|
||||
/* Remove from cleaning policy */
|
||||
if (cleaning_policy_ops[clean_type].purge_cache_block != NULL)
|
||||
cleaning_policy_ops[clean_type].purge_cache_block(cache, line);
|
||||
ocf_cleaning_purge_cache_block(cache, line);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,9 +99,6 @@ void ocf_user_part_move(struct ocf_request *req)
|
||||
ocf_cache_line_t line;
|
||||
ocf_part_id_t id_old, id_new;
|
||||
uint32_t i;
|
||||
ocf_cleaning_t type = cache->conf_meta->cleaning_policy_type;
|
||||
|
||||
ENV_BUG_ON(type >= ocf_cleaning_max);
|
||||
|
||||
entry = &req->map[0];
|
||||
for (i = 0; i < req->core_line_count; i++, entry++) {
|
||||
@ -141,9 +138,7 @@ void ocf_user_part_move(struct ocf_request *req)
|
||||
* TODO: Consider adding update_cache_line() ops
|
||||
* to cleaning policy to let policies handle this.
|
||||
*/
|
||||
if (cleaning_policy_ops[type].purge_cache_block)
|
||||
cleaning_policy_ops[type].
|
||||
purge_cache_block(cache, line);
|
||||
ocf_cleaning_purge_cache_block(cache, line);
|
||||
}
|
||||
|
||||
ocf_lru_repart(cache, line, &cache->user_parts[id_old].part,
|
||||
@ -155,9 +150,7 @@ void ocf_user_part_move(struct ocf_request *req)
|
||||
*/
|
||||
if (metadata_test_dirty(cache, line)) {
|
||||
/* Add cline back to cleaning policy */
|
||||
if (cleaning_policy_ops[type].set_hot_cache_line)
|
||||
cleaning_policy_ops[type].
|
||||
set_hot_cache_line(cache, line);
|
||||
ocf_cleaning_set_hot_cache_line(cache, line);
|
||||
|
||||
env_atomic_inc(&req->core->runtime_meta->
|
||||
part_counters[id_new].dirty_clines);
|
||||
|
Loading…
Reference in New Issue
Block a user