Merge tag 'spi-fix-v6.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
[linux-block.git] / drivers / md / dm-stats.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
fd2ed4d2
MP
2#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;
0cdb90f0 16 bool precise_timestamps;
fd2ed4d2
MP
17};
18
19struct dm_stats_aux {
20 bool merged;
c96aec34 21 unsigned long long duration_ns;
fd2ed4d2
MP
22};
23
d3aa3e06 24int dm_stats_init(struct dm_stats *st);
fd2ed4d2
MP
25void dm_stats_cleanup(struct dm_stats *st);
26
27struct mapped_device;
28
86a3238c
HM
29int dm_stats_message(struct mapped_device *md, unsigned int argc, char **argv,
30 char *result, unsigned int maxlen);
fd2ed4d2
MP
31
32void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
86a3238c 33 sector_t bi_sector, unsigned int bi_sectors, bool end,
8d394bc4 34 unsigned long start_time,
c96aec34 35 struct dm_stats_aux *aux);
fd2ed4d2
MP
36
37static inline bool dm_stats_used(struct dm_stats *st)
38{
39 return !list_empty(&st->list);
40}
41
0cdb90f0
MS
42static inline void dm_stats_record_start(struct dm_stats *stats, struct dm_stats_aux *aux)
43{
44 if (unlikely(stats->precise_timestamps))
45 aux->duration_ns = ktime_to_ns(ktime_get());
46}
47
fd2ed4d2 48#endif