casadm: occupancy per ioclass
Enable new ioclass config format with float allocation values Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
93a6a1670f
commit
c93d1f73ef
@ -2031,11 +2031,10 @@ void partition_list_line(FILE *out, struct kcas_io_class *cls, bool csv)
|
|||||||
{
|
{
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
const char *prio;
|
const char *prio;
|
||||||
const char *allocation;
|
char allocation_str[MAX_STR_LEN];
|
||||||
if (cls->info.cache_mode != ocf_cache_mode_pt)
|
|
||||||
allocation = csv ? "1" : "YES";
|
snprintf(allocation_str, sizeof(allocation_str), "%d.%02d",
|
||||||
else
|
cls->info.max_size/100, cls->info.max_size%100);
|
||||||
allocation = csv ? "0" : "NO";
|
|
||||||
|
|
||||||
if (OCF_IO_CLASS_PRIO_PINNED == cls->info.priority) {
|
if (OCF_IO_CLASS_PRIO_PINNED == cls->info.priority) {
|
||||||
prio = csv ? "" : "Pinned";
|
prio = csv ? "" : "Pinned";
|
||||||
@ -2045,7 +2044,7 @@ void partition_list_line(FILE *out, struct kcas_io_class *cls, bool csv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf(out, TAG(TABLE_ROW)"%u,%s,%s,%s\n",
|
fprintf(out, TAG(TABLE_ROW)"%u,%s,%s,%s\n",
|
||||||
cls->class_id, cls->info.name, prio, allocation);
|
cls->class_id, cls->info.name, prio, allocation_str);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2061,6 +2060,7 @@ int partition_list(unsigned int cache_id, unsigned int output_format)
|
|||||||
if (fd == -1 )
|
if (fd == -1 )
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
|
||||||
|
|
||||||
if (create_pipe_pair(intermediate_file)) {
|
if (create_pipe_pair(intermediate_file)) {
|
||||||
cas_printf(LOG_ERR,"Failed to create unidirectional pipe.\n");
|
cas_printf(LOG_ERR,"Failed to create unidirectional pipe.\n");
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -2118,8 +2118,11 @@ int partition_list(unsigned int cache_id, unsigned int output_format)
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
part_csv_coll_id = 0, part_csv_coll_name, part_csv_coll_prio,
|
part_csv_coll_id = 0,
|
||||||
part_csv_coll_alloc, part_csv_coll_max
|
part_csv_coll_name,
|
||||||
|
part_csv_coll_prio,
|
||||||
|
part_csv_coll_alloc,
|
||||||
|
part_csv_coll_max
|
||||||
};
|
};
|
||||||
|
|
||||||
int partition_is_name_valid(const char *name)
|
int partition_is_name_valid(const char *name)
|
||||||
@ -2157,6 +2160,28 @@ static inline const char *partition_get_csv_col(CSVFILE *csv, int col,
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int calculate_max_allocation(uint16_t cache_id, const char *allocation,
|
||||||
|
uint32_t *part_size)
|
||||||
|
{
|
||||||
|
float alloc = 0;
|
||||||
|
char *end;
|
||||||
|
|
||||||
|
if (strnlen(allocation, MAX_STR_LEN) > 4)
|
||||||
|
return FAILURE;
|
||||||
|
|
||||||
|
alloc = strtof(allocation, &end);
|
||||||
|
if (alloc > 1 || alloc < 0)
|
||||||
|
return FAILURE;
|
||||||
|
|
||||||
|
if (allocation + strnlen(allocation, MAX_STR_LEN) != end)
|
||||||
|
return FAILURE;
|
||||||
|
|
||||||
|
*part_size = (uint32_t)(alloc * 100);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline int partition_get_line(CSVFILE *csv,
|
static inline int partition_get_line(CSVFILE *csv,
|
||||||
struct kcas_io_classes *cnfg,
|
struct kcas_io_classes *cnfg,
|
||||||
int *error_col)
|
int *error_col)
|
||||||
@ -2227,20 +2252,13 @@ static inline int partition_get_line(CSVFILE *csv,
|
|||||||
if (strempty(alloc)) {
|
if (strempty(alloc)) {
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
if (validate_str_num(alloc, "alloc", 0, 1)) {
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
value = strtoul(alloc, NULL, 10);
|
|
||||||
if (0 == value) {
|
|
||||||
cnfg->info[part_id].cache_mode = ocf_cache_mode_pt;
|
|
||||||
} else if (1 == value) {
|
|
||||||
cnfg->info[part_id].cache_mode = ocf_cache_mode_max;
|
|
||||||
} else {
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (calculate_max_allocation(cnfg->cache_id, alloc, &value) == FAILURE)
|
||||||
|
return FAILURE;
|
||||||
|
|
||||||
|
cnfg->info[part_id].cache_mode = ocf_cache_mode_max;
|
||||||
cnfg->info[part_id].min_size = 0;
|
cnfg->info[part_id].min_size = 0;
|
||||||
cnfg->info[part_id].max_size = UINT32_MAX;
|
cnfg->info[part_id].max_size = value;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -403,9 +403,7 @@ static void print_stats_ioclass_conf(const struct kcas_io_class* io_class,
|
|||||||
print_kv_pair(outfile, "Eviction priority", "%d",
|
print_kv_pair(outfile, "Eviction priority", "%d",
|
||||||
io_class->info.priority);
|
io_class->info.priority);
|
||||||
}
|
}
|
||||||
print_kv_pair(outfile, "Selective allocation", "%s",
|
print_kv_pair(outfile, "Max size", "%u%%", io_class->info.max_size);
|
||||||
io_class->info.cache_mode != ocf_cache_mode_pt ?
|
|
||||||
"Yes" : "No");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user