Return error when modifying default ioclass rule

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2021-03-19 12:22:35 +01:00
parent ca4c2238b4
commit 0d3f3cde14
2 changed files with 14 additions and 3 deletions

View File

@ -135,9 +135,18 @@ static int _ocf_mngt_io_class_configure(ocf_cache_t cache,
if (part_id == PARTITION_DEFAULT) { if (part_id == PARTITION_DEFAULT) {
/* Special behavior for default partition */ /* Special behavior for default partition */
if (env_strncmp(name, OCF_IO_CLASS_NAME_MAX,
dest_part->config->name, OCF_IO_CLASS_NAME_MAX)) {
ocf_cache_log(cache, log_err,
"Can't change classification rule of the default IO class"
" [ ERROR ]\n");
return -OCF_ERR_INVAL;
}
/* Try set partition size */ /* Try set partition size */
if (_ocf_mngt_set_partition_size(cache, part_id, min, max)) { if (_ocf_mngt_set_partition_size(cache, part_id, min, max)) {
ocf_cache_log(cache, log_info, ocf_cache_log(cache, log_err,
"Setting IO class size, id: %u, name: '%s', max size: %u%%" "Setting IO class size, id: %u, name: '%s', max size: %u%%"
" [ ERROR ]\n", part_id, dest_part->config->name, max); " [ ERROR ]\n", part_id, dest_part->config->name, max);
return -OCF_ERR_INVAL; return -OCF_ERR_INVAL;
@ -161,7 +170,7 @@ static int _ocf_mngt_io_class_configure(ocf_cache_t cache,
/* Try set partition size */ /* Try set partition size */
if (_ocf_mngt_set_partition_size(cache, part_id, min, max)) { if (_ocf_mngt_set_partition_size(cache, part_id, min, max)) {
ocf_cache_log(cache, log_info, ocf_cache_log(cache, log_err,
"Setting IO class size, id: %u, name: '%s', max size %u%%" "Setting IO class size, id: %u, name: '%s', max size %u%%"
"[ ERROR ]\n", part_id, dest_part->config->name, max); "[ ERROR ]\n", part_id, dest_part->config->name, max);
return -OCF_ERR_INVAL; return -OCF_ERR_INVAL;

View File

@ -95,7 +95,7 @@ static inline void setup_valid_config(struct ocf_mngt_io_class_config *cfg,
int i; int i;
for (i = 0; i < OCF_IO_CLASS_MAX; i++) { for (i = 0; i < OCF_IO_CLASS_MAX; i++) {
cfg[i].class_id = i; cfg[i].class_id = i;
cfg[i].name = remove ? NULL : "test_io_class_name" ; cfg[i].name = remove ? NULL : i == 0 ? "unclassified" :"test_io_class_name" ;
cfg[i].prio = i; cfg[i].prio = i;
cfg[i].cache_mode = ocf_cache_mode_pt; cfg[i].cache_mode = ocf_cache_mode_pt;
cfg[i].max_size = 20*i; cfg[i].max_size = 20*i;
@ -161,6 +161,8 @@ static void ocf_mngt_io_classes_configure_test02(void **state)
cache->user_parts[i].config = cache->user_parts[i].config =
test_malloc(sizeof(struct ocf_user_part_config)); test_malloc(sizeof(struct ocf_user_part_config));
} }
strcpy(cache->user_parts[0].config->name, "unclassified");
cache->device = 1; cache->device = 1;
setup_valid_config(cfg.config, false); setup_valid_config(cfg.config, false);