From 4c991a9dec5693a8ea94efa673884387c76519fd Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Thu, 3 Mar 2022 09:41:45 +0100 Subject: [PATCH] casadm: improve cache conf stats in standby mode When cache is in standby mode config section of cache stats should contain only relevant information. Signed-off-by: Michal Mielewczyk --- casadm/statistics_model.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/casadm/statistics_model.c b/casadm/statistics_model.c index a3ed35f..6d42b75 100644 --- a/casadm/statistics_model.c +++ b/casadm/statistics_model.c @@ -537,6 +537,9 @@ int cache_stats_conf(int ctrl_fd, const struct kcas_cache_info *cache_info, const char *cache_path; char dev_path[MAX_STR_LEN]; int inactive_cores; + bool standby = (cache_info->info.state & (1 << ocf_cache_state_standby)); + bool standby_detached = cache_info->info.standby_detached; + bool cache_exported_obj_exists = (standby && !standby_detached); if (strnlen(cache_info->cache_path_name, sizeof(cache_info->cache_path_name)) == 0) { cache_path = "-"; @@ -561,6 +564,12 @@ int cache_stats_conf(int ctrl_fd, const struct kcas_cache_info *cache_info, print_kv_pair(outfile, "Cache Device", "%s", cache_path); + if (cache_exported_obj_exists) { + print_kv_pair(outfile, "Exported Object", "/dev/cas-cache-%d", + cache_info->cache_id); + } else { + print_kv_pair(outfile, "Exported Object", "-"); + } print_kv_pair(outfile, "Core Devices", "%d", cache_info->info.core_count); inactive_cores = get_inactive_core_count(cache_info); @@ -568,11 +577,11 @@ int cache_stats_conf(int ctrl_fd, const struct kcas_cache_info *cache_info, return FAILURE; print_kv_pair(outfile, "Inactive Core Devices", "%d", inactive_cores); - print_kv_pair(outfile, "Write Policy", "%s", + print_kv_pair(outfile, "Write Policy", "%s", standby ? "-" : cache_mode_to_name(cache_info->info.cache_mode)); - print_kv_pair(outfile, "Cleaning Policy", "%s", + print_kv_pair(outfile, "Cleaning Policy", "%s", standby ? "-" : cleaning_policy_to_name(cache_info->info.cleaning_policy)); - print_kv_pair(outfile, "Promotion Policy", "%s", + print_kv_pair(outfile, "Promotion Policy", "%s", standby ? "-" : promotion_policy_to_name(cache_info->info.promotion_policy)); print_kv_pair(outfile, "Cache line size", "%llu, [KiB]", cache_info->info.cache_line_size / KiB);