From aa3c33050d6dd8efc4c65ff4daba9cfd1ca17332 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Tue, 29 Mar 2022 18:38:59 +0200 Subject: [PATCH] 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