blob: f1c0956e3843f51e40dc2da23a68fc54d7a141c3 [file] [log] [blame]
Mikulas Patockafd2ed4d2013-08-16 10:54:23 -04001#ifndef DM_STATS_H
2#define DM_STATS_H
3
4#include <linux/types.h>
5#include <linux/mutex.h>
6#include <linux/list.h>
7
8int dm_statistics_init(void);
9void dm_statistics_exit(void);
10
11struct dm_stats {
12 struct mutex mutex;
13 struct list_head list; /* list of struct dm_stat */
14 struct dm_stats_last_position __percpu *last;
15 sector_t last_sector;
16 unsigned last_rw;
17};
18
19struct dm_stats_aux {
20 bool merged;
Mikulas Patockac96aec32015-06-09 17:21:39 -040021 unsigned long long duration_ns;
Mikulas Patockafd2ed4d2013-08-16 10:54:23 -040022};
23
24void dm_stats_init(struct dm_stats *st);
25void dm_stats_cleanup(struct dm_stats *st);
26
27struct mapped_device;
28
29int dm_stats_message(struct mapped_device *md, unsigned argc, char **argv,
30 char *result, unsigned maxlen);
31
32void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
33 sector_t bi_sector, unsigned bi_sectors, bool end,
Mikulas Patockac96aec32015-06-09 17:21:39 -040034 unsigned long duration_jiffies,
35 struct dm_stats_aux *aux);
Mikulas Patockafd2ed4d2013-08-16 10:54:23 -040036
37static inline bool dm_stats_used(struct dm_stats *st)
38{
39 return !list_empty(&st->list);
40}
41
42#endif