Return error from stats API functions in standby

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski 2022-03-29 18:38:38 +02:00
parent a64fc61413
commit 9a1f9d41b8
2 changed files with 24 additions and 3 deletions

View File

@ -291,6 +291,9 @@ int ocf_core_io_class_get_stats(ocf_core_t core, ocf_part_id_t part_id,
cache = ocf_core_get_cache(core); cache = ocf_core_get_cache(core);
if (ocf_cache_is_standby(cache))
return -OCF_ERR_CACHE_STANDBY;
if (!ocf_user_part_is_valid(&cache->user_parts[part_id])) if (!ocf_user_part_is_valid(&cache->user_parts[part_id]))
return -OCF_ERR_IO_CLASS_NOT_EXIST; return -OCF_ERR_IO_CLASS_NOT_EXIST;
@ -318,12 +321,17 @@ int ocf_core_get_stats(ocf_core_t core, struct ocf_stats_core *stats)
uint32_t i; uint32_t i;
struct ocf_counters_core *core_stats = NULL; struct ocf_counters_core *core_stats = NULL;
struct ocf_counters_part *curr = NULL; struct ocf_counters_part *curr = NULL;
ocf_cache_t cache;
OCF_CHECK_NULL(core); OCF_CHECK_NULL(core);
if (!stats) if (!stats)
return -OCF_ERR_INVAL; return -OCF_ERR_INVAL;
cache = ocf_core_get_cache(core);
if (ocf_cache_is_standby(cache))
return -OCF_ERR_CACHE_STANDBY;
core_stats = core->counters; core_stats = core->counters;
ENV_BUG_ON(env_memset(stats, sizeof(*stats), 0)); ENV_BUG_ON(env_memset(stats, sizeof(*stats), 0));

View File

@ -260,11 +260,14 @@ int ocf_stats_collect_part_core(ocf_core_t core, ocf_part_id_t part_id,
OCF_CHECK_NULL(core); OCF_CHECK_NULL(core);
cache = ocf_core_get_cache(core);
if (ocf_cache_is_standby(cache))
return -OCF_ERR_CACHE_STANDBY;
if (part_id > OCF_IO_CLASS_ID_MAX) if (part_id > OCF_IO_CLASS_ID_MAX)
return -OCF_ERR_INVAL; return -OCF_ERR_INVAL;
cache = ocf_core_get_cache(core);
_ocf_stats_zero(usage); _ocf_stats_zero(usage);
_ocf_stats_zero(req); _ocf_stats_zero(req);
_ocf_stats_zero(blocks); _ocf_stats_zero(blocks);
@ -288,6 +291,9 @@ int ocf_stats_collect_part_cache(ocf_cache_t cache, ocf_part_id_t part_id,
OCF_CHECK_NULL(cache); OCF_CHECK_NULL(cache);
if (ocf_cache_is_standby(cache))
return -OCF_ERR_CACHE_STANDBY;
if (part_id > OCF_IO_CLASS_ID_MAX) if (part_id > OCF_IO_CLASS_ID_MAX)
return -OCF_ERR_INVAL; return -OCF_ERR_INVAL;
@ -320,11 +326,15 @@ int ocf_stats_collect_core(ocf_core_t core,
OCF_CHECK_NULL(core); OCF_CHECK_NULL(core);
cache = ocf_core_get_cache(core);
if (ocf_cache_is_standby(cache))
return -OCF_ERR_CACHE_STANDBY;
result = ocf_core_get_stats(core, &s); result = ocf_core_get_stats(core, &s);
if (result) if (result)
return result; return result;
cache = ocf_core_get_cache(core);
cache_line_size = ocf_cache_get_line_size(cache); cache_line_size = ocf_cache_get_line_size(cache);
cache_size = cache->conf_meta->cachelines; cache_size = cache->conf_meta->cachelines;
cache_occupancy = ocf_get_cache_occupancy(cache); cache_occupancy = ocf_get_cache_occupancy(cache);
@ -399,6 +409,9 @@ int ocf_stats_collect_cache(ocf_cache_t cache,
OCF_CHECK_NULL(cache); OCF_CHECK_NULL(cache);
if (ocf_cache_is_standby(cache))
return -OCF_ERR_CACHE_STANDBY;
result = ocf_cache_get_info(cache, &info); result = ocf_cache_get_info(cache, &info);
if (result) if (result)
return result; return result;