From: Chao Yu <chao@kernel.org>
To: Wenjie Qi <qwjhust@gmail.com>, jaegeuk@kernel.org
Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, qiwenjie@xiaomi.com
Subject: Re: [PATCH] f2fs: skip clean inode update during fsync
Date: Mon, 15 Jun 2026 16:03:58 +0800 [thread overview]
Message-ID: <7a1d2390-8416-4e1d-859e-b4ac73c0894a@kernel.org> (raw)
In-Reply-To: <20260528140954.3205736-1-qiwenjie@xiaomi.com>
On 5/28/26 22:09, Wenjie Qi wrote:
> f2fs_do_sync_file() calls f2fs_skip_inode_update() before deciding
> whether it has to write an inode block and continue into the recovery
> info/flush path.
>
> For a full fsync, f2fs_skip_inode_update() currently returns false when
> FI_AUTO_RECOVER is not set. That makes fsync on an already clean file
> call f2fs_write_inode(). f2fs_write_inode() then returns immediately if
> the in-memory timestamps match the inode block and FI_DIRTY_INODE is not
> set, but f2fs_do_sync_file() still continues through go_write and may end
> at f2fs_issue_flush().
>
> Avoid that unnecessary path for clean, time-consistent inodes without
> FI_AUTO_RECOVER. Keep the existing conservative checks for keep-size
> files and non-block-aligned i_size before allowing the skip, and leave the
> FI_AUTO_RECOVER path unchanged.
>
> On a QEMU/KASAN test VM, repeated fsync() on an existing clean F2FS file
> improved from about 35.7 us/fsync to about 1.13 us/fsync. The baseline
> issued one flush per fsync, while the patched kernel kept the F2FS flush
> count unchanged over 140000 clean fsync calls.
>
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
> ---
> fs/f2fs/f2fs.h | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 9f24287de4c3..ebd485abecb4 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3668,11 +3668,13 @@ static inline bool f2fs_skip_inode_update(struct inode *inode, int dsync)
> spin_unlock(&sbi->inode_lock[DIRTY_META]);
> return ret;
> }
> - if (!is_inode_flag_set(inode, FI_AUTO_RECOVER) ||
> - file_keep_isize(inode) ||
> - i_size_read(inode) & ~PAGE_MASK)
> + if (file_keep_isize(inode) || i_size_read(inode) & ~PAGE_MASK)
> return false;
>
> + if (!is_inode_flag_set(inode, FI_AUTO_RECOVER))
> + return f2fs_is_time_consistent(inode) &&
> + !is_inode_flag_set(inode, FI_DIRTY_INODE);
IIUC, without this additional check condition, f2fs_write_inode() will skip to update
inode page as well according to the same check condition, so, do you know why will we
have so many benefits on fsync?
int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
{
...
/*
* atime could be updated without dirtying f2fs inode in lazytime mode
*/
if (f2fs_is_time_consistent(inode) &&
!is_inode_flag_set(inode, FI_DIRTY_INODE))
return 0;
Thanks,
> +
> if (!f2fs_is_time_consistent(inode))
> return false;
>
next prev parent reply other threads:[~2026-06-15 8:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 14:09 Wenjie Qi
2026-06-15 8:03 ` Chao Yu [this message]
2026-06-16 13:45 ` Wenjie Qi
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=7a1d2390-8416-4e1d-859e-b4ac73c0894a@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=qiwenjie@xiaomi.com \
--cc=qwjhust@gmail.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
all inboxes | Powered by JetHome®