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 <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2022-03-29 18:38:59 +02:00
parent 91866a4efe
commit aa3c33050d
2 changed files with 12 additions and 4 deletions

View File

@ -632,12 +632,20 @@ static int cache_stats(int ctrl_fd, const struct kcas_cache_info *cache_info,
bool by_id_path) bool by_id_path)
{ {
struct kcas_get_stats cache_stats = {}; struct kcas_get_stats cache_stats = {};
bool standby;
cache_stats.cache_id = cache_id; cache_stats.cache_id = cache_id;
cache_stats.core_id = OCF_CORE_ID_INVALID; cache_stats.core_id = OCF_CORE_ID_INVALID;
cache_stats.part_id = OCF_IO_CLASS_INVALID; cache_stats.part_id = OCF_IO_CLASS_INVALID;
if (ioctl(ctrl_fd, KCAS_IOCTL_GET_STATS, &cache_stats) < 0) standby = !!(cache_info->info.state & (1 << ocf_cache_state_standby));
return FAILURE;
if (!standby) {
if (ioctl(ctrl_fd, KCAS_IOCTL_GET_STATS, &cache_stats)) {
print_err(cache_stats.ext_err_code);
return FAILURE;
}
}
begin_record(outfile); 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); cache_stats_conf(ctrl_fd, cache_info, cache_id, outfile, by_id_path);
/* Don't print stats for a cache in standby state */ /* Don't print stats for a cache in standby state */
if (cache_info->info.state & (1 << ocf_cache_state_standby)) if (standby)
return SUCCESS; return SUCCESS;
if (stats_filters & STATS_FILTER_USAGE) if (stats_filters & STATS_FILTER_USAGE)

2
ocf

@ -1 +1 @@
Subproject commit a64fc614136916b02c4e77f2a9fb125b84382651 Subproject commit ca8531a421b4a90cddb641dc377b4607b06a0775