dm-stats.h 988 B

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