statistics.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright 2023 Red Hat
  4. */
  5. #ifndef STATISTICS_H
  6. #define STATISTICS_H
  7. #include "types.h"
  8. enum {
  9. STATISTICS_VERSION = 36,
  10. };
  11. struct block_allocator_statistics {
  12. /* The total number of slabs from which blocks may be allocated */
  13. u64 slab_count;
  14. /* The total number of slabs from which blocks have ever been allocated */
  15. u64 slabs_opened;
  16. /* The number of times since loading that a slab has been re-opened */
  17. u64 slabs_reopened;
  18. };
  19. /**
  20. * Counters for tracking the number of items written (blocks, requests, etc.)
  21. * that keep track of totals at steps in the write pipeline. Three counters
  22. * allow the number of buffered, in-memory items and the number of in-flight,
  23. * unacknowledged writes to be derived, while still tracking totals for
  24. * reporting purposes
  25. */
  26. struct commit_statistics {
  27. /* The total number of items on which processing has started */
  28. u64 started;
  29. /* The total number of items for which a write operation has been issued */
  30. u64 written;
  31. /* The total number of items for which a write operation has completed */
  32. u64 committed;
  33. };
  34. /** Counters for events in the recovery journal */
  35. struct recovery_journal_statistics {
  36. /* Number of times the on-disk journal was full */
  37. u64 disk_full;
  38. /* Number of times the recovery journal requested slab journal commits. */
  39. u64 slab_journal_commits_requested;
  40. /* Write/Commit totals for individual journal entries */
  41. struct commit_statistics entries;
  42. /* Write/Commit totals for journal blocks */
  43. struct commit_statistics blocks;
  44. };
  45. /** The statistics for the compressed block packer. */
  46. struct packer_statistics {
  47. /* Number of compressed data items written since startup */
  48. u64 compressed_fragments_written;
  49. /* Number of blocks containing compressed items written since startup */
  50. u64 compressed_blocks_written;
  51. /* Number of VIOs that are pending in the packer */
  52. u64 compressed_fragments_in_packer;
  53. };
  54. /** The statistics for the slab journals. */
  55. struct slab_journal_statistics {
  56. /* Number of times the on-disk journal was full */
  57. u64 disk_full_count;
  58. /* Number of times an entry was added over the flush threshold */
  59. u64 flush_count;
  60. /* Number of times an entry was added over the block threshold */
  61. u64 blocked_count;
  62. /* Number of times a tail block was written */
  63. u64 blocks_written;
  64. /* Number of times we had to wait for the tail to write */
  65. u64 tail_busy_count;
  66. };
  67. /** The statistics for the slab summary. */
  68. struct slab_summary_statistics {
  69. /* Number of blocks written */
  70. u64 blocks_written;
  71. };
  72. /** The statistics for the reference counts. */
  73. struct ref_counts_statistics {
  74. /* Number of reference blocks written */
  75. u64 blocks_written;
  76. };
  77. /** The statistics for the block map. */
  78. struct block_map_statistics {
  79. /* number of dirty (resident) pages */
  80. u32 dirty_pages;
  81. /* number of clean (resident) pages */
  82. u32 clean_pages;
  83. /* number of free pages */
  84. u32 free_pages;
  85. /* number of pages in failed state */
  86. u32 failed_pages;
  87. /* number of pages incoming */
  88. u32 incoming_pages;
  89. /* number of pages outgoing */
  90. u32 outgoing_pages;
  91. /* how many times free page not avail */
  92. u32 cache_pressure;
  93. /* number of get_vdo_page() calls for read */
  94. u64 read_count;
  95. /* number of get_vdo_page() calls for write */
  96. u64 write_count;
  97. /* number of times pages failed to read */
  98. u64 failed_reads;
  99. /* number of times pages failed to write */
  100. u64 failed_writes;
  101. /* number of gets that are reclaimed */
  102. u64 reclaimed;
  103. /* number of gets for outgoing pages */
  104. u64 read_outgoing;
  105. /* number of gets that were already there */
  106. u64 found_in_cache;
  107. /* number of gets requiring discard */
  108. u64 discard_required;
  109. /* number of gets enqueued for their page */
  110. u64 wait_for_page;
  111. /* number of gets that have to fetch */
  112. u64 fetch_required;
  113. /* number of page fetches */
  114. u64 pages_loaded;
  115. /* number of page saves */
  116. u64 pages_saved;
  117. /* the number of flushes issued */
  118. u64 flush_count;
  119. };
  120. /** The dedupe statistics from hash locks */
  121. struct hash_lock_statistics {
  122. /* Number of times the UDS advice proved correct */
  123. u64 dedupe_advice_valid;
  124. /* Number of times the UDS advice proved incorrect */
  125. u64 dedupe_advice_stale;
  126. /* Number of writes with the same data as another in-flight write */
  127. u64 concurrent_data_matches;
  128. /* Number of writes whose hash collided with an in-flight write */
  129. u64 concurrent_hash_collisions;
  130. /* Current number of dedupe queries that are in flight */
  131. u32 curr_dedupe_queries;
  132. };
  133. /** Counts of error conditions in VDO. */
  134. struct error_statistics {
  135. /* number of times VDO got an invalid dedupe advice PBN from UDS */
  136. u64 invalid_advice_pbn_count;
  137. /* number of times a VIO completed with a VDO_NO_SPACE error */
  138. u64 no_space_error_count;
  139. /* number of times a VIO completed with a VDO_READ_ONLY error */
  140. u64 read_only_error_count;
  141. };
  142. struct bio_stats {
  143. /* Number of REQ_OP_READ bios */
  144. u64 read;
  145. /* Number of REQ_OP_WRITE bios with data */
  146. u64 write;
  147. /* Number of bios tagged with REQ_PREFLUSH and containing no data */
  148. u64 empty_flush;
  149. /* Number of REQ_OP_DISCARD bios */
  150. u64 discard;
  151. /* Number of bios tagged with REQ_PREFLUSH */
  152. u64 flush;
  153. /* Number of bios tagged with REQ_FUA */
  154. u64 fua;
  155. };
  156. struct memory_usage {
  157. /* Tracked bytes currently allocated. */
  158. u64 bytes_used;
  159. /* Maximum tracked bytes allocated. */
  160. u64 peak_bytes_used;
  161. };
  162. /** UDS index statistics */
  163. struct index_statistics {
  164. /* Number of records stored in the index */
  165. u64 entries_indexed;
  166. /* Number of post calls that found an existing entry */
  167. u64 posts_found;
  168. /* Number of post calls that added a new entry */
  169. u64 posts_not_found;
  170. /* Number of query calls that found an existing entry */
  171. u64 queries_found;
  172. /* Number of query calls that added a new entry */
  173. u64 queries_not_found;
  174. /* Number of update calls that found an existing entry */
  175. u64 updates_found;
  176. /* Number of update calls that added a new entry */
  177. u64 updates_not_found;
  178. /* Number of entries discarded */
  179. u64 entries_discarded;
  180. };
  181. /** The statistics of the vdo service. */
  182. struct vdo_statistics {
  183. u32 version;
  184. /* Number of blocks used for data */
  185. u64 data_blocks_used;
  186. /* Number of blocks used for VDO metadata */
  187. u64 overhead_blocks_used;
  188. /* Number of logical blocks that are currently mapped to physical blocks */
  189. u64 logical_blocks_used;
  190. /* number of physical blocks */
  191. block_count_t physical_blocks;
  192. /* number of logical blocks */
  193. block_count_t logical_blocks;
  194. /* Size of the block map page cache, in bytes */
  195. u64 block_map_cache_size;
  196. /* The physical block size */
  197. u64 block_size;
  198. /* Number of times the VDO has successfully recovered */
  199. u64 complete_recoveries;
  200. /* Number of times the VDO has recovered from read-only mode */
  201. u64 read_only_recoveries;
  202. /* String describing the operating mode of the VDO */
  203. char mode[15];
  204. /* Whether the VDO is in recovery mode */
  205. bool in_recovery_mode;
  206. /* What percentage of recovery mode work has been completed */
  207. u8 recovery_percentage;
  208. /* The statistics for the compressed block packer */
  209. struct packer_statistics packer;
  210. /* Counters for events in the block allocator */
  211. struct block_allocator_statistics allocator;
  212. /* Counters for events in the recovery journal */
  213. struct recovery_journal_statistics journal;
  214. /* The statistics for the slab journals */
  215. struct slab_journal_statistics slab_journal;
  216. /* The statistics for the slab summary */
  217. struct slab_summary_statistics slab_summary;
  218. /* The statistics for the reference counts */
  219. struct ref_counts_statistics ref_counts;
  220. /* The statistics for the block map */
  221. struct block_map_statistics block_map;
  222. /* The dedupe statistics from hash locks */
  223. struct hash_lock_statistics hash_lock;
  224. /* Counts of error conditions */
  225. struct error_statistics errors;
  226. /* The VDO instance */
  227. u32 instance;
  228. /* Current number of active VIOs */
  229. u32 current_vios_in_progress;
  230. /* Maximum number of active VIOs */
  231. u32 max_vios;
  232. /* Number of times the UDS index was too slow in responding */
  233. u64 dedupe_advice_timeouts;
  234. /* Number of flush requests submitted to the storage device */
  235. u64 flush_out;
  236. /* Logical block size */
  237. u64 logical_block_size;
  238. /* Bios submitted into VDO from above */
  239. struct bio_stats bios_in;
  240. struct bio_stats bios_in_partial;
  241. /* Bios submitted onward for user data */
  242. struct bio_stats bios_out;
  243. /* Bios submitted onward for metadata */
  244. struct bio_stats bios_meta;
  245. struct bio_stats bios_journal;
  246. struct bio_stats bios_page_cache;
  247. struct bio_stats bios_out_completed;
  248. struct bio_stats bios_meta_completed;
  249. struct bio_stats bios_journal_completed;
  250. struct bio_stats bios_page_cache_completed;
  251. struct bio_stats bios_acknowledged;
  252. struct bio_stats bios_acknowledged_partial;
  253. /* Current number of bios in progress */
  254. struct bio_stats bios_in_progress;
  255. /* Memory usage stats. */
  256. struct memory_usage memory_usage;
  257. /* The statistics for the UDS index */
  258. struct index_statistics index;
  259. };
  260. #endif /* not STATISTICS_H */