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