0001
0002
0003
0004
0005
0006 #ifndef __F2FS_IOSTAT_H__
0007 #define __F2FS_IOSTAT_H__
0008
0009 struct bio_post_read_ctx;
0010
0011 #ifdef CONFIG_F2FS_IOSTAT
0012
0013 #define DEFAULT_IOSTAT_PERIOD_MS 3000
0014 #define MIN_IOSTAT_PERIOD_MS 100
0015
0016 #define MAX_IOSTAT_PERIOD_MS 8640000
0017
0018 enum {
0019 READ_IO,
0020 WRITE_SYNC_IO,
0021 WRITE_ASYNC_IO,
0022 MAX_IO_TYPE,
0023 };
0024
0025 struct iostat_lat_info {
0026 unsigned long sum_lat[MAX_IO_TYPE][NR_PAGE_TYPE];
0027 unsigned long peak_lat[MAX_IO_TYPE][NR_PAGE_TYPE];
0028 unsigned int bio_cnt[MAX_IO_TYPE][NR_PAGE_TYPE];
0029 };
0030
0031 extern int __maybe_unused iostat_info_seq_show(struct seq_file *seq,
0032 void *offset);
0033 extern void f2fs_reset_iostat(struct f2fs_sb_info *sbi);
0034 extern void f2fs_update_iostat(struct f2fs_sb_info *sbi,
0035 enum iostat_type type, unsigned long long io_bytes);
0036
0037 struct bio_iostat_ctx {
0038 struct f2fs_sb_info *sbi;
0039 unsigned long submit_ts;
0040 enum page_type type;
0041 struct bio_post_read_ctx *post_read_ctx;
0042 };
0043
0044 static inline void iostat_update_submit_ctx(struct bio *bio,
0045 enum page_type type)
0046 {
0047 struct bio_iostat_ctx *iostat_ctx = bio->bi_private;
0048
0049 iostat_ctx->submit_ts = jiffies;
0050 iostat_ctx->type = type;
0051 }
0052
0053 static inline struct bio_post_read_ctx *get_post_read_ctx(struct bio *bio)
0054 {
0055 struct bio_iostat_ctx *iostat_ctx = bio->bi_private;
0056
0057 return iostat_ctx->post_read_ctx;
0058 }
0059
0060 extern void iostat_update_and_unbind_ctx(struct bio *bio, int rw);
0061 extern void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi,
0062 struct bio *bio, struct bio_post_read_ctx *ctx);
0063 extern int f2fs_init_iostat_processing(void);
0064 extern void f2fs_destroy_iostat_processing(void);
0065 extern int f2fs_init_iostat(struct f2fs_sb_info *sbi);
0066 extern void f2fs_destroy_iostat(struct f2fs_sb_info *sbi);
0067 #else
0068 static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi,
0069 enum iostat_type type, unsigned long long io_bytes) {}
0070 static inline void iostat_update_and_unbind_ctx(struct bio *bio, int rw) {}
0071 static inline void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi,
0072 struct bio *bio, struct bio_post_read_ctx *ctx) {}
0073 static inline void iostat_update_submit_ctx(struct bio *bio,
0074 enum page_type type) {}
0075 static inline struct bio_post_read_ctx *get_post_read_ctx(struct bio *bio)
0076 {
0077 return bio->bi_private;
0078 }
0079 static inline int f2fs_init_iostat_processing(void) { return 0; }
0080 static inline void f2fs_destroy_iostat_processing(void) {}
0081 static inline int f2fs_init_iostat(struct f2fs_sb_info *sbi) { return 0; }
0082 static inline void f2fs_destroy_iostat(struct f2fs_sb_info *sbi) {}
0083 #endif
0084 #endif