From 42d6dbbf114484166dd3b6f2369eb92f56f624ce Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Tue, 3 Sep 2019 04:15:36 -0400 Subject: [PATCH] Remove low-level stats getters from public API. Since stats builder is implemented for retrieving cache, core and ioclass stats, adapters should use it instead. Signed-off-by: Michal Mielewczyk --- inc/ocf.h | 1 - inc/ocf_stats.h | 326 ++++++++++++++++++++++------------------ inc/ocf_stats_builder.h | 222 --------------------------- src/ocf_stats_priv.h | 167 ++++++++++++++++++++ 4 files changed, 348 insertions(+), 368 deletions(-) delete mode 100644 inc/ocf_stats_builder.h diff --git a/inc/ocf.h b/inc/ocf.h index 07c98b0..7b01411 100644 --- a/inc/ocf.h +++ b/inc/ocf.h @@ -29,7 +29,6 @@ #include "ocf_metadata_updater.h" #include "ocf_io_class.h" #include "ocf_stats.h" -#include "ocf_stats_builder.h" #include "ocf_mngt.h" #include "ocf_ctx.h" #include "ocf_err.h" diff --git a/inc/ocf_stats.h b/inc/ocf_stats.h index 4906023..141483b 100644 --- a/inc/ocf_stats.h +++ b/inc/ocf_stats.h @@ -14,133 +14,210 @@ #ifndef __OCF_STATS_H__ #define __OCF_STATS_H__ -struct ocf_io; +/** + * Entire row of statistcs + */ +struct ocf_stat { + /** Value */ + uint64_t value; + /** percent x100 */ + uint64_t fraction; +}; /** - * @brief OCF requests statistics like hit, miss, etc... + * @brief Usage statistics in 4 KiB unit * - * @note To calculate number of hits request do: - * total - (partial_miss + full_miss) + * An example of presenting statistics: + *
+ * ╔══════════════════╤══════════╤═══════╤═════════════╗
+ * ║ Usage statistics │  Count   │   %   │   Units     ║
+ * ╠══════════════════╪══════════╪═══════╪═════════════╣
+ * ║ Occupancy        │       20 │  50.0 │ 4KiB blocks ║
+ * ║ Free             │       20 │  50.0 │ 4KiB blocks ║
+ * ║ Clean            │       15 │  75.0 │ 4KiB blocks ║
+ * ║ Dirty            │        5 │  25.0 │ 4KiB blocks ║
+ * ╚══════════════════╧══════════╧═══════╧═════════════╝
+ * 
*/ -struct ocf_stats_req { - /** Number of partial misses */ - uint64_t partial_miss; - - /** Number of full misses */ - uint64_t full_miss; - - /** Total of requests */ - uint64_t total; - - /** Pass-through requests */ - uint64_t pass_through; +struct ocf_stats_usage { + struct ocf_stat occupancy; + struct ocf_stat free; + struct ocf_stat clean; + struct ocf_stat dirty; }; /** - * @brief OCF error statistics + * @brief Requests statistcs + * + * An example of presenting statistics: + *
+ * ╔══════════════════════╤═══════╤═══════╤══════════╗
+ * ║ Request statistics   │ Count │   %   │ Units    ║
+ * ╠══════════════════════╪═══════╪═══════╪══════════╣
+ * ║ Read hits            │    10 │   4.5 │ Requests ║
+ * ║ Read partial misses  │     1 │   0.5 │ Requests ║
+ * ║ Read full misses     │   211 │  95.0 │ Requests ║
+ * ║ Read total           │   222 │ 100.0 │ Requests ║
+ * ╟──────────────────────┼───────┼───────┼──────────╢
+ * ║ Write hits           │     0 │   0.0 │ Requests ║
+ * ║ Write partial misses │     0 │   0.0 │ Requests ║
+ * ║ Write full misses    │     0 │   0.0 │ Requests ║
+ * ║ Write total          │     0 │   0.0 │ Requests ║
+ * ╟──────────────────────┼───────┼───────┼──────────╢
+ * ║ Pass-Through reads   │     0 │   0.0 │ Requests ║
+ * ║ Pass-Through writes  │     0 │   0.0 │ Requests ║
+ * ║ Serviced requests    │   222 │ 100.0 │ Requests ║
+ * ╟──────────────────────┼───────┼───────┼──────────╢
+ * ║ Total requests       │   222 │ 100.0 │ Requests ║
+ * ╚══════════════════════╧═══════╧═══════╧══════════╝
+ * 
*/ -struct ocf_stats_error { - /** Read errors */ - uint32_t read; - - /** Write errors */ - uint32_t write; +struct ocf_stats_requests { + struct ocf_stat rd_hits; + struct ocf_stat rd_partial_misses; + struct ocf_stat rd_full_misses; + struct ocf_stat rd_total; + struct ocf_stat wr_hits; + struct ocf_stat wr_partial_misses; + struct ocf_stat wr_full_misses; + struct ocf_stat wr_total; + struct ocf_stat rd_pt; + struct ocf_stat wr_pt; + struct ocf_stat serviced; + struct ocf_stat total; }; /** - * @brief OCF block statistics in bytes + * @brief Block statistics + * + * An example of presenting statistics: + *
+ * ╔════════════════════════════════════╤═══════╤═══════╤═════════════╗
+ * ║ Block statistics                   │ Count │   %   │   Units     ║
+ * ╠════════════════════════════════════╪═══════╪═══════╪═════════════╣
+ * ║ Reads from core volume(s)          │   426 │ 100.0 │ 4KiB blocks ║
+ * ║ Writes to core volume(s)           │     0 │   0.0 │ 4KiB blocks ║
+ * ║ Total to/from core volume (s)      │   426 │ 100.0 │ 4KiB blocks ║
+ * ╟────────────────────────────────────┼───────┼───────┼─────────────╢
+ * ║ Reads from cache volume            │    13 │   3.0 │ 4KiB blocks ║
+ * ║ Writes to cache volume             │   426 │  97.0 │ 4KiB blocks ║
+ * ║ Total to/from cache volume         │   439 │ 100.0 │ 4KiB blocks ║
+ * ╟────────────────────────────────────┼───────┼───────┼─────────────╢
+ * ║ Reads from core(s)                 │   439 │ 100.0 │ 4KiB blocks ║
+ * ║ Writes to core(s)                  │     0 │   0.0 │ 4KiB blocks ║
+ * ║ Total to/from core(s)              │   439 │ 100.0 │ 4KiB blocks ║
+ * ╚════════════════════════════════════╧═══════╧═══════╧═════════════╝
+ * 
*/ -struct ocf_stats_block { - /** Number of blocks read */ - uint64_t read; - - /** Number of blocks written */ - uint64_t write; +struct ocf_stats_blocks { + struct ocf_stat core_volume_rd; + struct ocf_stat core_volume_wr; + struct ocf_stat core_volume_total; + struct ocf_stat cache_volume_rd; + struct ocf_stat cache_volume_wr; + struct ocf_stat cache_volume_total; + struct ocf_stat volume_rd; + struct ocf_stat volume_wr; + struct ocf_stat volume_total; }; /** - * Statistics appropriate for given IO class + * @brief Errors statistics + * + * An example of presenting statistics: + *
+ * ╔════════════════════╤═══════╤═════╤══════════╗
+ * ║ Error statistics   │ Count │  %  │ Units    ║
+ * ╠════════════════════╪═══════╪═════╪══════════╣
+ * ║ Cache read errors  │     0 │ 0.0 │ Requests ║
+ * ║ Cache write errors │     0 │ 0.0 │ Requests ║
+ * ║ Cache total errors │     0 │ 0.0 │ Requests ║
+ * ╟────────────────────┼───────┼─────┼──────────╢
+ * ║ Core read errors   │     0 │ 0.0 │ Requests ║
+ * ║ Core write errors  │     0 │ 0.0 │ Requests ║
+ * ║ Core total errors  │     0 │ 0.0 │ Requests ║
+ * ╟────────────────────┼───────┼─────┼──────────╢
+ * ║ Total errors       │     0 │ 0.0 │ Requests ║
+ * ╚════════════════════╧═══════╧═════╧══════════╝
+ * 
*/ -struct ocf_stats_io_class { - /** Number of cache lines available for given partition */ - uint64_t free_clines; - - /** Number of cache lines within lru list */ - uint64_t occupancy_clines; - - /** Number of dirty cache lines assigned to specific partition */ - uint64_t dirty_clines; - - /** Read requests statistics */ - struct ocf_stats_req read_reqs; - - /** Writes requests statistics */ - struct ocf_stats_req write_reqs; - - /** Block requests submitted by user to this core */ - struct ocf_stats_block blocks; - - /** Block requests for cache volume statistics */ - struct ocf_stats_block cache_blocks; - - /** Block requests for core volume statistics */ - struct ocf_stats_block core_blocks; -}; - -#define IO_PACKET_NO 12 -#define IO_ALIGN_NO 4 - -/** - * @brief Core debug statistics - */ -struct ocf_stats_core_debug { - /** I/O sizes being read (grouped by packets) */ - uint64_t read_size[IO_PACKET_NO]; - - /** I/O sizes being written (grouped by packets) */ - uint64_t write_size[IO_PACKET_NO]; - - /** I/O alignment for reads */ - uint64_t read_align[IO_ALIGN_NO]; - - /** I/O alignment for writes */ - uint64_t write_align[IO_ALIGN_NO]; +struct ocf_stats_errors { + struct ocf_stat core_volume_rd; + struct ocf_stat core_volume_wr; + struct ocf_stat core_volume_total; + struct ocf_stat cache_volume_rd; + struct ocf_stat cache_volume_wr; + struct ocf_stat cache_volume_total; + struct ocf_stat total; }; /** - * @brief OCF core statistics + * @param Collect statistics for given cache + * + * @param cache Cache instance for which statistics will be collected + * @param usage Usage statistics + * @param req Request statistics + * @param blocks Blocks statistics + * @param errors Errors statistics + * + * @retval 0 Success + * @retval Non-zero Error */ -struct ocf_stats_core { - /** Number of cache lines allocated in the cache for this core */ - uint32_t cache_occupancy; +int ocf_stats_collect_cache(ocf_cache_t cache, + struct ocf_stats_usage *usage, + struct ocf_stats_requests *req, + struct ocf_stats_blocks *blocks, + struct ocf_stats_errors *errors); - /** Number of dirty cache lines allocated in the cache for this core */ - uint32_t dirty; +/** + * @param Collect statistics for given core + * + * @param core Core for which statistics will be collected + * @param usage Usage statistics + * @param req Request statistics + * @param blocks Blocks statistics + * @param errors Errors statistics + * + * @retval 0 Success + * @retval Non-zero Error + */ +int ocf_stats_collect_core(ocf_core_t core, + struct ocf_stats_usage *usage, + struct ocf_stats_requests *req, + struct ocf_stats_blocks *blocks, + struct ocf_stats_errors *errors); - /** Read requests statistics */ - struct ocf_stats_req read_reqs; +/** + * @param Collect statistics for given ioclass + * + * @param core Core handle for which statistics will be collected + * @param part_id Ioclass id for which statistics will be collected + * @param usage Usage statistics + * @param req Request statistics + * @param blocks Blocks statistics + * + * @retval 0 Success + * @retval Non-zero Error + */ +int ocf_stats_collect_part_core(ocf_core_t core, ocf_part_id_t part_id, + struct ocf_stats_usage *usage, struct ocf_stats_requests *req, + struct ocf_stats_blocks *blocks); - /** Write requests statistics */ - struct ocf_stats_req write_reqs; - - /** Block requests for cache volume statistics */ - struct ocf_stats_block cache_volume; - - /** Block requests for core volume statistics */ - struct ocf_stats_block core_volume; - - /** Block requests submitted by user to this core */ - struct ocf_stats_block core; - - /** Cache volume error statistics */ - struct ocf_stats_error cache_errors; - - /** Core volume error statistics */ - struct ocf_stats_error core_errors; - - /** Debug statistics */ - struct ocf_stats_core_debug debug_stat; -}; +/** + * @param Collect statistics for given ioclass + * + * @param cache Cache instance for which statistics will be collected + * @param part_id Ioclass id for which statistics will be collected + * @param usage Usage statistics + * @param req Request statistics + * @param blocks Blocks statistics + * + * @retval 0 Success + * @retval Non-zero Error + */ +int ocf_stats_collect_part_cache(ocf_cache_t cache, ocf_part_id_t part_id, + struct ocf_stats_usage *usage, struct ocf_stats_requests *req, + struct ocf_stats_blocks *blocks); /** * @brief Initialize or reset core statistics @@ -160,45 +237,4 @@ void ocf_core_stats_initialize(ocf_core_t core); */ void ocf_core_stats_initialize_all(ocf_cache_t cache); -/** - * @brief ocf_core_io_class_get_stats retrieve io class statistics - * for given core - * - * Retrieve buffer of cache statistics for given cache instance. - * - * @param[in] core core handle to which request pertains - * @param[in] part_id IO class, stats of which are requested - * @param[out] stats statistic structure that shall be filled as - * a result of this function invocation. - * - * @result zero upon successful completion; error code otherwise - */ -int ocf_core_io_class_get_stats(ocf_core_t core, ocf_part_id_t part_id, - struct ocf_stats_io_class *stats); - -/** - * @brief retrieve core stats - * - * Retrieve ocf per core stats (for all IO classes together) - * - * @param[in] core core ID to which request pertains - * @param[out] stats statistics structure that shall be filled as - * a result of this function invocation. - * - * @result zero upon successful completion; error code otherwise - */ -int ocf_core_get_stats(ocf_core_t core, struct ocf_stats_core *stats); - -/** - * @brief update stats given IO request - * - * Function meant to update stats for IO request. - * - * @note This function shall be invoked for eac IO request processed - * - * @param[in] core to which request pertains - * @param[in] io request for which stats are being updated - */ -void ocf_core_update_stats(ocf_core_t core, struct ocf_io *io); - #endif /* __OCF_STATS_H__ */ diff --git a/inc/ocf_stats_builder.h b/inc/ocf_stats_builder.h deleted file mode 100644 index 1ee736d..0000000 --- a/inc/ocf_stats_builder.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright(c) 2012-2018 Intel Corporation - * SPDX-License-Identifier: BSD-3-Clause-Clear - */ - -/** - * @file - * @brief OCF API for collecting statistics - * - * This file contains routines pertaining to retrieval and - * manipulation of OCF IO statistics. - */ - -#ifndef __OCF_STATS_BUILDER_H__ -#define __OCF_STATS_BUILDER_H__ - -/** - * Entire row of statistcs - */ -struct ocf_stat { - /** Value */ - uint64_t value; - /** percent x100 */ - uint64_t fraction; -}; - -/** - * @brief Usage statistics in 4 KiB unit - * - * An example of presenting statistics: - *
- * ╔══════════════════╤══════════╤═══════╤═════════════╗
- * ║ Usage statistics │  Count   │   %   │   Units     ║
- * ╠══════════════════╪══════════╪═══════╪═════════════╣
- * ║ Occupancy        │       20 │  50.0 │ 4KiB blocks ║
- * ║ Free             │       20 │  50.0 │ 4KiB blocks ║
- * ║ Clean            │       15 │  75.0 │ 4KiB blocks ║
- * ║ Dirty            │        5 │  25.0 │ 4KiB blocks ║
- * ╚══════════════════╧══════════╧═══════╧═════════════╝
- * 
- */ -struct ocf_stats_usage { - struct ocf_stat occupancy; - struct ocf_stat free; - struct ocf_stat clean; - struct ocf_stat dirty; -}; - -/** - * @brief Requests statistcs - * - * An example of presenting statistics: - *
- * ╔══════════════════════╤═══════╤═══════╤══════════╗
- * ║ Request statistics   │ Count │   %   │ Units    ║
- * ╠══════════════════════╪═══════╪═══════╪══════════╣
- * ║ Read hits            │    10 │   4.5 │ Requests ║
- * ║ Read partial misses  │     1 │   0.5 │ Requests ║
- * ║ Read full misses     │   211 │  95.0 │ Requests ║
- * ║ Read total           │   222 │ 100.0 │ Requests ║
- * ╟──────────────────────┼───────┼───────┼──────────╢
- * ║ Write hits           │     0 │   0.0 │ Requests ║
- * ║ Write partial misses │     0 │   0.0 │ Requests ║
- * ║ Write full misses    │     0 │   0.0 │ Requests ║
- * ║ Write total          │     0 │   0.0 │ Requests ║
- * ╟──────────────────────┼───────┼───────┼──────────╢
- * ║ Pass-Through reads   │     0 │   0.0 │ Requests ║
- * ║ Pass-Through writes  │     0 │   0.0 │ Requests ║
- * ║ Serviced requests    │   222 │ 100.0 │ Requests ║
- * ╟──────────────────────┼───────┼───────┼──────────╢
- * ║ Total requests       │   222 │ 100.0 │ Requests ║
- * ╚══════════════════════╧═══════╧═══════╧══════════╝
- * 
- */ -struct ocf_stats_requests { - struct ocf_stat rd_hits; - struct ocf_stat rd_partial_misses; - struct ocf_stat rd_full_misses; - struct ocf_stat rd_total; - struct ocf_stat wr_hits; - struct ocf_stat wr_partial_misses; - struct ocf_stat wr_full_misses; - struct ocf_stat wr_total; - struct ocf_stat rd_pt; - struct ocf_stat wr_pt; - struct ocf_stat serviced; - struct ocf_stat total; -}; - -/** - * @brief Block statistics - * - * An example of presenting statistics: - *
- * ╔════════════════════════════════════╤═══════╤═══════╤═════════════╗
- * ║ Block statistics                   │ Count │   %   │   Units     ║
- * ╠════════════════════════════════════╪═══════╪═══════╪═════════════╣
- * ║ Reads from core volume(s)     │   426 │ 100.0 │ 4KiB blocks ║
- * ║ Writes to core volume(s)      │     0 │   0.0 │ 4KiB blocks ║
- * ║ Total to/from core volume (s) │   426 │ 100.0 │ 4KiB blocks ║
- * ╟────────────────────────────────────┼───────┼───────┼─────────────╢
- * ║ Reads from cache volume       │    13 │   3.0 │ 4KiB blocks ║
- * ║ Writes to cache volume        │   426 │  97.0 │ 4KiB blocks ║
- * ║ Total to/from cache volume    │   439 │ 100.0 │ 4KiB blocks ║
- * ╟────────────────────────────────────┼───────┼───────┼─────────────╢
- * ║ Reads from core(s)                 │   439 │ 100.0 │ 4KiB blocks ║
- * ║ Writes to core(s)                  │     0 │   0.0 │ 4KiB blocks ║
- * ║ Total to/from core(s)              │   439 │ 100.0 │ 4KiB blocks ║
- * ╚════════════════════════════════════╧═══════╧═══════╧═════════════╝
- * 
- */ -struct ocf_stats_blocks { - struct ocf_stat core_volume_rd; - struct ocf_stat core_volume_wr; - struct ocf_stat core_volume_total; - struct ocf_stat cache_volume_rd; - struct ocf_stat cache_volume_wr; - struct ocf_stat cache_volume_total; - struct ocf_stat volume_rd; - struct ocf_stat volume_wr; - struct ocf_stat volume_total; -}; - -/** - * @brief Errors statistics - * - * An example of presenting statistics: - *
- * ╔════════════════════╤═══════╤═════╤══════════╗
- * ║ Error statistics   │ Count │  %  │ Units    ║
- * ╠════════════════════╪═══════╪═════╪══════════╣
- * ║ Cache read errors  │     0 │ 0.0 │ Requests ║
- * ║ Cache write errors │     0 │ 0.0 │ Requests ║
- * ║ Cache total errors │     0 │ 0.0 │ Requests ║
- * ╟────────────────────┼───────┼─────┼──────────╢
- * ║ Core read errors   │     0 │ 0.0 │ Requests ║
- * ║ Core write errors  │     0 │ 0.0 │ Requests ║
- * ║ Core total errors  │     0 │ 0.0 │ Requests ║
- * ╟────────────────────┼───────┼─────┼──────────╢
- * ║ Total errors       │     0 │ 0.0 │ Requests ║
- * ╚════════════════════╧═══════╧═════╧══════════╝
- * 
- */ -struct ocf_stats_errors { - struct ocf_stat core_volume_rd; - struct ocf_stat core_volume_wr; - struct ocf_stat core_volume_total; - struct ocf_stat cache_volume_rd; - struct ocf_stat cache_volume_wr; - struct ocf_stat cache_volume_total; - struct ocf_stat total; -}; - -/** - * @param Collect statistics for given cache - * - * @param cache Cache instance for each statistics will be collected - * @param usage Usage statistics - * @param req Request statistics - * @param blocks Blocks statistics - * @param errors Errors statistics - * - * @retval 0 Success - * @retval Non-zero Error - */ -int ocf_stats_collect_cache(ocf_cache_t cache, - struct ocf_stats_usage *usage, - struct ocf_stats_requests *req, - struct ocf_stats_blocks *blocks, - struct ocf_stats_errors *errors); - -/** - * @param Collect statistics for given core - * - * @param core Core for which statistics will be collected - * @param usage Usage statistics - * @param req Request statistics - * @param blocks Blocks statistics - * @param errors Errors statistics - * - * @retval 0 Success - * @retval Non-zero Error - */ -int ocf_stats_collect_core(ocf_core_t core, - struct ocf_stats_usage *usage, - struct ocf_stats_requests *req, - struct ocf_stats_blocks *blocks, - struct ocf_stats_errors *errors); - -/** - * @param Collect statistics for given ioclass - * - * @param core Core handle for which statistics will be collected - * @param part_id Ioclass id for which statistics will be collected - * @param usage Usage statistics - * @param req Request statistics - * @param blocks Blocks statistics - * - * @retval 0 Success - * @retval Non-zero Error - */ -int ocf_stats_collect_part_core(ocf_core_t core, ocf_part_id_t part_id, - struct ocf_stats_usage *usage, struct ocf_stats_requests *req, - struct ocf_stats_blocks *blocks); - -/** - * @param Collect statistics for given ioclass - * - * @param cache Cache instance for which statistics will be collected - * @param part_id Ioclass id for which statistics will be collected - * @param usage Usage statistics - * @param req Request statistics - * @param blocks Blocks statistics - * - * @retval 0 Success - * @retval Non-zero Error - */ -int ocf_stats_collect_part_cache(ocf_cache_t cache, ocf_part_id_t part_id, - struct ocf_stats_usage *usage, struct ocf_stats_requests *req, - struct ocf_stats_blocks *blocks); - -#endif /* __OCF_STATS_BUILDER_H__ */ diff --git a/src/ocf_stats_priv.h b/src/ocf_stats_priv.h index 7d29199..93c65c9 100644 --- a/src/ocf_stats_priv.h +++ b/src/ocf_stats_priv.h @@ -23,6 +23,132 @@ struct ocf_counters_req { env_atomic64 pass_through; }; +/** + * @brief OCF requests statistics like hit, miss, etc... + * + * @note To calculate number of hits request do: + * total - (partial_miss + full_miss) + */ +struct ocf_stats_req { + /** Number of partial misses */ + uint64_t partial_miss; + + /** Number of full misses */ + uint64_t full_miss; + + /** Total of requests */ + uint64_t total; + + /** Pass-through requests */ + uint64_t pass_through; +}; + +/** + * @brief OCF error statistics + */ +struct ocf_stats_error { + /** Read errors */ + uint32_t read; + + /** Write errors */ + uint32_t write; +}; + +/** + * @brief OCF block statistics in bytes + */ +struct ocf_stats_block { + /** Number of blocks read */ + uint64_t read; + + /** Number of blocks written */ + uint64_t write; +}; + +/** + * Statistics appropriate for given IO class + */ +struct ocf_stats_io_class { + /** Number of cache lines available for given partition */ + uint64_t free_clines; + + /** Number of cache lines within lru list */ + uint64_t occupancy_clines; + + /** Number of dirty cache lines assigned to specific partition */ + uint64_t dirty_clines; + + /** Read requests statistics */ + struct ocf_stats_req read_reqs; + + /** Writes requests statistics */ + struct ocf_stats_req write_reqs; + + /** Block requests for ocf volume statistics */ + struct ocf_stats_block blocks; + + /** Block requests for cache volume statistics */ + struct ocf_stats_block cache_blocks; + + /** Block requests for core volume statistics */ + struct ocf_stats_block core_blocks; +}; + +#define IO_PACKET_NO 12 +#define IO_ALIGN_NO 4 + +/** + * @brief Core debug statistics + */ +struct ocf_stats_core_debug { + /** I/O sizes being read (grouped by packets) */ + uint64_t read_size[IO_PACKET_NO]; + + /** I/O sizes being written (grouped by packets) */ + uint64_t write_size[IO_PACKET_NO]; + + /** I/O alignment for reads */ + uint64_t read_align[IO_ALIGN_NO]; + + /** I/O alignment for writes */ + uint64_t write_align[IO_ALIGN_NO]; +}; + +/** + * @brief OCF core statistics + */ +struct ocf_stats_core { + /** 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; + + /** Read requests statistics */ + struct ocf_stats_req read_reqs; + + /** Write requests statistics */ + struct ocf_stats_req write_reqs; + + /** Block requests for cache volume statistics */ + struct ocf_stats_block cache_volume; + + /** Block requests for core volume statistics */ + struct ocf_stats_block core_volume; + + /** Block requests submitted by user to this core */ + struct ocf_stats_block core; + + /** Cache volume error statistics */ + struct ocf_stats_error cache_errors; + + /** Core volume error statistics */ + struct ocf_stats_error core_errors; + + /** Debug statistics */ + struct ocf_stats_core_debug debug_stat; +}; + /** * statistics appropriate for given io class. */ @@ -56,4 +182,45 @@ struct ocf_counters_core { #endif }; +/** + * @brief ocf_core_io_class_get_stats retrieve io class statistics + * for given core + * + * Retrieve buffer of cache statistics for given cache instance. + * + * @param[in] core core handle to which request pertains + * @param[in] part_id IO class, stats of which are requested + * @param[out] stats statistic structure that shall be filled as + * a result of this function invocation. + * + * @result zero upon successful completion; error code otherwise + */ +int ocf_core_io_class_get_stats(ocf_core_t core, ocf_part_id_t part_id, + struct ocf_stats_io_class *stats); + +/** + * @brief retrieve core stats + * + * Retrieve ocf per core stats (for all IO classes together) + * + * @param[in] core core ID to which request pertains + * @param[out] stats statistics structure that shall be filled as + * a result of this function invocation. + * + * @result zero upon successful completion; error code otherwise + */ +int ocf_core_get_stats(ocf_core_t core, struct ocf_stats_core *stats); + +/** + * @brief update DEBUG stats given IO request + * + * Function meant to update DEBUG stats for IO request. + * + * @note This function shall be invoked for each IO request processed + * + * @param[in] core to which request pertains + * @param[in] io request for which stats are being updated + */ +void ocf_core_update_stats(ocf_core_t core, struct ocf_io *io); + #endif