From aa3c33050d6dd8efc4c65ff4daba9cfd1ca17332 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Tue, 29 Mar 2022 18:38:59 +0200 Subject: [PATCH 1/2] Do not send KCAS_IOCTL_GET_STATS in standby Updated OCF returns erorr from stats API instead of zeros when cache is in standby. Signed-off-by: Adam Rutkowski --- casadm/statistics_model.c | 14 +++++++++++--- ocf | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/casadm/statistics_model.c b/casadm/statistics_model.c index 4adee70..886148a 100644 --- a/casadm/statistics_model.c +++ b/casadm/statistics_model.c @@ -632,12 +632,20 @@ static int cache_stats(int ctrl_fd, const struct kcas_cache_info *cache_info, bool by_id_path) { struct kcas_get_stats cache_stats = {}; + bool standby; + cache_stats.cache_id = cache_id; cache_stats.core_id = OCF_CORE_ID_INVALID; cache_stats.part_id = OCF_IO_CLASS_INVALID; - if (ioctl(ctrl_fd, KCAS_IOCTL_GET_STATS, &cache_stats) < 0) - return FAILURE; + standby = !!(cache_info->info.state & (1 << ocf_cache_state_standby)); + + if (!standby) { + if (ioctl(ctrl_fd, KCAS_IOCTL_GET_STATS, &cache_stats)) { + print_err(cache_stats.ext_err_code); + return FAILURE; + } + } begin_record(outfile); @@ -645,7 +653,7 @@ static int cache_stats(int ctrl_fd, const struct kcas_cache_info *cache_info, cache_stats_conf(ctrl_fd, cache_info, cache_id, outfile, by_id_path); /* Don't print stats for a cache in standby state */ - if (cache_info->info.state & (1 << ocf_cache_state_standby)) + if (standby) return SUCCESS; if (stats_filters & STATS_FILTER_USAGE) diff --git a/ocf b/ocf index a64fc61..ca8531a 160000 --- a/ocf +++ b/ocf @@ -1 +1 @@ -Subproject commit a64fc614136916b02c4e77f2a9fb125b84382651 +Subproject commit ca8531a421b4a90cddb641dc377b4607b06a0775 From 02dbc56ebaaed4f606b67b82a3cd0e98a3e1dbb6 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Tue, 29 Mar 2022 22:18:25 +0200 Subject: [PATCH 2/2] More specific error msg for core statistics in standby Signed-off-by: Adam Rutkowski --- casadm/statistics_model.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/casadm/statistics_model.c b/casadm/statistics_model.c index 886148a..5c84ddc 100644 --- a/casadm/statistics_model.c +++ b/casadm/statistics_model.c @@ -778,6 +778,17 @@ int cache_status(unsigned int cache_id, unsigned int core_id, int io_class_id, goto cleanup; } + if ((cache_info.info.state & (1 << ocf_cache_state_standby)) && + core_id != OCF_CORE_ID_INVALID) { + /* Explicitly fail due to standby mode rather than + * bouncing off the fact that there are 0 cores in the + * cache and saying "no such core device" + */ + print_err(OCF_ERR_CACHE_STANDBY); + ret = FAILURE; + goto cleanup; + } + /* Check if core exists in cache */ if (core_id != OCF_CORE_ID_INVALID) { for (i = 0; i < cache_info.info.core_count; ++i) {