File: dm-stats.h

package info (click to toggle)
linux 6.1.133-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,136 kB
  • sloc: ansic: 23,466,380; asm: 266,559; sh: 110,511; makefile: 49,889; python: 36,990; perl: 36,827; cpp: 6,056; yacc: 4,908; lex: 2,725; awk: 1,440; ruby: 25; sed: 5
file content (48 lines) | stat: -rw-r--r-- 1,162 bytes parent folder | download | duplicates (30)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef DM_STATS_H
#define DM_STATS_H

#include <linux/types.h>
#include <linux/mutex.h>
#include <linux/list.h>

int dm_statistics_init(void);
void dm_statistics_exit(void);

struct dm_stats {
	struct mutex mutex;
	struct list_head list;	/* list of struct dm_stat */
	struct dm_stats_last_position __percpu *last;
	bool precise_timestamps;
};

struct dm_stats_aux {
	bool merged;
	unsigned long long duration_ns;
};

int dm_stats_init(struct dm_stats *st);
void dm_stats_cleanup(struct dm_stats *st);

struct mapped_device;

int dm_stats_message(struct mapped_device *md, unsigned int argc, char **argv,
		     char *result, unsigned int maxlen);

void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
			 sector_t bi_sector, unsigned int bi_sectors, bool end,
			 unsigned long start_time,
			 struct dm_stats_aux *aux);

static inline bool dm_stats_used(struct dm_stats *st)
{
	return !list_empty(&st->list);
}

static inline void dm_stats_record_start(struct dm_stats *stats, struct dm_stats_aux *aux)
{
	if (unlikely(stats->precise_timestamps))
		aux->duration_ns = ktime_to_ns(ktime_get());
}

#endif