bcachefs-tools/libbcache/stats.h

69 lines
1.9 KiB
C
Raw Normal View History

2017-01-08 12:13:18 +03:00
#ifndef _BCACHE_STATS_H_
#define _BCACHE_STATS_H_
#include "stats_types.h"
2017-03-11 00:40:01 +03:00
struct bch_fs;
2017-01-08 12:13:18 +03:00
struct cached_dev;
struct bcache_device;
#ifndef NO_BCACHE_ACCOUNTING
2017-01-08 12:13:18 +03:00
void bch_cache_accounting_init(struct cache_accounting *, struct closure *);
int bch_cache_accounting_add_kobjs(struct cache_accounting *, struct kobject *);
void bch_cache_accounting_clear(struct cache_accounting *);
void bch_cache_accounting_destroy(struct cache_accounting *);
#else
static inline void bch_cache_accounting_init(struct cache_accounting *acc,
struct closure *cl) {}
static inline int bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
struct kobject *cl)
{
return 0;
}
static inline void bch_cache_accounting_clear(struct cache_accounting *acc) {}
static inline void bch_cache_accounting_destroy(struct cache_accounting *acc) {}
#endif
2017-01-08 12:13:18 +03:00
static inline void mark_cache_stats(struct cache_stat_collector *stats,
bool hit, bool bypass)
{
atomic_inc(&stats->cache_hit_array[!bypass][!hit]);
}
2017-03-11 00:40:01 +03:00
static inline void bch_mark_cache_accounting(struct bch_fs *c,
2017-01-08 12:13:18 +03:00
struct cached_dev *dc,
bool hit, bool bypass)
{
mark_cache_stats(&dc->accounting.collector, hit, bypass);
mark_cache_stats(&c->accounting.collector, hit, bypass);
}
2017-03-11 00:40:01 +03:00
static inline void bch_mark_sectors_bypassed(struct bch_fs *c,
2017-01-08 12:13:18 +03:00
struct cached_dev *dc,
unsigned sectors)
{
atomic_add(sectors, &dc->accounting.collector.sectors_bypassed);
atomic_add(sectors, &c->accounting.collector.sectors_bypassed);
}
2017-03-11 00:40:01 +03:00
static inline void bch_mark_gc_write(struct bch_fs *c, int sectors)
2017-01-08 12:13:18 +03:00
{
atomic_add(sectors, &c->accounting.collector.gc_write_sectors);
}
2017-03-11 00:40:01 +03:00
static inline void bch_mark_foreground_write(struct bch_fs *c, int sectors)
2017-01-08 12:13:18 +03:00
{
atomic_add(sectors, &c->accounting.collector.foreground_write_sectors);
}
2017-03-11 00:40:01 +03:00
static inline void bch_mark_discard(struct bch_fs *c, int sectors)
2017-01-08 12:13:18 +03:00
{
atomic_add(sectors, &c->accounting.collector.discard_sectors);
}
#endif /* _BCACHE_STATS_H_ */