1 #ifndef _BCACHE_STATS_H_
2 #define _BCACHE_STATS_H_
4 #include "stats_types.h"
10 void bch_cache_accounting_init(struct cache_accounting *, struct closure *);
11 int bch_cache_accounting_add_kobjs(struct cache_accounting *, struct kobject *);
12 void bch_cache_accounting_clear(struct cache_accounting *);
13 void bch_cache_accounting_destroy(struct cache_accounting *);
15 static inline void mark_cache_stats(struct cache_stat_collector *stats,
16 bool hit, bool bypass)
18 atomic_inc(&stats->cache_hit_array[!bypass][!hit]);
21 static inline void bch_mark_cache_accounting(struct cache_set *c,
22 struct cached_dev *dc,
23 bool hit, bool bypass)
25 mark_cache_stats(&dc->accounting.collector, hit, bypass);
26 mark_cache_stats(&c->accounting.collector, hit, bypass);
29 static inline void bch_mark_sectors_bypassed(struct cache_set *c,
30 struct cached_dev *dc,
33 atomic_add(sectors, &dc->accounting.collector.sectors_bypassed);
34 atomic_add(sectors, &c->accounting.collector.sectors_bypassed);
37 static inline void bch_mark_gc_write(struct cache_set *c, int sectors)
39 atomic_add(sectors, &c->accounting.collector.gc_write_sectors);
42 static inline void bch_mark_foreground_write(struct cache_set *c, int sectors)
44 atomic_add(sectors, &c->accounting.collector.foreground_write_sectors);
47 static inline void bch_mark_discard(struct cache_set *c, int sectors)
49 atomic_add(sectors, &c->accounting.collector.discard_sectors);
52 #endif /* _BCACHE_STATS_H_ */