Fix minor bugs in promotion policy

Signed-off-by: Jan Musial <jan.musial@intel.com>
This commit is contained in:
Jan Musial 2019-09-09 12:24:33 +02:00
parent 9c51ca4e97
commit 703a757db1
4 changed files with 10 additions and 6 deletions

View File

@ -73,7 +73,10 @@ struct ocf_cache_info {
/*!< Eviction policy selected */
ocf_cleaning_t cleaning_policy;
/*!< Cleaning policy selected (alru/nop) */
/*!< Cleaning policy selected */
ocf_promotion_t promotion_policy;
/*!< Promotion policy selected */
ocf_cache_line_size_t cache_line_size;
/*!< Cache line size in KiB */

View File

@ -156,6 +156,7 @@ int ocf_cache_get_info(ocf_cache_t cache, struct ocf_cache_info *info)
info->eviction_policy = cache->conf_meta->eviction_policy_type;
info->cleaning_policy = cache->conf_meta->cleaning_policy_type;
info->promotion_policy = cache->conf_meta->promotion_policy_type;
info->metadata_footprint = ocf_cache_is_device_attached(cache) ?
ocf_metadata_size_of(cache) : 0;
info->cache_line_size = ocf_line_size(cache);

View File

@ -183,7 +183,7 @@ bool nhit_req_should_promote(ocf_promotion_policy_t policy,
ocf_metadata_get_cachelines_count(policy->owner) -
ocf_freelist_num_free(policy->owner->freelist);
if (occupied_cachelines > env_atomic64_read(&ctx->trigger_threshold))
if (occupied_cachelines < env_atomic64_read(&ctx->trigger_threshold))
return true;
for (i = 0, core_line = req->core_line_first;
@ -196,9 +196,8 @@ bool nhit_req_should_promote(ocf_promotion_policy_t policy,
}
}
/* We don't want to reject even partially
* hit requests - this way we could trigger passthrough and invalidation.
* Let's let it in! */
return result || req->info.hit_no;
/* We don't want to reject even partially hit requests - this way we
* could trigger passthrough and invalidation. Let's let it in! */
return result || ocf_engine_mapped_count(req);
}

View File

@ -68,6 +68,7 @@ ocf_error_t ocf_promotion_set_policy(ocf_promotion_policy_t policy,
ocf_promotion_policies[prev_policy].deinit(policy);
cache->conf_meta->promotion_policy_type = type;
policy->type = type;
if (ocf_promotion_policies[type].init)
result = ocf_promotion_policies[type].init(cache, policy);