Add memory check before engaging promotion policy

Signed-off-by: Jan Musial <jan.musial@intel.com>
This commit is contained in:
Jan Musial
2020-03-12 07:12:18 +01:00
parent b08514c2db
commit d2fe82dc85
4 changed files with 59 additions and 3 deletions

View File

@@ -48,6 +48,13 @@ ocf_error_t ocf_promotion_init(ocf_cache_t cache, ocf_promotion_t type)
if (result) {
env_vfree(cache->promotion_policy);
cache->promotion_policy = NULL;
ocf_cache_log(cache, log_info,
"Policy '%s' failed to initialize\n",
ocf_promotion_policies[type].name);
} else {
ocf_cache_log(cache, log_info,
"Policy '%s' initialized successfully\n",
ocf_promotion_policies[type].name);
}
return result;
@@ -99,6 +106,10 @@ ocf_error_t ocf_promotion_set_policy(ocf_promotion_policy_t policy,
"Falling back to 'always' promotion policy\n");
cache->conf_meta->promotion_policy_type = ocf_promotion_always;
policy->type = ocf_promotion_always;
} else {
ocf_cache_log(cache, log_info,
"Switched to '%s' promotion policy\n",
ocf_promotion_policies[type].name);
}
return result;