1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 2 /* 3 * Copyright 2021 Google LLC 3 * Copyright 2021 Google LLC 4 * Author: Daeho Jeong <daehojeong@google.com> 4 * Author: Daeho Jeong <daehojeong@google.com> 5 */ 5 */ 6 #ifndef __F2FS_IOSTAT_H__ 6 #ifndef __F2FS_IOSTAT_H__ 7 #define __F2FS_IOSTAT_H__ 7 #define __F2FS_IOSTAT_H__ 8 8 9 struct bio_post_read_ctx; 9 struct bio_post_read_ctx; 10 10 11 enum iostat_lat_type { 11 enum iostat_lat_type { 12 READ_IO = 0, 12 READ_IO = 0, 13 WRITE_SYNC_IO, 13 WRITE_SYNC_IO, 14 WRITE_ASYNC_IO, 14 WRITE_ASYNC_IO, 15 MAX_IO_TYPE, 15 MAX_IO_TYPE, 16 }; 16 }; 17 17 18 #ifdef CONFIG_F2FS_IOSTAT 18 #ifdef CONFIG_F2FS_IOSTAT 19 19 20 #define NUM_PREALLOC_IOSTAT_CTXS 128 20 #define NUM_PREALLOC_IOSTAT_CTXS 128 21 #define DEFAULT_IOSTAT_PERIOD_MS 3000 21 #define DEFAULT_IOSTAT_PERIOD_MS 3000 22 #define MIN_IOSTAT_PERIOD_MS 100 22 #define MIN_IOSTAT_PERIOD_MS 100 23 /* maximum period of iostat tracing is 1 day * 23 /* maximum period of iostat tracing is 1 day */ 24 #define MAX_IOSTAT_PERIOD_MS 864000 24 #define MAX_IOSTAT_PERIOD_MS 8640000 25 25 26 struct iostat_lat_info { 26 struct iostat_lat_info { 27 unsigned long sum_lat[MAX_IO_TYPE][NR_ 27 unsigned long sum_lat[MAX_IO_TYPE][NR_PAGE_TYPE]; /* sum of io latencies */ 28 unsigned long peak_lat[MAX_IO_TYPE][NR 28 unsigned long peak_lat[MAX_IO_TYPE][NR_PAGE_TYPE]; /* peak io latency */ 29 unsigned int bio_cnt[MAX_IO_TYPE][NR_P 29 unsigned int bio_cnt[MAX_IO_TYPE][NR_PAGE_TYPE]; /* bio count */ 30 }; 30 }; 31 31 32 extern int __maybe_unused iostat_info_seq_show 32 extern int __maybe_unused iostat_info_seq_show(struct seq_file *seq, 33 void *offset); 33 void *offset); 34 extern void f2fs_reset_iostat(struct f2fs_sb_i 34 extern void f2fs_reset_iostat(struct f2fs_sb_info *sbi); 35 extern void f2fs_update_iostat(struct f2fs_sb_ 35 extern void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode, 36 enum iostat_type type, 36 enum iostat_type type, unsigned long long io_bytes); 37 37 38 struct bio_iostat_ctx { 38 struct bio_iostat_ctx { 39 struct f2fs_sb_info *sbi; 39 struct f2fs_sb_info *sbi; 40 unsigned long submit_ts; 40 unsigned long submit_ts; 41 enum page_type type; 41 enum page_type type; 42 struct bio_post_read_ctx *post_read_ct 42 struct bio_post_read_ctx *post_read_ctx; 43 }; 43 }; 44 44 45 static inline void iostat_update_submit_ctx(st 45 static inline void iostat_update_submit_ctx(struct bio *bio, 46 enum page_type type) 46 enum page_type type) 47 { 47 { 48 struct bio_iostat_ctx *iostat_ctx = bi 48 struct bio_iostat_ctx *iostat_ctx = bio->bi_private; 49 49 50 iostat_ctx->submit_ts = jiffies; 50 iostat_ctx->submit_ts = jiffies; 51 iostat_ctx->type = type; 51 iostat_ctx->type = type; 52 } 52 } 53 53 54 static inline struct bio_post_read_ctx *get_po 54 static inline struct bio_post_read_ctx *get_post_read_ctx(struct bio *bio) 55 { 55 { 56 struct bio_iostat_ctx *iostat_ctx = bi 56 struct bio_iostat_ctx *iostat_ctx = bio->bi_private; 57 57 58 return iostat_ctx->post_read_ctx; 58 return iostat_ctx->post_read_ctx; 59 } 59 } 60 60 61 extern void iostat_update_and_unbind_ctx(struc 61 extern void iostat_update_and_unbind_ctx(struct bio *bio); 62 extern void iostat_alloc_and_bind_ctx(struct f 62 extern void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi, 63 struct bio *bio, struct bio_po 63 struct bio *bio, struct bio_post_read_ctx *ctx); 64 extern int f2fs_init_iostat_processing(void); 64 extern int f2fs_init_iostat_processing(void); 65 extern void f2fs_destroy_iostat_processing(voi 65 extern void f2fs_destroy_iostat_processing(void); 66 extern int f2fs_init_iostat(struct f2fs_sb_inf 66 extern int f2fs_init_iostat(struct f2fs_sb_info *sbi); 67 extern void f2fs_destroy_iostat(struct f2fs_sb 67 extern void f2fs_destroy_iostat(struct f2fs_sb_info *sbi); 68 #else 68 #else 69 static inline void f2fs_update_iostat(struct f 69 static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode, 70 enum iostat_type type, unsigne 70 enum iostat_type type, unsigned long long io_bytes) {} 71 static inline void iostat_update_and_unbind_ct 71 static inline void iostat_update_and_unbind_ctx(struct bio *bio) {} 72 static inline void iostat_alloc_and_bind_ctx(s 72 static inline void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi, 73 struct bio *bio, struct bio_po 73 struct bio *bio, struct bio_post_read_ctx *ctx) {} 74 static inline void iostat_update_submit_ctx(st 74 static inline void iostat_update_submit_ctx(struct bio *bio, 75 enum page_type type) {} 75 enum page_type type) {} 76 static inline struct bio_post_read_ctx *get_po 76 static inline struct bio_post_read_ctx *get_post_read_ctx(struct bio *bio) 77 { 77 { 78 return bio->bi_private; 78 return bio->bi_private; 79 } 79 } 80 static inline int f2fs_init_iostat_processing( 80 static inline int f2fs_init_iostat_processing(void) { return 0; } 81 static inline void f2fs_destroy_iostat_process 81 static inline void f2fs_destroy_iostat_processing(void) {} 82 static inline int f2fs_init_iostat(struct f2fs 82 static inline int f2fs_init_iostat(struct f2fs_sb_info *sbi) { return 0; } 83 static inline void f2fs_destroy_iostat(struct 83 static inline void f2fs_destroy_iostat(struct f2fs_sb_info *sbi) {} 84 #endif 84 #endif 85 #endif /* __F2FS_IOSTAT_H__ */ 85 #endif /* __F2FS_IOSTAT_H__ */ 86 86
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.