^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef DM_STATS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define DM_STATS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) int dm_statistics_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) void dm_statistics_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct dm_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct list_head list; /* list of struct dm_stat */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct dm_stats_last_position __percpu *last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) sector_t last_sector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) unsigned last_rw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct dm_stats_aux {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) bool merged;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) unsigned long long duration_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) void dm_stats_init(struct dm_stats *st);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) void dm_stats_cleanup(struct dm_stats *st);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct mapped_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int dm_stats_message(struct mapped_device *md, unsigned argc, char **argv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) char *result, unsigned maxlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) sector_t bi_sector, unsigned bi_sectors, bool end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) unsigned long duration_jiffies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct dm_stats_aux *aux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static inline bool dm_stats_used(struct dm_stats *st)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) return !list_empty(&st->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #endif