1 #ifndef _BCACHE_STATS_H_
2 #define _BCACHE_STATS_H_
4 #include "stats_types.h"
10 #ifndef NO_BCACHE_ACCOUNTING
12 void bch_cache_accounting_init(struct cache_accounting *, struct closure *);
13 int bch_cache_accounting_add_kobjs(struct cache_accounting *, struct kobject *);
14 void bch_cache_accounting_clear(struct cache_accounting *);
15 void bch_cache_accounting_destroy(struct cache_accounting *);
19 static inline void bch_cache_accounting_init(struct cache_accounting *acc,
20 struct closure *cl) {}
21 static inline int bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
26 static inline void bch_cache_accounting_clear(struct cache_accounting *acc) {}
27 static inline void bch_cache_accounting_destroy(struct cache_accounting *acc) {}
31 static inline void mark_cache_stats(struct cache_stat_collector *stats,
32 bool hit, bool bypass)
34 atomic_inc(&stats->cache_hit_array[!bypass][!hit]);
37 static inline void bch_mark_cache_accounting(struct cache_set *c,
38 struct cached_dev *dc,
39 bool hit, bool bypass)
41 mark_cache_stats(&dc->accounting.collector, hit, bypass);
42 mark_cache_stats(&c->accounting.collector, hit, bypass);
45 static inline void bch_mark_sectors_bypassed(struct cache_set *c,
46 struct cached_dev *dc,
49 atomic_add(sectors, &dc->accounting.collector.sectors_bypassed);
50 atomic_add(sectors, &c->accounting.collector.sectors_bypassed);
53 static inline void bch_mark_gc_write(struct cache_set *c, int sectors)
55 atomic_add(sectors, &c->accounting.collector.gc_write_sectors);
58 static inline void bch_mark_foreground_write(struct cache_set *c, int sectors)
60 atomic_add(sectors, &c->accounting.collector.foreground_write_sectors);
63 static inline void bch_mark_discard(struct cache_set *c, int sectors)
65 atomic_add(sectors, &c->accounting.collector.discard_sectors);
68 #endif /* _BCACHE_STATS_H_ */