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