Split retrieving core stats and config info into two functions.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
@@ -143,6 +143,13 @@ int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx,
|
||||
|
||||
/* *** HELPER FUNCTIONS *** */
|
||||
|
||||
static uint32_t _calc_dirty_for(uint64_t dirty_since)
|
||||
{
|
||||
return dirty_since ?
|
||||
(env_ticks_to_msecs(env_get_tick_count() - dirty_since) / 1000)
|
||||
: 0;
|
||||
}
|
||||
|
||||
static inline struct ocf_request *ocf_io_to_req(struct ocf_io *io)
|
||||
{
|
||||
struct ocf_io_internal *ioi;
|
||||
@@ -585,3 +592,31 @@ int ocf_core_volume_type_init(ocf_ctx_t ctx)
|
||||
&ocf_core_volume_properties,
|
||||
&ocf_core_volume_extended);
|
||||
}
|
||||
|
||||
int ocf_core_get_info(ocf_core_t core, struct ocf_core_info *info)
|
||||
{
|
||||
ocf_cache_t cache;
|
||||
|
||||
OCF_CHECK_NULL(core);
|
||||
|
||||
cache = ocf_core_get_cache(core);
|
||||
|
||||
if (!info)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
ENV_BUG_ON(env_memset(info, sizeof(*info), 0));
|
||||
|
||||
info->core_size_bytes = ocf_volume_get_length(&core->volume);
|
||||
info->core_size = ocf_bytes_2_lines_round_up(cache,
|
||||
info->core_size_bytes);
|
||||
info->seq_cutoff_threshold = ocf_core_get_seq_cutoff_threshold(core);
|
||||
info->seq_cutoff_policy = ocf_core_get_seq_cutoff_policy(core);
|
||||
|
||||
info->flushed = env_atomic_read(&core->flushed);
|
||||
info->dirty = env_atomic_read(&core->runtime_meta->dirty_clines);
|
||||
|
||||
info->dirty_for = _calc_dirty_for(
|
||||
env_atomic64_read(&core->runtime_meta->dirty_since));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -204,26 +204,14 @@ int ocf_core_io_class_get_stats(ocf_core_t core, ocf_part_id_t part_id,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t _calc_dirty_for(uint64_t dirty_since)
|
||||
{
|
||||
return dirty_since ?
|
||||
(env_ticks_to_msecs(env_get_tick_count() - dirty_since) / 1000)
|
||||
: 0;
|
||||
}
|
||||
|
||||
int ocf_core_get_stats(ocf_core_t core, struct ocf_stats_core *stats)
|
||||
{
|
||||
uint32_t i;
|
||||
ocf_core_id_t core_id;
|
||||
ocf_cache_t cache;
|
||||
struct ocf_counters_core *core_stats = NULL;
|
||||
struct ocf_counters_part *curr = NULL;
|
||||
|
||||
OCF_CHECK_NULL(core);
|
||||
|
||||
core_id = ocf_core_get_id(core);
|
||||
cache = ocf_core_get_cache(core);
|
||||
|
||||
if (!stats)
|
||||
return -OCF_ERR_INVAL;
|
||||
|
||||
@@ -231,16 +219,6 @@ int ocf_core_get_stats(ocf_core_t core, struct ocf_stats_core *stats)
|
||||
|
||||
ENV_BUG_ON(env_memset(stats, sizeof(*stats), 0));
|
||||
|
||||
stats->core_size_bytes = ocf_volume_get_length(
|
||||
&cache->core[core_id].volume);
|
||||
stats->core_size = ocf_bytes_2_lines_round_up(cache,
|
||||
stats->core_size_bytes);
|
||||
stats->seq_cutoff_threshold = ocf_core_get_seq_cutoff_threshold(core);
|
||||
stats->seq_cutoff_policy = ocf_core_get_seq_cutoff_policy(core);
|
||||
|
||||
|
||||
env_atomic_read(&core->runtime_meta->cached_clines);
|
||||
|
||||
copy_error_stats(&stats->core_errors,
|
||||
&core_stats->core_errors);
|
||||
copy_error_stats(&stats->cache_errors,
|
||||
@@ -269,11 +247,6 @@ int ocf_core_get_stats(ocf_core_t core, struct ocf_stats_core *stats)
|
||||
part_counters[i].dirty_clines);
|
||||
}
|
||||
|
||||
stats->flushed = env_atomic_read(&core->flushed);
|
||||
|
||||
stats->dirty_for = _calc_dirty_for(
|
||||
env_atomic64_read(&core->runtime_meta->dirty_since));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user