Merge pull request #257 from imjfckm/nhit-api-names

Make NHIT API naming convention similar to cleaning
This commit is contained in:
Robert Bałdyga 2019-09-11 10:37:15 +02:00 committed by GitHub
commit 11d0108639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 19 deletions

View File

@ -6,18 +6,18 @@
#ifndef __OCF_PROMOTION_NHIT_H__ #ifndef __OCF_PROMOTION_NHIT_H__
#define __OCF_PROMOTION_NHIT_H__ #define __OCF_PROMOTION_NHIT_H__
enum nhit_param { enum ocf_nhit_param {
nhit_insertion_threshold, ocf_nhit_insertion_threshold,
nhit_trigger_threshold, ocf_nhit_trigger_threshold,
nhit_param_max ocf_nhit_param_max
}; };
#define NHIT_MIN_THRESHOLD 2 #define OCF_NHIT_MIN_THRESHOLD 2
#define NHIT_MAX_THRESHOLD 1000 #define OCF_NHIT_MAX_THRESHOLD 1000
#define NHIT_THRESHOLD_DEFAULT 3 #define OCF_NHIT_THRESHOLD_DEFAULT 3
#define NHIT_MIN_TRIGGER 0 #define OCF_NHIT_MIN_TRIGGER 0
#define NHIT_MAX_TRIGGER 100 #define OCF_NHIT_MAX_TRIGGER 100
#define NHIT_TRIGGER_DEFAULT 80 #define OCF_NHIT_TRIGGER_DEFAULT 80
#endif /* __OCF_PROMOTION_NHIT_H__ */ #endif /* __OCF_PROMOTION_NHIT_H__ */

View File

@ -37,9 +37,9 @@ ocf_error_t nhit_init(ocf_cache_t cache, ocf_promotion_policy_t policy)
if (result) if (result)
goto dealloc_ctx; goto dealloc_ctx;
env_atomic_set(&ctx->insertion_threshold, NHIT_THRESHOLD_DEFAULT); env_atomic_set(&ctx->insertion_threshold, OCF_NHIT_THRESHOLD_DEFAULT);
env_atomic64_set(&ctx->trigger_threshold, env_atomic64_set(&ctx->trigger_threshold,
OCF_DIV_ROUND_UP((NHIT_TRIGGER_DEFAULT * OCF_DIV_ROUND_UP((OCF_NHIT_TRIGGER_DEFAULT *
ocf_metadata_get_cachelines_count(cache)), 100)); ocf_metadata_get_cachelines_count(cache)), 100));
policy->ctx = ctx; policy->ctx = ctx;
@ -70,9 +70,9 @@ ocf_error_t nhit_set_param(ocf_promotion_policy_t policy, uint8_t param_id,
ocf_error_t result = 0; ocf_error_t result = 0;
switch (param_id) { switch (param_id) {
case nhit_insertion_threshold: case ocf_nhit_insertion_threshold:
if (param_value >= NHIT_MIN_THRESHOLD && if (param_value >= OCF_NHIT_MIN_THRESHOLD &&
param_value < NHIT_MAX_THRESHOLD) { param_value < OCF_NHIT_MAX_THRESHOLD) {
env_atomic_set(&ctx->insertion_threshold, param_value); env_atomic_set(&ctx->insertion_threshold, param_value);
} else { } else {
ocf_cache_log(policy->owner, log_err, "Invalid nhit " ocf_cache_log(policy->owner, log_err, "Invalid nhit "
@ -81,9 +81,9 @@ ocf_error_t nhit_set_param(ocf_promotion_policy_t policy, uint8_t param_id,
} }
break; break;
case nhit_trigger_threshold: case ocf_nhit_trigger_threshold:
if (param_value >= NHIT_MIN_TRIGGER && if (param_value >= OCF_NHIT_MIN_TRIGGER &&
param_value < NHIT_MAX_TRIGGER) { param_value < OCF_NHIT_MAX_TRIGGER) {
env_atomic64_set(&ctx->trigger_threshold, env_atomic64_set(&ctx->trigger_threshold,
OCF_DIV_ROUND_UP((param_value * OCF_DIV_ROUND_UP((param_value *
ocf_metadata_get_cachelines_count(policy->owner)), ocf_metadata_get_cachelines_count(policy->owner)),
@ -118,7 +118,7 @@ ocf_error_t nhit_get_param(ocf_promotion_policy_t policy, uint8_t param_id,
OCF_CHECK_NULL(param_value); OCF_CHECK_NULL(param_value);
switch (param_id) { switch (param_id) {
case nhit_insertion_threshold: case ocf_nhit_insertion_threshold:
*param_value = env_atomic_read(&ctx->insertion_threshold); *param_value = env_atomic_read(&ctx->insertion_threshold);
break; break;