Merge pull request #1043 from Open-CAS/casadm_detached_fix
Fix for casadm output when listing detached cache
This commit is contained in:
commit
6f26d2eade
@ -79,6 +79,8 @@ static const char *core_states_name[] = {
|
|||||||
|
|
||||||
#define NOT_RUNNING_STATE "Not running"
|
#define NOT_RUNNING_STATE "Not running"
|
||||||
|
|
||||||
|
#define STANDBY_DETACHED_STATE "Standby detached"
|
||||||
|
|
||||||
#define CACHE_STATE_LENGHT 20
|
#define CACHE_STATE_LENGHT 20
|
||||||
|
|
||||||
#define CAS_LOG_FILE "/var/log/opencas.log"
|
#define CAS_LOG_FILE "/var/log/opencas.log"
|
||||||
@ -487,9 +489,13 @@ void print_err(int error_code)
|
|||||||
cas_printf(LOG_ERR, "%s\n", msg);
|
cas_printf(LOG_ERR, "%s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *get_cache_state_name(int cache_state)
|
const char *get_cache_state_name(int cache_state, bool detached)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (detached == true)
|
||||||
|
return STANDBY_DETACHED_STATE;
|
||||||
|
|
||||||
/* iterate over states in reverse order, so that combined states "running&stopping"
|
/* iterate over states in reverse order, so that combined states "running&stopping"
|
||||||
* would be described as "stopping" */
|
* would be described as "stopping" */
|
||||||
for (i = ocf_cache_state_max - 1; i >= 0; --i) {
|
for (i = ocf_cache_state_max - 1; i >= 0; --i) {
|
||||||
@ -774,9 +780,6 @@ struct cache_device *get_cache_device(const struct kcas_cache_info *info, bool b
|
|||||||
cache_size = sizeof(*cache);
|
cache_size = sizeof(*cache);
|
||||||
cache_size += info->info.core_count * sizeof(cache->cores[0]);
|
cache_size += info->info.core_count * sizeof(cache->cores[0]);
|
||||||
|
|
||||||
if (info->info.standby_detached)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
cache = (struct cache_device *) malloc(cache_size);
|
cache = (struct cache_device *) malloc(cache_size);
|
||||||
if (NULL == cache) {
|
if (NULL == cache) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -786,6 +789,7 @@ struct cache_device *get_cache_device(const struct kcas_cache_info *info, bool b
|
|||||||
cache->expected_core_count = info->info.core_count;
|
cache->expected_core_count = info->info.core_count;
|
||||||
cache->id = cache_id;
|
cache->id = cache_id;
|
||||||
cache->state = info->info.state;
|
cache->state = info->info.state;
|
||||||
|
cache->standby_detached = info->info.standby_detached;
|
||||||
|
|
||||||
if (strncpy_s(cache->device, sizeof(cache->device),
|
if (strncpy_s(cache->device, sizeof(cache->device),
|
||||||
info->cache_path_name,
|
info->cache_path_name,
|
||||||
@ -2751,7 +2755,7 @@ int list_caches(unsigned int list_format, bool by_id_path)
|
|||||||
float cache_flush_prog;
|
float cache_flush_prog;
|
||||||
float core_flush_prog;
|
float core_flush_prog;
|
||||||
|
|
||||||
if (!by_id_path) {
|
if (!by_id_path && !curr_cache->standby_detached) {
|
||||||
if (get_dev_path(curr_cache->device, curr_cache->device,
|
if (get_dev_path(curr_cache->device, curr_cache->device,
|
||||||
sizeof(curr_cache->device))) {
|
sizeof(curr_cache->device))) {
|
||||||
cas_printf(LOG_WARNING, "WARNING: Cannot resolve path "
|
cas_printf(LOG_WARNING, "WARNING: Cannot resolve path "
|
||||||
@ -2767,7 +2771,8 @@ int list_caches(unsigned int list_format, bool by_id_path)
|
|||||||
snprintf(mode_string, sizeof(mode_string), "wb->%s",
|
snprintf(mode_string, sizeof(mode_string), "wb->%s",
|
||||||
cache_mode_to_name(curr_cache->mode));
|
cache_mode_to_name(curr_cache->mode));
|
||||||
} else {
|
} else {
|
||||||
tmp_status = get_cache_state_name(curr_cache->state);
|
tmp_status = get_cache_state_name(curr_cache->state, curr_cache->standby_detached);
|
||||||
|
|
||||||
if (curr_cache->state & (1 << ocf_cache_state_standby)) {
|
if (curr_cache->state & (1 << ocf_cache_state_standby)) {
|
||||||
strncpy(mode_string, "-", sizeof(mode_string));
|
strncpy(mode_string, "-", sizeof(mode_string));
|
||||||
snprintf(cache_ctrl_dev, sizeof(cache_ctrl_dev),
|
snprintf(cache_ctrl_dev, sizeof(cache_ctrl_dev),
|
||||||
@ -2783,7 +2788,7 @@ int list_caches(unsigned int list_format, bool by_id_path)
|
|||||||
"%s,%u,%s,%s,%s,%s\n",
|
"%s,%u,%s,%s,%s,%s\n",
|
||||||
"cache", /* type */
|
"cache", /* type */
|
||||||
curr_cache->id, /* id */
|
curr_cache->id, /* id */
|
||||||
curr_cache->device, /* device path */
|
curr_cache->standby_detached ? "-" : curr_cache->device, /* device path */
|
||||||
tmp_status, /* cache status */
|
tmp_status, /* cache status */
|
||||||
mode_string, /* write policy */
|
mode_string, /* write policy */
|
||||||
cache_ctrl_dev /* device */);
|
cache_ctrl_dev /* device */);
|
||||||
|
@ -49,6 +49,7 @@ struct cache_device {
|
|||||||
int flushed;
|
int flushed;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
int core_count;
|
int core_count;
|
||||||
|
bool standby_detached;
|
||||||
struct core_device cores[];
|
struct core_device cores[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ enum output_format_t {
|
|||||||
const char *cleaning_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 *promotion_policy_to_name(uint8_t policy);
|
||||||
const char *cache_mode_to_name(uint8_t cache_mode);
|
const char *cache_mode_to_name(uint8_t cache_mode);
|
||||||
const char *get_cache_state_name(int cache_state);
|
const char *get_cache_state_name(int cache_state, bool detached);
|
||||||
const char *get_core_state_name(int core_state);
|
const char *get_core_state_name(int core_state);
|
||||||
const char *seq_cutoff_policy_to_name(uint8_t seq_cutoff_policy);
|
const char *seq_cutoff_policy_to_name(uint8_t seq_cutoff_policy);
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ int cache_stats_conf(int ctrl_fd, const struct kcas_cache_info *cache_info,
|
|||||||
"Flushing", flush_progress);
|
"Flushing", flush_progress);
|
||||||
} else {
|
} else {
|
||||||
print_kv_pair(outfile, "Status", "%s",
|
print_kv_pair(outfile, "Status", "%s",
|
||||||
get_cache_state_name(cache_info->info.state));
|
get_cache_state_name(cache_info->info.state, cache_info->info.standby_detached));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user