xref: /linux/drivers/md/bcache/stats.h (revision a0433f8cae3ac51f59b4b1863032822aaa2d8164)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHE_STATS_H_
3 #define _BCACHE_STATS_H_
4 
5 struct cache_stat_collector {
6 	atomic_t cache_hits;
7 	atomic_t cache_misses;
8 	atomic_t cache_bypass_hits;
9 	atomic_t cache_bypass_misses;
10 	atomic_t cache_miss_collisions;
11 	atomic_t sectors_bypassed;
12 };
13 
14 struct cache_stats {
15 	struct kobject		kobj;
16 
17 	unsigned long cache_hits;
18 	unsigned long cache_misses;
19 	unsigned long cache_bypass_hits;
20 	unsigned long cache_bypass_misses;
21 	unsigned long cache_miss_collisions;
22 	unsigned long sectors_bypassed;
23 
24 	unsigned int		rescale;
25 };
26 
27 struct cache_accounting {
28 	struct closure		cl;
29 	struct timer_list	timer;
30 	atomic_t		closing;
31 
32 	struct cache_stat_collector collector;
33 
34 	struct cache_stats total;
35 	struct cache_stats five_minute;
36 	struct cache_stats hour;
37 	struct cache_stats day;
38 };
39 
40 struct cache_set;
41 struct cached_dev;
42 struct bcache_device;
43 
44 void bch_cache_accounting_init(struct cache_accounting *acc,
45 			       struct closure *parent);
46 
47 int bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
48 				   struct kobject *parent);
49 
50 void bch_cache_accounting_clear(struct cache_accounting *acc);
51 
52 void bch_cache_accounting_destroy(struct cache_accounting *acc);
53 
54 void bch_mark_cache_accounting(struct cache_set *c, struct bcache_device *d,
55 			       bool hit, bool bypass);
56 void bch_mark_cache_miss_collision(struct cache_set *c,
57 				   struct bcache_device *d);
58 void bch_mark_sectors_bypassed(struct cache_set *c,
59 			       struct cached_dev *dc,
60 			       int sectors);
61 
62 #endif /* _BCACHE_STATS_H_ */
63