18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _BCACHE_STATS_H_ 38c2ecf20Sopenharmony_ci#define _BCACHE_STATS_H_ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_cistruct cache_stat_collector { 68c2ecf20Sopenharmony_ci atomic_t cache_hits; 78c2ecf20Sopenharmony_ci atomic_t cache_misses; 88c2ecf20Sopenharmony_ci atomic_t cache_bypass_hits; 98c2ecf20Sopenharmony_ci atomic_t cache_bypass_misses; 108c2ecf20Sopenharmony_ci atomic_t cache_readaheads; 118c2ecf20Sopenharmony_ci atomic_t cache_miss_collisions; 128c2ecf20Sopenharmony_ci atomic_t sectors_bypassed; 138c2ecf20Sopenharmony_ci}; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistruct cache_stats { 168c2ecf20Sopenharmony_ci struct kobject kobj; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci unsigned long cache_hits; 198c2ecf20Sopenharmony_ci unsigned long cache_misses; 208c2ecf20Sopenharmony_ci unsigned long cache_bypass_hits; 218c2ecf20Sopenharmony_ci unsigned long cache_bypass_misses; 228c2ecf20Sopenharmony_ci unsigned long cache_readaheads; 238c2ecf20Sopenharmony_ci unsigned long cache_miss_collisions; 248c2ecf20Sopenharmony_ci unsigned long sectors_bypassed; 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci unsigned int rescale; 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistruct cache_accounting { 308c2ecf20Sopenharmony_ci struct closure cl; 318c2ecf20Sopenharmony_ci struct timer_list timer; 328c2ecf20Sopenharmony_ci atomic_t closing; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci struct cache_stat_collector collector; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci struct cache_stats total; 378c2ecf20Sopenharmony_ci struct cache_stats five_minute; 388c2ecf20Sopenharmony_ci struct cache_stats hour; 398c2ecf20Sopenharmony_ci struct cache_stats day; 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistruct cache_set; 438c2ecf20Sopenharmony_cistruct cached_dev; 448c2ecf20Sopenharmony_cistruct bcache_device; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_civoid bch_cache_accounting_init(struct cache_accounting *acc, 478c2ecf20Sopenharmony_ci struct closure *parent); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ciint bch_cache_accounting_add_kobjs(struct cache_accounting *acc, 508c2ecf20Sopenharmony_ci struct kobject *parent); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_civoid bch_cache_accounting_clear(struct cache_accounting *acc); 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_civoid bch_cache_accounting_destroy(struct cache_accounting *acc); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_civoid bch_mark_cache_accounting(struct cache_set *c, struct bcache_device *d, 578c2ecf20Sopenharmony_ci bool hit, bool bypass); 588c2ecf20Sopenharmony_civoid bch_mark_cache_readahead(struct cache_set *c, struct bcache_device *d); 598c2ecf20Sopenharmony_civoid bch_mark_cache_miss_collision(struct cache_set *c, 608c2ecf20Sopenharmony_ci struct bcache_device *d); 618c2ecf20Sopenharmony_civoid bch_mark_sectors_bypassed(struct cache_set *c, 628c2ecf20Sopenharmony_ci struct cached_dev *dc, 638c2ecf20Sopenharmony_ci int sectors); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#endif /* _BCACHE_STATS_H_ */ 66