Allow reset stats for all cores within cache instance at once.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2019-04-09 05:39:29 -04:00
parent 3ee1d84120
commit 54027e92ae
3 changed files with 13 additions and 9 deletions

View File

@ -742,12 +742,12 @@ rd_unlock:
return result; return result;
} }
int cache_mng_reset_core_stats(ocf_cache_id_t cache_id, int cache_mng_reset_stats(ocf_cache_id_t cache_id,
ocf_core_id_t core_id) ocf_core_id_t core_id)
{ {
ocf_cache_t cache; ocf_cache_t cache;
ocf_core_t core; ocf_core_t core;
int result; int result = 0;
result = ocf_mngt_cache_get_by_id(cas_ctx, cache_id, &cache); result = ocf_mngt_cache_get_by_id(cas_ctx, cache_id, &cache);
if (result) if (result)
@ -759,16 +759,20 @@ int cache_mng_reset_core_stats(ocf_cache_id_t cache_id,
return result; return result;
} }
result = ocf_core_get(cache, core_id, &core); if (core_id != OCF_CORE_ID_INVALID) {
if (result) result = ocf_core_get(cache, core_id, &core);
goto out; if (result)
goto out;
ocf_core_stats_initialize(core); ocf_core_stats_initialize(core);
} else {
ocf_core_stats_initialize_all(cache);
}
out: out:
ocf_mngt_cache_unlock(cache); ocf_mngt_cache_unlock(cache);
ocf_mngt_cache_put(cache); ocf_mngt_cache_put(cache);
return 0; return result;
} }
static inline void io_class_info2cfg(ocf_part_id_t part_id, static inline void io_class_info2cfg(ocf_part_id_t part_id,

View File

@ -25,7 +25,7 @@ int cache_mng_add_core_to_cache(struct ocf_mngt_core_config *cfg,
int cache_mng_remove_core_from_cache(struct kcas_remove_core *cmd); int cache_mng_remove_core_from_cache(struct kcas_remove_core *cmd);
int cache_mng_reset_core_stats(ocf_cache_id_t cache_id, int cache_mng_reset_stats(ocf_cache_id_t cache_id,
ocf_core_id_t core_id); ocf_core_id_t core_id);
int cache_mng_set_partitions(struct kcas_io_classes *cfg); int cache_mng_set_partitions(struct kcas_io_classes *cfg);

View File

@ -197,7 +197,7 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
GET_CMD_INFO(cmd_info, arg); GET_CMD_INFO(cmd_info, arg);
retval = cache_mng_reset_core_stats(cmd_info->cache_id, retval = cache_mng_reset_stats(cmd_info->cache_id,
cmd_info->core_id); cmd_info->core_id);
RETURN_CMD_RESULT(cmd_info, arg, retval); RETURN_CMD_RESULT(cmd_info, arg, retval);