iostat.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright 2021 Google LLC
  4. * Author: Daeho Jeong <[email protected]>
  5. */
  6. #ifndef __F2FS_IOSTAT_H__
  7. #define __F2FS_IOSTAT_H__
  8. struct bio_post_read_ctx;
  9. enum iostat_lat_type {
  10. READ_IO = 0,
  11. WRITE_SYNC_IO,
  12. WRITE_ASYNC_IO,
  13. MAX_IO_TYPE,
  14. };
  15. #ifdef CONFIG_F2FS_IOSTAT
  16. #define NUM_PREALLOC_IOSTAT_CTXS 128
  17. #define DEFAULT_IOSTAT_PERIOD_MS 3000
  18. #define MIN_IOSTAT_PERIOD_MS 100
  19. /* maximum period of iostat tracing is 1 day */
  20. #define MAX_IOSTAT_PERIOD_MS 8640000
  21. struct iostat_lat_info {
  22. unsigned long sum_lat[MAX_IO_TYPE][NR_PAGE_TYPE]; /* sum of io latencies */
  23. unsigned long peak_lat[MAX_IO_TYPE][NR_PAGE_TYPE]; /* peak io latency */
  24. unsigned int bio_cnt[MAX_IO_TYPE][NR_PAGE_TYPE]; /* bio count */
  25. };
  26. extern int __maybe_unused iostat_info_seq_show(struct seq_file *seq,
  27. void *offset);
  28. extern void f2fs_reset_iostat(struct f2fs_sb_info *sbi);
  29. extern void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode,
  30. enum iostat_type type, unsigned long long io_bytes);
  31. struct bio_iostat_ctx {
  32. struct f2fs_sb_info *sbi;
  33. unsigned long submit_ts;
  34. enum page_type type;
  35. struct bio_post_read_ctx *post_read_ctx;
  36. };
  37. static inline void iostat_update_submit_ctx(struct bio *bio,
  38. enum page_type type)
  39. {
  40. struct bio_iostat_ctx *iostat_ctx = bio->bi_private;
  41. iostat_ctx->submit_ts = jiffies;
  42. iostat_ctx->type = type;
  43. }
  44. static inline struct bio_post_read_ctx *get_post_read_ctx(struct bio *bio)
  45. {
  46. struct bio_iostat_ctx *iostat_ctx = bio->bi_private;
  47. return iostat_ctx->post_read_ctx;
  48. }
  49. extern void iostat_update_and_unbind_ctx(struct bio *bio);
  50. extern void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi,
  51. struct bio *bio, struct bio_post_read_ctx *ctx);
  52. extern int f2fs_init_iostat_processing(void);
  53. extern void f2fs_destroy_iostat_processing(void);
  54. extern int f2fs_init_iostat(struct f2fs_sb_info *sbi);
  55. extern void f2fs_destroy_iostat(struct f2fs_sb_info *sbi);
  56. #else
  57. static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode,
  58. enum iostat_type type, unsigned long long io_bytes) {}
  59. static inline void iostat_update_and_unbind_ctx(struct bio *bio) {}
  60. static inline void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi,
  61. struct bio *bio, struct bio_post_read_ctx *ctx) {}
  62. static inline void iostat_update_submit_ctx(struct bio *bio,
  63. enum page_type type) {}
  64. static inline struct bio_post_read_ctx *get_post_read_ctx(struct bio *bio)
  65. {
  66. return bio->bi_private;
  67. }
  68. static inline int f2fs_init_iostat_processing(void) { return 0; }
  69. static inline void f2fs_destroy_iostat_processing(void) {}
  70. static inline int f2fs_init_iostat(struct f2fs_sb_info *sbi) { return 0; }
  71. static inline void f2fs_destroy_iostat(struct f2fs_sb_info *sbi) {}
  72. #endif
  73. #endif /* __F2FS_IOSTAT_H__ */