Message ID | 20230201104703.31008-2-frank.li@vivo.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [f2fs-dev,v4,1/2] f2fs: use iostat_lat_type directly as a parameter in the iostat_update_and_unbind_ctx() | expand |
I combined two patches into one w/ Chao's reviewed-by. Let me know if you have other concern. On 02/01, Yangtao Li wrote: > From: Chao Yu <chao@kernel.org> > > Parsing sync/rw type from bio inside iostat_update_and_unbind_ctx() > to avoid unnecessary parameters. > > Signed-off-by: Chao Yu <chao@kernel.org> > [Yangtao: remove lat_type check] > Signed-off-by: Yangtao Li <frank.li@vivo.com> > --- > change: > -remove lat_type check > fs/f2fs/data.c | 4 ++-- > fs/f2fs/iostat.c | 19 ++++++++++--------- > fs/f2fs/iostat.h | 4 ++-- > 3 files changed, 14 insertions(+), 13 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index 86fc28adc970..82e326c0e11d 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -292,7 +292,7 @@ static void f2fs_read_end_io(struct bio *bio) > struct bio_post_read_ctx *ctx; > bool intask = in_task(); > > - iostat_update_and_unbind_ctx(bio, READ_IO); > + iostat_update_and_unbind_ctx(bio); > ctx = bio->bi_private; > > if (time_to_inject(sbi, FAULT_READ_IO)) > @@ -330,7 +330,7 @@ static void f2fs_write_end_io(struct bio *bio) > struct bio_vec *bvec; > struct bvec_iter_all iter_all; > > - iostat_update_and_unbind_ctx(bio, bio->bi_opf & REQ_SYNC ? WRITE_SYNC_IO : WRITE_ASYNC_IO); > + iostat_update_and_unbind_ctx(bio); > sbi = bio->bi_private; > > if (time_to_inject(sbi, FAULT_WRITE_IO)) > diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c > index c767a2e7d5a9..3d5bfb1ad585 100644 > --- a/fs/f2fs/iostat.c > +++ b/fs/f2fs/iostat.c > @@ -228,11 +228,6 @@ static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx, > return; > } > > - if (lat_type >= MAX_IO_TYPE) { > - f2fs_warn(sbi, "%s: %d over MAX_IO_TYPE", __func__, lat_type); > - return; > - } > - > spin_lock_irqsave(&sbi->iostat_lat_lock, flags); > io_lat->sum_lat[lat_type][page_type] += ts_diff; > io_lat->bio_cnt[lat_type][page_type]++; > @@ -241,14 +236,20 @@ static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx, > spin_unlock_irqrestore(&sbi->iostat_lat_lock, flags); > } > > -void iostat_update_and_unbind_ctx(struct bio *bio, enum iostat_lat_type lat_type) > +void iostat_update_and_unbind_ctx(struct bio *bio) > { > struct bio_iostat_ctx *iostat_ctx = bio->bi_private; > + enum iostat_lat_type lat_type; > > - if (lat_type == READ_IO) > - bio->bi_private = iostat_ctx->post_read_ctx; > - else > + if (op_is_write(bio_op(bio))) { > + lat_type = bio->bi_opf & REQ_SYNC ? > + WRITE_SYNC_IO : WRITE_ASYNC_IO; > bio->bi_private = iostat_ctx->sbi; > + } else { > + lat_type = READ_IO; > + bio->bi_private = iostat_ctx->post_read_ctx; > + } > + > __update_iostat_latency(iostat_ctx, lat_type); > mempool_free(iostat_ctx, bio_iostat_ctx_pool); > } > diff --git a/fs/f2fs/iostat.h b/fs/f2fs/iostat.h > index 1f827a2fe6b2..eb99d05cf272 100644 > --- a/fs/f2fs/iostat.h > +++ b/fs/f2fs/iostat.h > @@ -58,7 +58,7 @@ static inline struct bio_post_read_ctx *get_post_read_ctx(struct bio *bio) > return iostat_ctx->post_read_ctx; > } > > -extern void iostat_update_and_unbind_ctx(struct bio *bio, enum iostat_lat_type type); > +extern void iostat_update_and_unbind_ctx(struct bio *bio); > extern void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi, > struct bio *bio, struct bio_post_read_ctx *ctx); > extern int f2fs_init_iostat_processing(void); > @@ -68,7 +68,7 @@ extern void f2fs_destroy_iostat(struct f2fs_sb_info *sbi); > #else > static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode, > enum iostat_type type, unsigned long long io_bytes) {} > -static inline void iostat_update_and_unbind_ctx(struct bio *bio, enum iostat_lat_type type) {} > +static inline void iostat_update_and_unbind_ctx(struct bio *bio) {} > static inline void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi, > struct bio *bio, struct bio_post_read_ctx *ctx) {} > static inline void iostat_update_submit_ctx(struct bio *bio, > -- > 2.25.1
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 86fc28adc970..82e326c0e11d 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -292,7 +292,7 @@ static void f2fs_read_end_io(struct bio *bio) struct bio_post_read_ctx *ctx; bool intask = in_task(); - iostat_update_and_unbind_ctx(bio, READ_IO); + iostat_update_and_unbind_ctx(bio); ctx = bio->bi_private; if (time_to_inject(sbi, FAULT_READ_IO)) @@ -330,7 +330,7 @@ static void f2fs_write_end_io(struct bio *bio) struct bio_vec *bvec; struct bvec_iter_all iter_all; - iostat_update_and_unbind_ctx(bio, bio->bi_opf & REQ_SYNC ? WRITE_SYNC_IO : WRITE_ASYNC_IO); + iostat_update_and_unbind_ctx(bio); sbi = bio->bi_private; if (time_to_inject(sbi, FAULT_WRITE_IO)) diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c index c767a2e7d5a9..3d5bfb1ad585 100644 --- a/fs/f2fs/iostat.c +++ b/fs/f2fs/iostat.c @@ -228,11 +228,6 @@ static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx, return; } - if (lat_type >= MAX_IO_TYPE) { - f2fs_warn(sbi, "%s: %d over MAX_IO_TYPE", __func__, lat_type); - return; - } - spin_lock_irqsave(&sbi->iostat_lat_lock, flags); io_lat->sum_lat[lat_type][page_type] += ts_diff; io_lat->bio_cnt[lat_type][page_type]++; @@ -241,14 +236,20 @@ static inline void __update_iostat_latency(struct bio_iostat_ctx *iostat_ctx, spin_unlock_irqrestore(&sbi->iostat_lat_lock, flags); } -void iostat_update_and_unbind_ctx(struct bio *bio, enum iostat_lat_type lat_type) +void iostat_update_and_unbind_ctx(struct bio *bio) { struct bio_iostat_ctx *iostat_ctx = bio->bi_private; + enum iostat_lat_type lat_type; - if (lat_type == READ_IO) - bio->bi_private = iostat_ctx->post_read_ctx; - else + if (op_is_write(bio_op(bio))) { + lat_type = bio->bi_opf & REQ_SYNC ? + WRITE_SYNC_IO : WRITE_ASYNC_IO; bio->bi_private = iostat_ctx->sbi; + } else { + lat_type = READ_IO; + bio->bi_private = iostat_ctx->post_read_ctx; + } + __update_iostat_latency(iostat_ctx, lat_type); mempool_free(iostat_ctx, bio_iostat_ctx_pool); } diff --git a/fs/f2fs/iostat.h b/fs/f2fs/iostat.h index 1f827a2fe6b2..eb99d05cf272 100644 --- a/fs/f2fs/iostat.h +++ b/fs/f2fs/iostat.h @@ -58,7 +58,7 @@ static inline struct bio_post_read_ctx *get_post_read_ctx(struct bio *bio) return iostat_ctx->post_read_ctx; } -extern void iostat_update_and_unbind_ctx(struct bio *bio, enum iostat_lat_type type); +extern void iostat_update_and_unbind_ctx(struct bio *bio); extern void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi, struct bio *bio, struct bio_post_read_ctx *ctx); extern int f2fs_init_iostat_processing(void); @@ -68,7 +68,7 @@ extern void f2fs_destroy_iostat(struct f2fs_sb_info *sbi); #else static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode, enum iostat_type type, unsigned long long io_bytes) {} -static inline void iostat_update_and_unbind_ctx(struct bio *bio, enum iostat_lat_type type) {} +static inline void iostat_update_and_unbind_ctx(struct bio *bio) {} static inline void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi, struct bio *bio, struct bio_post_read_ctx *ctx) {} static inline void iostat_update_submit_ctx(struct bio *bio,