Merge pull request #104 from imjfckm/pp-in-casadm

Promotion Policy in OCL
This commit is contained in:
Adam Rutkowski 2019-09-19 09:07:08 +02:00 committed by GitHub
commit ad98c52350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 456 additions and 9 deletions

View File

@ -265,6 +265,12 @@ static struct name_to_val_mapping cleaning_policy_names[] = {
{ NULL }
};
static struct name_to_val_mapping promotion_policy_names[] = {
{ .short_name = "always", .value = ocf_promotion_always },
{ .short_name = "nhit", .value = ocf_promotion_nhit },
{ NULL}
};
static struct name_to_val_mapping metadata_mode_names[] = {
{ .short_name = "normal", .value = CAS_METADATA_MODE_NORMAL },
{ .short_name = "atomic", .value = CAS_METADATA_MODE_ATOMIC },
@ -434,6 +440,16 @@ inline const char *cleaning_policy_to_name(uint8_t policy)
return val_to_short_name(policy, cleaning_policy_names, "Unknown");
}
inline int validate_str_promotion_policy(const char *s)
{
return validate_str_val_mapping(s, promotion_policy_names, -1);
}
inline const char *promotion_policy_to_name(uint8_t policy)
{
return val_to_short_name(policy, promotion_policy_names, "Unknown");
}
const char *metadata_mode_to_name(uint8_t metadata_mode)
{
return val_to_short_name(metadata_mode, metadata_mode_names, "Invalid");
@ -707,6 +723,7 @@ struct cache_device *get_cache_device(const struct kcas_cache_info *info)
cache->flushed = info->info.flushed;
cache->eviction_policy = info->info.eviction_policy;
cache->cleaning_policy = info->info.cleaning_policy;
cache->promotion_policy = info->info.promotion_policy;
cache->size = info->info.cache_line_size;
if ((info->info.state & (1 << ocf_cache_state_running)) == 0) {

View File

@ -44,6 +44,7 @@ struct cache_device {
int mode;
int eviction_policy;
int cleaning_policy;
int promotion_policy;
int dirty;
int flushed;
unsigned size;
@ -92,6 +93,7 @@ enum metadata_mode_t {
const char *eviction_policy_to_name(uint8_t policy);
const char *cleaning_policy_to_name(uint8_t policy);
const char *promotion_policy_to_name(uint8_t policy);
const char *cache_mode_to_name(uint8_t cache_mode);
const char *get_cache_state_name(int cache_state);
const char *get_core_state_name(int core_state);
@ -256,6 +258,7 @@ int validate_path(const char *path, int exist);
int validate_str_cache_mode(const char *s);
int validate_str_ev_policy(const char *s);
int validate_str_cln_policy(const char *s);
int validate_str_promotion_policy(const char *s);
int validate_str_meta_variant(const char *s);
int validate_str_stats_filters(const char* s);
int validate_str_output_format(const char* s);

View File

@ -50,6 +50,7 @@ struct command_args{
int cache_state_flush;
int flush_data;
int cleaning_policy_type;
int promotion_policy_type;
int script_subcmd;
int try_add;
int update_path;
@ -75,6 +76,7 @@ static struct command_args command_args_values = {
.cache_state_flush = UNDEFINED, /* three state logic: YES NO UNDEFINED */
.flush_data = 1,
.cleaning_policy_type = 0,
.promotion_policy_type = 0,
.script_subcmd = -1,
.try_add = false,
.update_path = false,
@ -560,6 +562,12 @@ static char *cleaning_policy_type_values[] = {
NULL,
};
static char *promotion_policy_type_values[] = {
[ocf_promotion_always] = "always",
[ocf_promotion_nhit] = "nhit",
NULL,
};
static struct cas_param cas_cache_params[] = {
/* Cleaning policy type */
[cache_param_cleaning_policy_type] = {
@ -588,6 +596,20 @@ static struct cas_param cas_cache_params[] = {
[cache_param_cleaning_acp_flush_max_buffers] = {
.name = "Flush max buffers" ,
},
/* Promotion policy type */
[cache_param_promotion_policy_type] = {
.name = "Promotion policy type",
.value_names = promotion_policy_type_values,
},
/*Promotion policy NHIT params */
[cache_param_promotion_nhit_insertion_threshold] = {
.name = "Insertion threshold",
},
[cache_param_promotion_nhit_trigger_threshold] = {
.name = "Policy trigger [%]",
},
{0},
};
@ -614,6 +636,15 @@ static struct cas_param cas_cache_params[] = {
#define CLEANING_ACP_MAX_BUFFERS_DESC "Number of cache lines flushed in single ACP cleaning thread iteration" \
" <%d-%d> (default: %d)"
#define PROMOTION_POLICY_TYPE_DESC "Promotion policy type. "\
"Available policy types: {always|nhit}"
#define PROMOTION_NHIT_TRIGGER_DESC "Cache occupancy value over which NHIT promotion is active " \
"<%d-%d>[%] (default: %d%)"
#define PROMOTION_NHIT_THRESHOLD_DESC "Number of requests for given core line " \
"after which NHIT policy allows insertion into cache <%d-%d> (default: %d)"
static cli_namespace set_param_namespace = {
.short_name = 'n',
.long_name = "name",
@ -627,6 +658,21 @@ static cli_namespace set_param_namespace = {
{'p', "policy", CLEANING_POLICY_TYPE_DESC, 1, "POLICY", 0},
CACHE_PARAMS_NS_END()
CACHE_PARAMS_NS_BEGIN("promotion", "Promotion policy parameters")
{'p', "policy", PROMOTION_POLICY_TYPE_DESC, 1, "POLICY", 0},
CACHE_PARAMS_NS_END()
CACHE_PARAMS_NS_BEGIN("promotion-nhit", "Promotion policy NHIT parameters")
{'t', "threshold", PROMOTION_NHIT_THRESHOLD_DESC, 1, "NUMBER",
CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT,
OCF_NHIT_MIN_THRESHOLD, OCF_NHIT_MAX_THRESHOLD,
OCF_NHIT_THRESHOLD_DEFAULT},
{'o', "trigger", PROMOTION_NHIT_TRIGGER_DESC, 1, "NUMBER",
CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT,
OCF_NHIT_MIN_TRIGGER, OCF_NHIT_MAX_TRIGGER,
OCF_NHIT_TRIGGER_DEFAULT},
CACHE_PARAMS_NS_END()
CACHE_PARAMS_NS_BEGIN("cleaning-alru", "Cleaning policy ALRU parameters")
{'w', "wake-up", CLEANING_ALRU_WAKE_UP_DESC, 1, "NUMBER",
CLI_OPTION_RANGE_INT | CLI_OPTION_DEFAULT_INT,
@ -772,6 +818,49 @@ int set_param_cleaning_acp_handle_option(char *opt, const char **arg)
SET_CACHE_PARAM(cache_param_cleaning_acp_flush_max_buffers,
strtoul(arg[0], NULL, 10));
}
return FAILURE;
}
int set_param_promotion_handle_option(char *opt, const char **arg)
{
if (!strcmp(opt, "policy")) {
if (!strcmp("always", arg[0])) {
SET_CACHE_PARAM(cache_param_promotion_policy_type,
ocf_promotion_always);
} else if (!strcmp("nhit", arg[0])) {
SET_CACHE_PARAM(cache_param_promotion_policy_type,
ocf_promotion_nhit);
} else {
cas_printf(LOG_ERR, "Error: Invalid policy name.\n");
return FAILURE;
}
} else {
return FAILURE;
}
return SUCCESS;
}
int set_param_promotion_nhit_handle_option(char *opt, const char **arg)
{
if (!strcmp(opt, "threshold")) {
if (validate_str_num(arg[0], "threshold",
OCF_NHIT_MIN_THRESHOLD, OCF_NHIT_MAX_THRESHOLD)) {
return FAILURE;
}
SET_CACHE_PARAM(cache_param_promotion_nhit_insertion_threshold,
strtoul(arg[0], NULL, 10));
} else if (!strcmp(opt, "trigger")) {
if (validate_str_num(arg[0], "trigger",
OCF_NHIT_MIN_TRIGGER, OCF_NHIT_MAX_THRESHOLD)) {
return FAILURE;
}
SET_CACHE_PARAM(cache_param_promotion_nhit_trigger_threshold,
strtoul(arg[0], NULL, 10));
} else {
return FAILURE;
}
@ -793,6 +882,12 @@ int set_param_namespace_handle_option(char *namespace, char *opt, const char **a
} else if (!strcmp(namespace, "cleaning-acp")) {
return cache_param_handle_option_generic(opt, arg,
set_param_cleaning_acp_handle_option);
} else if (!strcmp(namespace, "promotion")) {
return cache_param_handle_option_generic(opt, arg,
set_param_promotion_handle_option);
} else if (!strcmp(namespace, "promotion-nhit")) {
return cache_param_handle_option_generic(opt, arg,
set_param_promotion_nhit_handle_option);
} else {
return FAILURE;
}
@ -831,6 +926,8 @@ static cli_namespace get_param_namespace = {
GET_CACHE_PARAMS_NS("cleaning", "Cleaning policy parameters")
GET_CACHE_PARAMS_NS("cleaning-alru", "Cleaning policy ALRU parameters")
GET_CACHE_PARAMS_NS("cleaning-acp", "Cleaning policy ACP parameters")
GET_CACHE_PARAMS_NS("promotion", "Promotion policy parameters")
GET_CACHE_PARAMS_NS("promotion-nhit", "Promotion policy NHIT parameters")
{0},
},
@ -872,6 +969,15 @@ int get_param_namespace_handle_option(char *namespace, char *opt, const char **a
SELECT_CACHE_PARAM(cache_param_cleaning_acp_flush_max_buffers);
return cache_param_handle_option_generic(opt, arg,
get_param_handle_option);
} else if (!strcmp(namespace, "promotion")) {
SELECT_CACHE_PARAM(cache_param_promotion_policy_type);
return cache_param_handle_option_generic(opt, arg,
get_param_handle_option);
} else if (!strcmp(namespace, "promotion-nhit")) {
SELECT_CACHE_PARAM(cache_param_promotion_nhit_insertion_threshold);
SELECT_CACHE_PARAM(cache_param_promotion_nhit_trigger_threshold);
return cache_param_handle_option_generic(opt, arg,
get_param_handle_option);
} else {
return FAILURE;
}

View File

@ -548,6 +548,8 @@ int cache_stats_conf(int ctrl_fd, const struct kcas_cache_info *cache_info,
eviction_policy_to_name(cache_info->info.eviction_policy));
print_kv_pair(outfile, "Cleaning Policy", "%s",
cleaning_policy_to_name(cache_info->info.cleaning_policy));
print_kv_pair(outfile, "Promotion Policy", "%s",
promotion_policy_to_name(cache_info->info.promotion_policy));
print_kv_pair(outfile, "Cache line size", "%llu, [KiB]",
cache_info->info.cache_line_size / KiB);

View File

@ -348,6 +348,73 @@ int cache_mngt_get_cleaning_param(ocf_cache_t cache, ocf_cleaning_t type,
return result;
}
int cache_mngt_set_promotion_policy(ocf_cache_t cache, uint32_t type)
{
int result;
result = _cache_mngt_lock_sync(cache);
if (result) {
return result;
}
result = ocf_mngt_cache_promotion_set_policy(cache, type);
if (result)
goto out;
result = _cache_mngt_save_sync(cache);
out:
ocf_mngt_cache_unlock(cache);
return result;
}
int cache_mngt_get_promotion_policy(ocf_cache_t cache, uint32_t *type)
{
int result;
result = _cache_mngt_read_lock_sync(cache);
if (result) {
return result;
}
*type = ocf_mngt_cache_promotion_get_policy(cache);
ocf_mngt_cache_read_unlock(cache);
return result;
}
int cache_mngt_set_promotion_param(ocf_cache_t cache, uint32_t param_id,
uint32_t param_value)
{
int result;
result = _cache_mngt_lock_sync(cache);
if (result) {
return result;
}
result = ocf_mngt_cache_promotion_set_param(cache, param_id, param_value);
ocf_mngt_cache_unlock(cache);
return result;
}
int cache_mngt_get_promotion_param(ocf_cache_t cache, uint32_t param_id,
uint32_t *param_value)
{
int result;
result = _cache_mngt_read_lock_sync(cache);
if (result) {
return result;
}
result = ocf_mngt_cache_promotion_get_param(cache, param_id, param_value);
ocf_mngt_cache_read_unlock(cache);
return result;
}
struct get_paths_ctx {
char *core_path_name_tab;
int max_count;
@ -1064,6 +1131,7 @@ int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
cfg->cache_mode = cmd->caching_mode;
cfg->cache_line_size = cmd->line_size;
cfg->eviction_policy = cmd->eviction_policy;
cfg->promotion_policy = ocf_promotion_default;
cfg->cache_line_size = cmd->line_size;
cfg->pt_unaligned_io = !unaligned_io;
cfg->use_submit_io_fast = !use_io_scheduler;
@ -2055,6 +2123,17 @@ int cache_mngt_set_cache_params(struct kcas_set_cache_param *info)
ocf_cleaning_acp, ocf_acp_flush_max_buffers,
info->param_value);
break;
case cache_param_promotion_policy_type:
result = cache_mngt_set_promotion_policy(cache, info->param_value);
break;
case cache_param_promotion_nhit_insertion_threshold:
result = cache_mngt_set_promotion_param(cache,
ocf_nhit_insertion_threshold, info->param_value);
break;
case cache_param_promotion_nhit_trigger_threshold:
result = cache_mngt_set_promotion_param(cache,
ocf_nhit_trigger_threshold, info->param_value);
break;
default:
result = -EINVAL;
}
@ -2109,6 +2188,19 @@ int cache_mngt_get_cache_params(struct kcas_get_cache_param *info)
ocf_cleaning_acp, ocf_acp_flush_max_buffers,
&info->param_value);
break;
case cache_param_promotion_policy_type:
result = cache_mngt_get_promotion_policy(cache, &info->param_value);
break;
case cache_param_promotion_nhit_insertion_threshold:
result = cache_mngt_get_promotion_param(cache,
ocf_nhit_insertion_threshold,
&info->param_value);
break;
case cache_param_promotion_nhit_trigger_threshold:
result = cache_mngt_get_promotion_param(cache,
ocf_nhit_trigger_threshold,
&info->param_value);
break;
default:
result = -EINVAL;
}

View File

@ -20,6 +20,16 @@ int cache_mngt_set_cleaning_param(ocf_cache_t cache, ocf_cleaning_t type,
int cache_mngt_get_cleaning_param(ocf_cache_t cache, ocf_cleaning_t type,
uint32_t param_id, uint32_t *param_value);
int cache_mngt_set_promotion_policy(ocf_cache_t cache, uint32_t type);
int cache_mngt_get_promotion_policy(ocf_cache_t cache, uint32_t *type);
int cache_mngt_set_promotion_param(ocf_cache_t cache, uint32_t param_id,
uint32_t param_value);
int cache_mngt_get_promotion_param(ocf_cache_t cache, uint32_t param_id,
uint32_t *param_value);
int cache_mngt_add_core_to_cache(const char *cache_name,
struct ocf_mngt_core_config *cfg,
struct kcas_insert_core *cmd_info);

View File

@ -66,6 +66,10 @@ bool cas_upgrade_is_in_upgrade(void)
* |core | core_X_path | string |
* |core | core_X_type | uint |
* |------------|-------------------------------|---------------|
* |promotion | promotion_policy | uint |
* |promotion | nhit_insertion_threshold| uint |
* |promotion | nhit_insertion_trigger | uint |
* |------------|-------------------------------|---------------|
* |flush | flush_cleaning_policy | uint |
* |flush | flush_wake_up_time | uint |
* |flush | flush_staleness_time | uint |
@ -99,6 +103,10 @@ bool cas_upgrade_is_in_upgrade(void)
#define CORE_SEQ_CUTOFF_THRESHOLD_STR "core_%lu_seq_cutoff_thresh"
#define CORE_SEQ_CUTOFF_POLICY_STR "core_%lu_seq_cutoff_policy"
#define PROMOTION_POLICY_STR "promotion_policy"
#define PROMOTION_NHIT_INSERTION_STR "nhit_insertion_threshold"
#define PROMOTION_NHIT_TRIGGER_STR "nhit_trigger_threshold"
#define CLEANING_POLICY_STR "flush_cleaning_policy"
#define CLEANING_ALRU_WAKEUP_TIME_STR "flush_wakeup_time"
#define CLEANING_ALRU_STALENESS_TIME_STR "flush_staleness_time"
@ -116,7 +124,8 @@ bool cas_upgrade_is_in_upgrade(void)
#define IO_CLASS_CACHE_MODE_STR "io_class_%lu_cache_mode"
#define CAS_UPGRADE_IFACE_VERSION_19_03_00 190300
#define CAS_UPGRADE_IFACE_CURRENT_VERSION CAS_UPGRADE_IFACE_VERSION_19_03_00
#define CAS_UPGRADE_IFACE_VERSION_19_09_00 190900
#define CAS_UPGRADE_IFACE_CURRENT_VERSION CAS_UPGRADE_IFACE_VERSION_19_09_00
static int _cas_upgrade_dump_cache_conf_main(ocf_cache_t cache,
struct cas_properties *cache_props)
@ -305,6 +314,72 @@ err:
return result;
}
static int _cas_upgrade_dump_cache_conf_promotion(ocf_cache_t cache,
struct cas_properties *cache_props)
{
uint32_t promotion_type = ocf_promotion_default;
uint32_t nhit_insertion_threshold;
uint32_t nhit_trigger_threshold;
int result = 0;
result = cache_mngt_get_promotion_policy(cache, &promotion_type);
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT
"Unable to get promotion policy type\n");
return result;
}
if (promotion_type == ocf_promotion_nhit) {
result |= cache_mngt_get_promotion_param(cache,
ocf_nhit_insertion_threshold,
&nhit_insertion_threshold);
result |= cache_mngt_get_promotion_param(cache,
ocf_nhit_trigger_threshold,
&nhit_trigger_threshold);
}
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT
"Unable to get promotion policy params\n");
return result;
}
result = cas_properties_add_uint(cache_props, PROMOTION_POLICY_STR,
promotion_type, CAS_PROPERTIES_CONST);
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT
"Error during adding promotion policy type\n");
return result;
}
if (promotion_type == ocf_promotion_nhit) {
result = cas_properties_add_uint(cache_props,
PROMOTION_NHIT_INSERTION_STR,
nhit_insertion_threshold,
CAS_PROPERTIES_CONST);
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT
"Error during adding nhit insertion "
"threshold\n");
return result;
}
result = cas_properties_add_uint(cache_props,
PROMOTION_NHIT_TRIGGER_STR,
nhit_trigger_threshold,
CAS_PROPERTIES_CONST);
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT
"Error during adding nhit trigger "
"threshold\n");
return result;
}
}
return result;
}
static int _cas_upgrade_dump_cache_conf_flush(ocf_cache_t cache,
struct cas_properties *cache_props)
{
@ -315,6 +390,7 @@ static int _cas_upgrade_dump_cache_conf_flush(ocf_cache_t cache,
uint32_t alru_activity_threshold;
uint32_t acp_thread_wakeup_time;
uint32_t acp_flush_max_buffers;
int result = 0;
CAS_DEBUG_TRACE();
@ -586,6 +662,10 @@ static int _cas_upgrade_dump_cache_conf(ocf_cache_t device,
if (result)
return result;
result = _cas_upgrade_dump_cache_conf_promotion(device, cache_props);
if (result)
return result;
result = _cas_upgrade_dump_cache_conf_io_class(device, cache_props);
if (result)
return result;
@ -1078,6 +1158,68 @@ static int _cas_upgrade_restore_conf_flush(struct cas_properties *cache_props,
return result;
}
static int _cas_upgrade_restore_conf_promotion(struct cas_properties *cache_props,
ocf_cache_t cache)
{
uint64_t promotion_type;
uint64_t nhit_insertion_threshold;
uint64_t nhit_trigger_threshold;
int result = 0;
result = cas_properties_get_uint(cache_props, PROMOTION_POLICY_STR,
&promotion_type);
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT "Couldn't retrieve promotion "
"policy type \n");
goto out;
}
result = cache_mngt_set_promotion_policy(cache, promotion_type);
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT "Couldn't set promotion policy\n");
goto out;
}
if (promotion_type != ocf_promotion_nhit)
goto out;
result = cas_properties_get_uint(cache_props,
PROMOTION_NHIT_INSERTION_STR, &nhit_insertion_threshold);
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT "Couldn't retrieve NHIT insertion "
"threshold parameter \n");
goto out;
}
result = cas_properties_get_uint(cache_props,
PROMOTION_NHIT_TRIGGER_STR, &nhit_trigger_threshold);
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT "Couldn't retrieve NHIT insertion "
"trigger parameter \n");
goto out;
}
result = cache_mngt_set_promotion_param(cache, ocf_nhit_insertion_threshold,
nhit_insertion_threshold);
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT "Couldn't set NHIT insertion "
"threshold parameter \n");
goto out;
}
result = cache_mngt_set_promotion_param(cache, ocf_nhit_trigger_threshold,
nhit_trigger_threshold);
if (result) {
printk(KERN_ERR OCF_PREFIX_SHORT "Couldn't set NHIT trigger "
"threshold parameter \n");
goto out;
}
out:
return result;
}
static int _cas_upgrade_restore_conf_io_class(
struct cas_properties *cache_props, ocf_cache_t cache)
{
@ -1210,6 +1352,10 @@ static int _cas_upgrade_restore_cache(struct cas_properties *cache_props)
if (result)
goto error;
result = _cas_upgrade_restore_conf_promotion(cache_props, cache);
if (result)
goto error;
result = _cas_upgrade_restore_conf_io_class(cache_props, cache);
if (result)
goto error;

View File

@ -353,6 +353,9 @@ enum kcas_cache_param_id {
cache_param_cleaning_alru_activity_threshold,
cache_param_cleaning_acp_wake_up_time,
cache_param_cleaning_acp_flush_max_buffers,
cache_param_promotion_policy_type,
cache_param_promotion_nhit_insertion_threshold,
cache_param_promotion_nhit_trigger_threshold,
cache_param_id_max,
};

2
ocf

@ -1 +1 @@
Subproject commit f86287ef06190b080f9529c9f2514e56da8b726b
Subproject commit af48ee56e3d86c5de4a0ce7def35a1fedf35edf4

View File

@ -236,6 +236,8 @@ Available namespaces are:
\fBcleaning\fR - Cleaning policy parameters.
\fBcleaning-alru\fR - Cleaning policy ALRU parameters.
\fBcleaning-acp\fR - Cleaning policy ACP parameters.
\fBpromotion\fR - Promotion policy parameters.
\fBpromotion-nhit\fR - Promotion policy NHIT parameters.
.SH Options that are valid with --set-param (-X) --name (-n) seq-cutoff are:
@ -310,6 +312,36 @@ Period of time between awakenings of flushing thread [ms] (default: 10 ms).
.B -b, --flush-max-buffers <NUMBER>
Number of dirty cache blocks to be flushed in one cleaning cycle (default: 128).
.SH Options that are valid with --set-param (-X) --name (-n) promotion are:
.TP
.B -i, --cache-id <ID>
Identifier of cache instance <1-16384>.
.TP
.B -p, --policy {always|nhit}
Promotion policy type to be used with a given cache instance.
Available policies:
.br
1. \fBalways\fR. Core lines are attempted to be promoted each time they're accessed.
.br
2. \fBnhit\fR. Core lines are attempted to be promoted after n accesses.
.SH Options that are valid with --set-param (-X) --name (-n) promotion-nhit are:
.TP
.B -i, --cache-id <ID>
Identifier of cache instance <1-16384>.
.TP
.B -o, --trigger <PERCENTAGE>
Percent of cache to be occupied before cache inserts will be filtered by the policy.
.TP
.B -t, --threshold <NUMBER>
Number of core line accesses required for it to be inserted into cache.
.SH Options that are valid with --get-param (-G) are:
.TP
@ -322,6 +354,8 @@ Available namespaces are:
\fBcleaning\fR - Cleaning policy parameters.
\fBcleaning-alru\fR - Cleaning policy ALRU parameters.
\fBcleaning-acp\fR - Cleaning policy ACP parameters.
\fBpromotion\fR - Promotion policy parameters.
\fBpromotion-nhit\fR - Promotion policy NHIT parameters.
.SH Options that are valid with --get-param (-G) --name (-n) seq-cutoff are:
@ -367,6 +401,26 @@ Identifier of cache instance <1-16384>.
.B -o, --output-format {table|csv}
Defines output format for parameter list. It can be either \fBtable\fR (default) or \fBcsv\fR.
.SH Options that are valid with --get-param (-G) --name (-n) promotion are:
.TP
.B -i, --cache-id <ID>
Identifier of cache instance <1-16384>.
.TP
.B -o, --output-format {table|csv}
Defines output format for parameter list. It can be either \fBtable\fR (default) or \fBcsv\fR.
.SH Options that are valid with --get-param (-G) --name (-n) promotion-nhit are:
.TP
.B -i, --cache-id <ID>
Identifier of cache instance <1-16384>.
.TP
.B -o, --output-format {table|csv}
Defines output format for parameter list. It can be either \fBtable\fR (default) or \fBcsv\fR.
.SH Options that are valid with --set-cache-mode (-Q) are:
.TP
.B -c, --cache-mode {wt|wb|wa|pt}

View File

@ -24,7 +24,7 @@ Cache device <DEVICE>
.br
Cache mode {wt|wb|wa|pt}
.br
Extra fields (optional) ioclass_file=<file>,cleaning_policy=<alru,nop>
Extra fields (optional) ioclass_file=<file>,cleaning_policy=<alru,nop>,promotion_policy=<always,nhit>
.RE
.TP
\fB[cores]\fR Cores configuration. Following columns are required:

View File

@ -236,6 +236,8 @@ class cas_config(object):
raise ValueError('Incorrect path to io_class file')
elif param_name == 'cleaning_policy':
self.check_cleaning_policy_valid(param_value)
elif param_name == 'promotion_policy':
self.check_promotion_policy_valid(param_value)
elif param_name == 'cache_line_size':
self.check_cache_line_size_valid(param_value)
else:
@ -269,6 +271,11 @@ class cas_config(object):
raise ValueError('{0} is invalid cleaning policy name'.format(
cleaning_policy))
def check_promotion_policy_valid(self, promotion_policy):
if promotion_policy.lower() not in ['always', 'nhit']:
raise ValueError('{0} is invalid promotion policy name'.format(
promotion_policy))
def check_cache_line_size_valid(self, cache_line_size):
if cache_line_size not in ['4', '8', '16', '32', '64']:
raise ValueError('{0} is invalid cache line size'.format(
@ -500,12 +507,19 @@ def start_cache(cache, load, force=False):
force=force)
def configure_cache(cache):
if 'cleaning_policy' in cache.params:
casadm.set_param('cleaning', cache_id=cache.cache_id,
policy=cache.params['cleaning_policy'])
if 'ioclass_file' in cache.params:
casadm.io_class_load_config(cache_id=cache.cache_id,
ioclass_file=cache.params['ioclass_file'])
if "cleaning_policy" in cache.params:
casadm.set_param(
"cleaning", cache_id=cache.cache_id, policy=cache.params["cleaning_policy"]
)
if "promotion_policy" in cache.params:
casadm.set_param(
"promotion", cache_id=cache.cache_id, policy=cache.params["promotion"]
)
if "ioclass_file" in cache.params:
casadm.io_class_load_config(
cache_id=cache.cache_id, ioclass_file=cache.params["ioclass_file"]
)
def add_core(core, attach):
casadm.add_core(