standard error message for each disallowed management operation in standby mode

Signed-off-by: Piotr Debski <piotr.debski@intel.com>
This commit is contained in:
Piotr Debski 2022-04-11 06:08:42 +02:00
parent a3e6284e4c
commit f773d7fff3
3 changed files with 17 additions and 20 deletions

View File

@ -1099,8 +1099,7 @@ int get_cache_mode(int ctrl_fd, unsigned int cache_id, int *mode)
if (ioctl(ctrl_fd, KCAS_IOCTL_CACHE_INFO, &cmd_info) < 0)
{
if (cmd_info.ext_err_code == OCF_ERR_CACHE_STANDBY)
cas_printf(LOG_ERR, "Cannot get cache mode while cache %d is in standby mode.", cmd_info.cache_id);
print_err(cmd_info.ext_err_code);
return FAILURE;
}
*mode = cmd_info.info.cache_mode;
@ -1166,8 +1165,7 @@ int set_cache_mode(unsigned int cache_mode, unsigned int cache_id, int flush)
"'--flush-cache no' parameter.\n");
return INTERRUPTED;
} else if (OCF_ERR_CACHE_STANDBY == cmd.ext_err_code) {
cas_printf(LOG_ERR, "Cannot change cache mode while cache %d is in standby mode\n",
cache_id);
print_err(cmd.ext_err_code);
return FAILURE;
} else {
cas_printf(LOG_ERR, "Error while setting cache state for cache %d\n",
@ -1229,7 +1227,7 @@ int core_params_set(unsigned int cache_id, unsigned int core_id,
if (run_ioctl(fd, KCAS_IOCTL_SET_CORE_PARAM, &cmd) < 0) {
close(fd);
if (cmd.ext_err_code == OCF_ERR_CACHE_STANDBY) {
cas_printf(LOG_ERR, "Cannot set parameters for cache %d while in standby mode.\n", cmd.cache_id);
print_err(cmd.ext_err_code);
}
return FAILURE;
}
@ -1331,8 +1329,7 @@ int cache_params_set(unsigned int cache_id, struct cas_param *params)
if (run_ioctl(fd, KCAS_IOCTL_SET_CACHE_PARAM, &cmd) < 0) {
if (cmd.ext_err_code == OCF_ERR_CACHE_STANDBY)
cas_printf(LOG_ERR, "Cannot set cache parameters while cache %d is in standby mode\n", cmd.cache_id);
print_err(cmd.ext_err_code);
close(fd);
return FAILURE;
}
@ -1374,7 +1371,7 @@ int cache_params_get(unsigned int cache_id, struct cas_param *params,
if (cmd.ext_err_code == OCF_ERR_CACHE_NOT_EXIST)
cas_printf(LOG_ERR, "Cache id %d not running\n", cache_id);
else if (cmd.ext_err_code == OCF_ERR_CACHE_STANDBY)
cas_printf(LOG_ERR, "Cannot get cache parameters while cache %d is in standby mode\n", cmd.cache_id);
print_err(cmd.ext_err_code);
else
cas_printf(LOG_ERR, "Can't get parameters\n");
fclose(intermediate_file[0]);
@ -1701,8 +1698,6 @@ int add_core(unsigned int cache_id, unsigned int core_id, const char *core_devic
"accessing it or unmount the device.\n",
user_core_path);
}
} else if (OCF_ERR_CACHE_STANDBY == cmd.ext_err_code) {
cas_printf(LOG_ERR, "Cannot add core to cache %d in standby mode\n", cache_id);
} else {
print_err(cmd.ext_err_code);
}
@ -1939,9 +1934,6 @@ int flush_cache(unsigned int cache_id)
if (OCF_ERR_FLUSHING_INTERRUPTED == cmd.ext_err_code) {
cas_printf(LOG_ERR, DIRTY_FLUSHING_WARNING);
return INTERRUPTED;
} else if (OCF_ERR_CACHE_STANDBY == cmd.ext_err_code) {
cas_printf(LOG_ERR, "Cannot flush cache %d in standby mode\n", cmd.cache_id);
return FAILURE;
} else {
print_err(cmd.ext_err_code);
return FAILURE;
@ -1969,10 +1961,7 @@ int purge_core(unsigned int cache_id, unsigned int core_id)
if (run_ioctl_interruptible(fd, KCAS_IOCTL_PURGE_CORE, &cmd, "Purging core", cache_id, core_id) < 0) {
close(fd);
if (OCF_ERR_CACHE_STANDBY == cmd.ext_err_code)
cas_printf(LOG_ERR, "Cannot purge core while cache %d is in standby mode\n", cmd.cache_id);
else
print_err(cmd.ext_err_code);
print_err(cmd.ext_err_code);
return FAILURE;
}
@ -2393,7 +2382,7 @@ int partition_set_config(struct kcas_io_classes *cnfg)
if (OCF_ERR_IO_CLASS_NOT_EXIST == cnfg->ext_err_code) {
result = SUCCESS;
} else if (OCF_ERR_CACHE_STANDBY == cnfg->ext_err_code) {
cas_printf(LOG_ERR, "Cannot set IO class config for cache %d while in standby mode.\n", cnfg->cache_id);
print_err(cnfg->ext_err_code);
result = FAILURE;
} else {
print_err(cnfg->ext_err_code);
@ -2469,12 +2458,14 @@ int reset_counters(unsigned int cache_id, unsigned int core_id)
cmd.core_id = core_id;
if (ioctl(fd, KCAS_IOCTL_RESET_STATS, &cmd) < 0) {
if (OCF_ERR_CACHE_STANDBY == cmd.ext_err_code) {
cas_printf(LOG_ERR, "Cannot reset statistics for cache %d while in standby mode.\n", cmd.cache_id);
print_err(cmd.ext_err_code);
} else {
cas_printf(LOG_ERR, "Error encountered while resetting counters\n");
print_err(cmd.ext_err_code);
}
close(fd);
return FAILURE;
}

View File

@ -180,7 +180,7 @@ struct {
},
{
OCF_ERR_CACHE_STANDBY,
"Operation not permitted in failover standby mode"
"The operation is not permited while the cache is in the standby mode"
},
{
OCF_ERR_STANDBY_ATTACHED,

View File

@ -1711,6 +1711,11 @@ int cache_mngt_set_partitions(const char *cache_name, size_t name_len,
name_len, &cache);
if (result)
goto out_get;
if (ocf_cache_is_standby(cache)) {
result = -OCF_ERR_CACHE_STANDBY;
goto out_standby;
}
for (class_id = 0; class_id < OCF_USER_IO_CLASS_MAX; class_id++) {
result = cas_cls_rule_create(cache, class_id,
@ -1744,6 +1749,7 @@ out_cls:
while (class_id--)
cas_cls_rule_destroy(cache, cls_rule[class_id]);
}
out_standby:
ocf_mngt_cache_put(cache);
out_get:
kfree(io_class_cfg);