Print separate messages for different "remove core" return codes

Change extended error message for `KCAS_ERR_REMOVED_DIRTY`.
Print informative messages when `remove core` command fails.
Make separate error messages for detaching.
Update help printouts.
Update documentation comments.

Signed-off-by: Slawomir Jankowski <slawomir.jankowski@intel.com>
This commit is contained in:
Slawomir Jankowski 2021-02-17 15:35:57 +01:00
parent f955ce890c
commit 2bf6e42dea
4 changed files with 24 additions and 12 deletions

View File

@ -1904,12 +1904,24 @@ int remove_core(unsigned int cache_id, unsigned int core_id,
if (run_ioctl_interruptible(fd, KCAS_IOCTL_REMOVE_CORE, &cmd,
"Removing core", cache_id, core_id) < 0) {
close(fd);
if (OCF_ERR_FLUSHING_INTERRUPTED == cmd.ext_err_code) {
cas_printf(LOG_ERR, "You have interrupted removal of core. CAS continues to operate normally.\n");
if (cmd.ext_err_code == OCF_ERR_FLUSHING_INTERRUPTED) {
cas_printf(LOG_ERR, "You have interrupted %s of core. "
"CAS continues to operate normally.\n",
detach ? "detaching" : "removal");
return INTERRUPTED;
} else if (cmd.ext_err_code == OCF_ERR_CORE_IN_INACTIVE_STATE) {
cas_printf(LOG_ERR, "Core is inactive. To manage the "
"inactive core use '--remove-inactive' "
"command.\n");
return FAILURE;
} else if (cmd.ext_err_code == KCAS_ERR_REMOVED_DIRTY) {
print_err(cmd.ext_err_code);
return SUCCESS;
} else {
cas_printf(LOG_ERR, "Error while removing core device %d from cache instance %d\n",
core_id, cache_id);
cas_printf(LOG_ERR, "Error while %s core device %d "
"from cache instance %d\n",
detach ? "detaching" : "removing",
core_id, cache_id);
print_err(cmd.ext_err_code);
return FAILURE;
}

View File

@ -1109,7 +1109,7 @@ int handle_add()
static cli_option remove_options[] = {
{'i', "cache-id", CACHE_ID_DESC, 1, "ID", CLI_OPTION_REQUIRED},
{'j', "core-id", CORE_ID_DESC, 1, "ID", CLI_OPTION_REQUIRED},
{'f', "force", "Force remove inactive core"},
{'f', "force", "Force active core removal without data flush"},
{0}
};
@ -1961,7 +1961,7 @@ static cli_command cas_commands[] = {
{
.name = "remove-core",
.short_name = 'R',
.desc = "Remove core device from cache instance",
.desc = "Remove active core device from cache instance",
.long_desc = NULL,
.options = remove_options,
.command_handle_opts = remove_core_command_handle_option,

View File

@ -222,8 +222,8 @@ struct {
},
{
KCAS_ERR_REMOVED_DIRTY,
"Flush error occured. Core has been set to detached state.\n"
"Warning: Core device may contain inconsistent data.\n"
"Warning: Core has been removed or detached without flush.\n"
"Core device may contain inconsistent data.\n"
"To access your data please add core back to the cache."
},
{

View File

@ -117,7 +117,7 @@ struct kcas_insert_core {
struct kcas_remove_core {
uint16_t cache_id; /**< id of an running cache */
uint16_t core_id; /**< id core object to be removed */
bool force_no_flush; /**< remove core without flushing */
bool force_no_flush; /**< remove active core without flushing */
bool detach; /**< detach core without removing it from cache metadata */
int ext_err_code;
@ -473,7 +473,7 @@ struct kcas_get_cache_param {
/** Add core object to an running cache instance */
#define KCAS_IOCTL_INSERT_CORE _IOWR(KCAS_IOCTL_MAGIC, 22, struct kcas_insert_core)
/** Remove core object from an running cache instance */
/** Remove active core object from an running cache instance */
#define KCAS_IOCTL_REMOVE_CORE _IOR(KCAS_IOCTL_MAGIC, 23, struct kcas_remove_core)
/** Retrieve properties of a running cache instance (incl. mode etc.) */
@ -566,7 +566,7 @@ enum kcas_error {
/** Given device is a partition */
KCAS_ERR_A_PART,
/** Core has been removed with flush error */
/** Core has been removed, but it may contain dirty data */
KCAS_ERR_REMOVED_DIRTY,
/** Cache has been stopped, but it may contain dirty data */
@ -584,7 +584,7 @@ enum kcas_error {
/** Condition token does not identify any known condition */
KCAS_ERR_CLS_RULE_UNKNOWN_CONDITION,
/** Waiting for async operation was interrupted*/
/** Waiting for async operation was interrupted */
KCAS_ERR_WAITING_INTERRUPTED,
/** Cache already being stopped*/