Add promote-on-threshold sequential cutoff switch

Decide whether to promote sequential cutoff stream
to global structures when threshold is reached

Signed-off-by: Rafal Stefanowski <rafal.stefanowski@intel.com>
This commit is contained in:
Rafal Stefanowski
2021-10-29 13:23:06 +02:00
parent 55eda53cde
commit 0b39711b8b
6 changed files with 128 additions and 2 deletions

View File

@@ -472,6 +472,8 @@ static void ocf_mngt_cache_add_core_insert(ocf_pipeline_t pipeline,
cfg->seq_cutoff_threshold);
env_atomic_set(&core->conf_meta->seq_cutoff_promo_count,
cfg->seq_cutoff_promotion_count);
env_atomic_set(&core->conf_meta->seq_cutoff_promote_on_threshold,
cfg->seq_cutoff_promote_on_threshold);
/* Add core sequence number for atomic metadata matching */
core_sequence_no = _ocf_mngt_get_core_seq_no(cache);
@@ -1103,3 +1105,58 @@ int ocf_mngt_core_get_seq_cutoff_promotion_count(ocf_core_t core,
return 0;
}
static int _cache_mngt_set_core_seq_cutoff_promote_on_threshold(
ocf_core_t core, void *cntx)
{
bool promote = *(bool*) cntx;
bool promote_old = ocf_core_get_seq_cutoff_promote_on_threshold(core);
if (promote_old == promote) {
ocf_core_log(core, log_info,
"Sequential cutoff promote on threshold "
"is already set to %s\n", promote ? "true" : "false");
return 0;
}
env_atomic_set(&core->conf_meta->seq_cutoff_promote_on_threshold,
promote);
ocf_core_log(core, log_info, "Changing sequential cutoff promote "
"on threshold from %s to %s successful\n",
promote_old ? "true" : "false", promote ? "true" : "false");
return 0;
}
int ocf_mngt_core_set_seq_cutoff_promote_on_threshold(ocf_core_t core,
bool promote)
{
OCF_CHECK_NULL(core);
return _cache_mngt_set_core_seq_cutoff_promote_on_threshold(core, &promote);
}
int ocf_mngt_core_set_seq_cutoff_promote_on_threshold_all(ocf_cache_t cache,
bool promote)
{
OCF_CHECK_NULL(cache);
if (ocf_cache_is_standby(cache))
return -OCF_ERR_CACHE_STANDBY;
return ocf_core_visit(cache,
_cache_mngt_set_core_seq_cutoff_promote_on_threshold,
&promote, true);
}
int ocf_mngt_core_get_seq_cutoff_promote_on_threshold(ocf_core_t core,
bool *promote)
{
OCF_CHECK_NULL(core);
OCF_CHECK_NULL(promote);
*promote = ocf_core_get_seq_cutoff_promote_on_threshold(core);
return 0;
}

View File

@@ -121,6 +121,11 @@ uint32_t ocf_core_get_seq_cutoff_promotion_count(ocf_core_t core)
return env_atomic_read(&core->conf_meta->seq_cutoff_promo_count);
}
bool ocf_core_get_seq_cutoff_promote_on_threshold(ocf_core_t core)
{
return env_atomic_read(&core->conf_meta->seq_cutoff_promote_on_threshold);
}
int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx,
bool only_opened)
{

View File

@@ -47,6 +47,9 @@ struct ocf_core_meta_config {
/* Sequential cutoff stream promotion request count */
env_atomic seq_cutoff_promo_count;
/* Sequential cutoff stream promote on threshold */
env_atomic seq_cutoff_promote_on_threshold;
/* core object size in bytes */
uint64_t length;

View File

@@ -300,13 +300,15 @@ void ocf_core_seq_cutoff_update(ocf_core_t core, struct ocf_request *req)
uint32_t threshold = ocf_core_get_seq_cutoff_threshold(core);
uint32_t promotion_count =
ocf_core_get_seq_cutoff_promotion_count(core);
bool promote_on_threshold =
ocf_core_get_seq_cutoff_promote_on_threshold(core);
struct ocf_seq_cutoff_stream *stream;
bool promote = false;
if (policy == ocf_seq_cutoff_policy_never)
return;
if (req->byte_length >= threshold)
if (req->byte_length >= threshold && promote_on_threshold)
promote = true;
if (promotion_count == 1)
@@ -328,7 +330,7 @@ void ocf_core_seq_cutoff_update(ocf_core_t core, struct ocf_request *req)
req->byte_position, req->byte_length, req->rw, true);
env_rwlock_write_unlock(&req->io_queue->seq_cutoff->lock);
if (stream->bytes >= threshold)
if (stream->bytes >= threshold && promote_on_threshold)
promote = true;
if (stream->req_count >= promotion_count)