1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2cafe5635SKent Overstreet #ifndef _BCACHE_STATS_H_ 3cafe5635SKent Overstreet #define _BCACHE_STATS_H_ 4cafe5635SKent Overstreet 5cafe5635SKent Overstreet struct cache_stat_collector { 6cafe5635SKent Overstreet atomic_t cache_hits; 7cafe5635SKent Overstreet atomic_t cache_misses; 8cafe5635SKent Overstreet atomic_t cache_bypass_hits; 9cafe5635SKent Overstreet atomic_t cache_bypass_misses; 10cafe5635SKent Overstreet atomic_t cache_readaheads; 11cafe5635SKent Overstreet atomic_t cache_miss_collisions; 12cafe5635SKent Overstreet atomic_t sectors_bypassed; 13cafe5635SKent Overstreet }; 14cafe5635SKent Overstreet 15cafe5635SKent Overstreet struct cache_stats { 16cafe5635SKent Overstreet struct kobject kobj; 17cafe5635SKent Overstreet 18cafe5635SKent Overstreet unsigned long cache_hits; 19cafe5635SKent Overstreet unsigned long cache_misses; 20cafe5635SKent Overstreet unsigned long cache_bypass_hits; 21cafe5635SKent Overstreet unsigned long cache_bypass_misses; 22cafe5635SKent Overstreet unsigned long cache_readaheads; 23cafe5635SKent Overstreet unsigned long cache_miss_collisions; 24cafe5635SKent Overstreet unsigned long sectors_bypassed; 25cafe5635SKent Overstreet 266f10f7d1SColy Li unsigned int rescale; 27cafe5635SKent Overstreet }; 28cafe5635SKent Overstreet 29cafe5635SKent Overstreet struct cache_accounting { 30cafe5635SKent Overstreet struct closure cl; 31cafe5635SKent Overstreet struct timer_list timer; 32cafe5635SKent Overstreet atomic_t closing; 33cafe5635SKent Overstreet 34cafe5635SKent Overstreet struct cache_stat_collector collector; 35cafe5635SKent Overstreet 36cafe5635SKent Overstreet struct cache_stats total; 37cafe5635SKent Overstreet struct cache_stats five_minute; 38cafe5635SKent Overstreet struct cache_stats hour; 39cafe5635SKent Overstreet struct cache_stats day; 40cafe5635SKent Overstreet }; 41cafe5635SKent Overstreet 42220bb38cSKent Overstreet struct cache_set; 43220bb38cSKent Overstreet struct cached_dev; 44220bb38cSKent Overstreet struct bcache_device; 45cafe5635SKent Overstreet 46cafe5635SKent Overstreet void bch_cache_accounting_init(struct cache_accounting *acc, 47cafe5635SKent Overstreet struct closure *parent); 48cafe5635SKent Overstreet 49cafe5635SKent Overstreet int bch_cache_accounting_add_kobjs(struct cache_accounting *acc, 50cafe5635SKent Overstreet struct kobject *parent); 51cafe5635SKent Overstreet 52cafe5635SKent Overstreet void bch_cache_accounting_clear(struct cache_accounting *acc); 53cafe5635SKent Overstreet 54cafe5635SKent Overstreet void bch_cache_accounting_destroy(struct cache_accounting *acc); 55cafe5635SKent Overstreet 56*fc2d5988SColy Li void bch_mark_cache_accounting(struct cache_set *c, struct bcache_device *d, 57*fc2d5988SColy Li bool hit, bool bypass); 58*fc2d5988SColy Li void bch_mark_cache_readahead(struct cache_set *c, struct bcache_device *d); 59*fc2d5988SColy Li void bch_mark_cache_miss_collision(struct cache_set *c, 60*fc2d5988SColy Li struct bcache_device *d); 61*fc2d5988SColy Li void bch_mark_sectors_bypassed(struct cache_set *c, 62*fc2d5988SColy Li struct cached_dev *dc, 63*fc2d5988SColy Li int sectors); 64cafe5635SKent Overstreet 65cafe5635SKent Overstreet #endif /* _BCACHE_STATS_H_ */ 66