From: liujinbao1 <jinbaoliu365@gmail.com>
To: Chao Yu <chao@kernel.org>, jaegeuk@kernel.org
Cc: shengyong1 <shengyong1@xiaomi.com>,
liujinbao1 <liujinbao1@xiaomi.com>,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: add iostat latency tracking for direct IO
Date: Wed, 13 May 2026 21:57:10 +0800 [thread overview]
Message-ID: <bbc0de21-4d5b-4eeb-baa3-79418c53bd2c@gmail.com> (raw)
In-Reply-To: <3f01a4cb-349a-47b0-8282-48dbc36c1797@kernel.org>
在 2026/5/9 17:20, Chao Yu 写道:
> On 5/8/26 21:59, liujinbao1 wrote:
>> From: liujinbao1 <liujinbao1@xiaomi.com>
>>
>> F2FS did not collect iostat latency for direct IO reads and writes,
>> hook iomap_dio_ops.submit_io to bind an iostat context and record the
>> submission timestamp. Replace bi_end_io with f2fs_dio_end_bio() to
>> collect IO latency on completion before calling back to the original
>> iomap_dio_bio_end_io(), to add iostat latency tracking support for
>> F2FS DIO.
>>
>> Signed-off-by: shengyong1 <shengyong1@xiaomi.com>
>> Signed-off-by: liujinbao1 <liujinbao1@xiaomi.com>
>> ---
>> v2:
>> - add f2fs_dio_iostat_start() to avoid duplicated code
>> and CONFIG_F2FS_IOSTAT guard
>> ---
>> fs/f2fs/file.c | 35 +++++++++++++++++++++++++++++++++++
>> fs/f2fs/iostat.c | 2 +-
>> 2 files changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index 091a9db29228..d35e3cf158bf 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -4790,6 +4790,30 @@ static bool f2fs_should_use_dio(struct inode
>> *inode, struct kiocb *iocb,
>> return true;
>> }
>> +#ifdef CONFIG_F2FS_IOSTAT
>> +static void f2fs_dio_end_bio(struct bio *bio)
>> +{
>> + struct bio_iostat_ctx *iostat_ctx = bio->bi_private;
>> + void *orig_bi_private = iostat_ctx->post_read_ctx;
>> +
>> + iostat_update_and_unbind_ctx(bio);
>> + bio->bi_private = orig_bi_private;
>> + iomap_dio_bio_end_io(bio);
>> +}
>> +
>> +static void f2fs_dio_iostat_start(struct f2fs_sb_info *sbi, struct
>> bio *bio)
>> +{
>> + void *bi_private = bio->bi_private;
>> +
>> + iostat_alloc_and_bind_ctx(sbi, bio, bi_private);
>> + iostat_update_submit_ctx(bio, DATA);
>> + bio->bi_end_io = f2fs_dio_end_bio;
>> +}
>> +#else
>> +static inline void f2fs_dio_iostat_start(struct f2fs_sb_info *sbi,
>> + struct bio *bio) {}
>> +#endif
>> +
>> static int f2fs_dio_read_end_io(struct kiocb *iocb, ssize_t size,
>> int error,
>> unsigned int flags)
>> {
>> @@ -4802,8 +4826,18 @@ static int f2fs_dio_read_end_io(struct kiocb
>> *iocb, ssize_t size, int error,
>> return 0;
>> }
>> +static void f2fs_dio_read_submit_io(const struct iomap_iter *iter,
>> + struct bio *bio, loff_t file_offset)
>> +{
>> + struct f2fs_sb_info *sbi = F2FS_I_SB(iter->inode);
>> +
>> + f2fs_dio_iostat_start(sbi, bio);
>> + blk_crypto_submit_bio(bio);
>> +}
>> +
>> static const struct iomap_dio_ops f2fs_iomap_dio_read_ops = {
>> .end_io = f2fs_dio_read_end_io,
>> + .submit_io = f2fs_dio_read_submit_io,
>> };
>> static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct
>> iov_iter *to)
>> @@ -5082,6 +5116,7 @@ static void f2fs_dio_write_submit_io(const
>> struct iomap_iter *iter,
>> enum temp_type temp = f2fs_get_segment_temp(sbi, type);
>> bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi, DATA, temp);
>> + f2fs_dio_iostat_start(sbi, bio);
>> blk_crypto_submit_bio(bio);
>> }
>> diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c
>> index ae265e3e9b2c..232fdec036c1 100644
>> --- a/fs/f2fs/iostat.c
>> +++ b/fs/f2fs/iostat.c
>> @@ -254,7 +254,7 @@ static inline void __update_iostat_latency(struct
>> bio_iostat_ctx *iostat_ctx,
>> struct iostat_lat_info *io_lat = sbi->iostat_io_lat;
>> unsigned long flags;
>> - if (!sbi->iostat_enable)
>> + if (!sbi->iostat_enable || iostat_ctx->submit_ts == 0)
>
> Which path we will see zeroed .submit_ts?
>
> Thanks,
>
After careful investigation, this scenario should not exist. I will
modify the code.
thanks
>> return;
>> ts_diff = jiffies - iostat_ctx->submit_ts;
>
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
prev parent reply other threads:[~2026-05-13 13:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 13:59 [f2fs-dev] [PATCH v2] f2fs: add iostat latency tracking for direct IO liujinbao1
2026-05-09 9:20 ` Chao Yu via Linux-f2fs-devel
2026-05-13 13:57 ` liujinbao1 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bbc0de21-4d5b-4eeb-baa3-79418c53bd2c@gmail.com \
--to=jinbaoliu365@gmail.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=liujinbao1@xiaomi.com \
--cc=shengyong1@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox