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] f2fs: add iostat tracking for direct IO
Date: Wed, 6 May 2026 21:49:00 +0800 [thread overview]
Message-ID: <e029962f-050b-4900-aa9e-4529d775fc31@gmail.com> (raw)
In-Reply-To: <76c97aef-7c28-4d50-887b-4624d7b2c1ba@kernel.org>
在 2026/4/29 15:44, Chao Yu 写道:
> On 4/23/26 11:42, liujinbao1 wrote:
>> From: liujinbao1 <liujinbao1@xiaomi.com>
>>
>> F2FS did not collect iostat statistics for direct IO reads and writes,
>> hook submit_io to bind an iostat context and record the submission
>> timestamp, replace bi_end_io to collect IO latency on completion and
>> then call back to the original iomap_dio_bio_end_io(), to add iostat
>> tracking support for F2FS DIO.
>
> Not sure, do we need to distinguish the latency of DIO from buffered IO?
>
We don't need to distinguish DIO latency from buffered IO. The latency
is measured from
bio submit to end_io, so there should be little difference between them.
I will correct commit.
>>
>> Signed-off-by: shengyong1 <shengyong1@xiaomi.com>
>> Signed-off-by: liujinbao1 <liujinbao1@xiaomi.com>
>> ---
>> fs/f2fs/file.c | 27 +++++++++++++++++++++++++++
>> fs/f2fs/iostat.c | 2 +-
>> 2 files changed, 28 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index 2c4880f24b54..fcf725931fd8 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -4774,6 +4774,16 @@ static bool f2fs_should_use_dio(struct inode
>> *inode, struct kiocb *iocb,
>> return true;
>> }
>> +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 int f2fs_dio_read_end_io(struct kiocb *iocb, ssize_t size,
>> int error,
>> unsigned int flags)
>> {
>> @@ -4786,8 +4796,21 @@ 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);
>> + 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;
>> + 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)
>> @@ -5064,8 +5087,12 @@ static void f2fs_dio_write_submit_io(const
>> struct iomap_iter *iter,
>> struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
>> enum log_type type = f2fs_rw_hint_to_seg_type(sbi,
>> inode->i_write_hint);
>> enum temp_type temp = f2fs_get_segment_temp(sbi, type);
>> + void *bi_private = bio->bi_private;
>> bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi, DATA, temp);
>> + iostat_alloc_and_bind_ctx(sbi, bio, bi_private);
>> + iostat_update_submit_ctx(bio, DATA);
>> + bio->bi_end_io = f2fs_dio_end_bio;
>> blk_crypto_submit_bio(bio);
>
> There are duplicated codes in f2fs_dio_write_submit_io() and
> f2fs_dio_read_submit_io(),
> can we introduce a common function to wrap those codes?
OK,thanks
>
> Thanks,
>
>> }
>> diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c
>> index f8703038e1d8..57d2c3e68a1b 100644
>> --- a/fs/f2fs/iostat.c
>> +++ b/fs/f2fs/iostat.c
>> @@ -218,7 +218,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)
>> 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-06 13:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 3:42 [f2fs-dev] [PATCH] f2fs: add iostat tracking for direct IO liujinbao1
2026-04-29 7:44 ` Chao Yu via Linux-f2fs-devel
2026-05-06 13:49 ` 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=e029962f-050b-4900-aa9e-4529d775fc31@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