Split retrieving core stats and config info into two functions.
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
f9da89263b
commit
89de6038c1
@ -16,6 +16,32 @@
|
||||
#include "ocf_io.h"
|
||||
#include "ocf_mngt.h"
|
||||
|
||||
struct ocf_core_info {
|
||||
/** Core size in cache line size unit */
|
||||
uint64_t core_size;
|
||||
|
||||
/** Core size in bytes unit */
|
||||
uint64_t core_size_bytes;
|
||||
|
||||
/** Fields refers ongoing flush operation */
|
||||
struct {
|
||||
/** Number of blocks flushed in ongoing flush operation */
|
||||
uint32_t flushed;
|
||||
|
||||
/** Number of blocks left to flush in ongoing flush operation */
|
||||
uint32_t dirty;
|
||||
};
|
||||
|
||||
/** How long core is dirty in seconds unit */
|
||||
uint32_t dirty_for;
|
||||
|
||||
/** Sequential cutoff threshold (in bytes) */
|
||||
uint32_t seq_cutoff_threshold;
|
||||
|
||||
/** Sequential cutoff policy */
|
||||
ocf_seq_cutoff_policy seq_cutoff_policy;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Get OCF core by name
|
||||
*
|
||||
@ -202,4 +228,15 @@ typedef int (*ocf_core_visitor_t)(ocf_core_t core, void *cntx);
|
||||
int ocf_core_visit(ocf_cache_t cache, ocf_core_visitor_t visitor, void *cntx,
|
||||
bool only_opened);
|
||||
|
||||
/**
|
||||
* @brief Get info of given core object
|
||||
*
|
||||
* @param[in] core Core object
|
||||
* @param[out] info Core info structure
|
||||
*
|
||||
* @retval 0 Success
|
||||
* @retval Non-zero Fail
|
||||
*/
|
||||
int ocf_core_get_info(ocf_core_t core, struct ocf_core_info *info);
|
||||
|
||||
#endif /* __OCF_CORE_H__ */
|
||||
|
@ -111,24 +111,12 @@ struct ocf_stats_core_debug {
|
||||
* @brief OCF core statistics
|
||||
*/
|
||||
struct ocf_stats_core {
|
||||
/** Core size in cache line size unit */
|
||||
uint64_t core_size;
|
||||
|
||||
/** Core size in bytes unit */
|
||||
uint64_t core_size_bytes;
|
||||
|
||||
/** Number of cache lines allocated in the cache for this core */
|
||||
uint32_t cache_occupancy;
|
||||
|
||||
/** Number of dirty cache lines allocated in the cache for this core */
|
||||
uint32_t dirty;
|
||||
|
||||
/** Number of block flushed in ongoing flush operation */
|
||||
uint32_t flushed;
|
||||
|
||||
/** How long core is dirty in seconds unit */
|
||||
uint32_t dirty_for;
|
||||
|
||||
/** Read requests statistics */
|
||||
struct ocf_stats_req read_reqs;
|
||||
|
||||
@ -152,12 +140,6 @@ struct ocf_stats_core {
|
||||
|
||||
/** Debug statistics */
|
||||
struct ocf_stats_core_debug debug_stat;
|
||||
|
||||
/** Sequential cutoff threshold (in bytes) */
|
||||
uint32_t seq_cutoff_threshold;
|
||||
|
||||
/** Sequential cutoff policy */
|
||||
ocf_seq_cutoff_policy seq_cutoff_policy;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user