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