From: Chao Yu <chao@kernel.org>
To: Daeho Jeong <daeho43@gmail.com>,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: chao@kernel.org, Daeho Jeong <daehojeong@google.com>
Subject: Re: [f2fs-dev] [PATCH] f2fs: write the directory inode in fsync before checkpoint
Date: Fri, 9 Oct 2026 17:03:24 +0800 [thread overview]
Message-ID: <411bd479-f3ba-48cd-9b96-ec017c685b1c@kernel.org> (raw)
In-Reply-To: <20261007223608.2158904-1-daeho43@gmail.com>
On 10/8/26 06:36, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> fsync() on a directory is done by a checkpoint, but the checkpoint
> does not write timestamp-only inode updates. Since commit 7c45729a4d6d
> ("f2fs: keep dirty inodes selectively for checkpoint"), such updates
> are marked with sync=false and left to inode writeback on purpose.
>
> fsync() on a regular file calls f2fs_write_inode() first when the
> inode is dirty, but fsync() on a directory goes to the checkpoint
> directly and misses it. So if the last change to a directory only
> updated its timestamps, e.g. unlinking a file in it, the new mtime is
> lost after a sudden power off even though fsync() returned. generic/547
> fails sometimes because of this.
Has 9ec09d5f4b31 ("f2fs: dirty directory inodes on mtime/ctime update") fixed
this issue?
Thanks,
>
> Call f2fs_write_inode() for a directory before the checkpoint, as the
> regular file path does. The inode block becomes dirty and is written by
> the same checkpoint, so no extra checkpoint or flush is added.
> Timestamp-only updates without fsync() are still not written by the
> checkpoint.
>
> Fixes: 7c45729a4d6d ("f2fs: keep dirty inodes selectively for checkpoint")
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
> ---
> fs/f2fs/file.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 56c686b8580..b012cc22307 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -351,8 +351,15 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
>
> trace_f2fs_sync_file_enter(inode);
>
> - if (S_ISDIR(inode->i_mode))
> + if (S_ISDIR(inode->i_mode)) {
> + /*
> + * Checkpoint writes only the inodes on the dirty meta list.
> + * Timestamp updates of a directory, e.g. by unlinking a file
> + * in it, do not put it on the list, so write it here.
> + */
> + f2fs_write_inode(inode, NULL);
> goto go_write;
> + }
>
> /* if fdatasync is triggered, let's do in-place-update */
> if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)
next prev parent reply other threads:[~2026-10-09 9:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 22:36 Daeho Jeong
2026-10-09 9:03 ` Chao Yu [this message]
2026-10-09 15:09 ` [f2fs-dev] " Daeho Jeong
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=411bd479-f3ba-48cd-9b96-ec017c685b1c@kernel.org \
--to=chao@kernel.org \
--cc=daeho43@gmail.com \
--cc=daehojeong@google.com \
--cc=kernel-team@android.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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®