Make seq cutoff policy and threshold atomic variables

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2020-02-28 09:20:10 +01:00
parent 935df23c74
commit 332ad1dfbc
3 changed files with 13 additions and 10 deletions

View File

@ -427,8 +427,10 @@ static void ocf_mngt_cache_add_core_insert(ocf_pipeline_t pipeline,
core->opened = true; core->opened = true;
/* Set default cache parameters for sequential */ /* Set default cache parameters for sequential */
core->conf_meta->seq_cutoff_policy = ocf_seq_cutoff_policy_default; env_atomic_set(&core->conf_meta->seq_cutoff_policy,
core->conf_meta->seq_cutoff_threshold = cfg->seq_cutoff_threshold; ocf_seq_cutoff_policy_default);
env_atomic_set(&core->conf_meta->seq_cutoff_threshold,
cfg->seq_cutoff_threshold);
/* Add core sequence number for atomic metadata matching */ /* Add core sequence number for atomic metadata matching */
core_sequence_no = _ocf_mngt_get_core_seq_no(cache); core_sequence_no = _ocf_mngt_get_core_seq_no(cache);
@ -855,7 +857,7 @@ int ocf_mngt_core_get_user_metadata(ocf_core_t core, void *data, size_t size)
static int _cache_mngt_set_core_seq_cutoff_threshold(ocf_core_t core, void *cntx) static int _cache_mngt_set_core_seq_cutoff_threshold(ocf_core_t core, void *cntx)
{ {
uint32_t threshold = *(uint32_t*) cntx; uint32_t threshold = *(uint32_t*) cntx;
uint32_t threshold_old = core->conf_meta->seq_cutoff_threshold; uint32_t threshold_old = ocf_core_get_seq_cutoff_threshold(core);
if (threshold_old == threshold) { if (threshold_old == threshold) {
ocf_core_log(core, log_info, ocf_core_log(core, log_info,
@ -863,7 +865,8 @@ static int _cache_mngt_set_core_seq_cutoff_threshold(ocf_core_t core, void *cntx
"already set\n", threshold); "already set\n", threshold);
return 0; return 0;
} }
core->conf_meta->seq_cutoff_threshold = threshold;
env_atomic_set(&core->conf_meta->seq_cutoff_threshold, threshold);
ocf_core_log(core, log_info, "Changing sequential cutoff " ocf_core_log(core, log_info, "Changing sequential cutoff "
"threshold from %u to %u bytes successful\n", "threshold from %u to %u bytes successful\n",
@ -916,7 +919,7 @@ static const char *_cache_mngt_seq_cutoff_policy_get_name(
static int _cache_mngt_set_core_seq_cutoff_policy(ocf_core_t core, void *cntx) static int _cache_mngt_set_core_seq_cutoff_policy(ocf_core_t core, void *cntx)
{ {
ocf_seq_cutoff_policy policy = *(ocf_seq_cutoff_policy*) cntx; ocf_seq_cutoff_policy policy = *(ocf_seq_cutoff_policy*) cntx;
uint32_t policy_old = core->conf_meta->seq_cutoff_policy; uint32_t policy_old = ocf_core_get_seq_cutoff_policy(core);
if (policy_old == policy) { if (policy_old == policy) {
ocf_core_log(core, log_info, ocf_core_log(core, log_info,
@ -931,7 +934,7 @@ static int _cache_mngt_set_core_seq_cutoff_policy(ocf_core_t core, void *cntx)
return -OCF_ERR_INVAL; return -OCF_ERR_INVAL;
} }
core->conf_meta->seq_cutoff_policy = policy; env_atomic_set(&core->conf_meta->seq_cutoff_policy, policy);
ocf_core_log(core, log_info, ocf_core_log(core, log_info,
"Changing sequential cutoff policy from %s to %s\n", "Changing sequential cutoff policy from %s to %s\n",

View File

@ -106,12 +106,12 @@ int ocf_core_get(ocf_cache_t cache, ocf_core_id_t id, ocf_core_t *core)
uint32_t ocf_core_get_seq_cutoff_threshold(ocf_core_t core) uint32_t ocf_core_get_seq_cutoff_threshold(ocf_core_t core)
{ {
return core->conf_meta->seq_cutoff_threshold; return env_atomic_read(&core->conf_meta->seq_cutoff_threshold);
} }
ocf_seq_cutoff_policy ocf_core_get_seq_cutoff_policy(ocf_core_t core) ocf_seq_cutoff_policy ocf_core_get_seq_cutoff_policy(ocf_core_t core)
{ {
return core->conf_meta->seq_cutoff_policy; return env_atomic_read(&core->conf_meta->seq_cutoff_policy);
} }
int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx, int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx,

View File

@ -38,10 +38,10 @@ struct ocf_core_meta_config {
ocf_seq_no_t seq_no; ocf_seq_no_t seq_no;
/* Sequential cutoff threshold (in bytes) */ /* Sequential cutoff threshold (in bytes) */
uint32_t seq_cutoff_threshold; env_atomic seq_cutoff_threshold;
/* Sequential cutoff policy */ /* Sequential cutoff policy */
ocf_seq_cutoff_policy seq_cutoff_policy; env_atomic seq_cutoff_policy;
/* core object size in bytes */ /* core object size in bytes */
uint64_t length; uint64_t length;