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>,
stable@vger.kernel.org
Subject: Re: [f2fs-dev] [PATCH] f2fs: write a checkpoint in fsync after the warm node log is moved
Date: Tue, 1 Dec 2026 15:58:34 +0800 [thread overview]
Message-ID: <cbd46b3b-267b-49df-bd50-22bb52fe9204@kernel.org> (raw)
In-Reply-To: <20261115213540.2100311-1-daeho43@gmail.com>
On 11/16/26 05:35, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> Roll-forward recovery finds fsynced node blocks by following the chain in
> the warm node log. It starts from the next free block of the log recorded
> in the last checkpoint, and each node block has the address of the next
> one in its footer. f2fs_allocate_data_block() fills the footer after it
> moves the log to a new segment, so the chain is kept when a segment is
> full.
>
> f2fs_allocate_segment_for_resize() moves the log out of the range to be
> removed in the middle of a segment. No node block is allocated there, so
> the last node block in the old segment still points to the next block of
> the old segment, and nothing points to the new one. The node blocks
> written after that cannot be found by recovery until the next checkpoint.
>
> For example, with F2FS_IOC_RESIZE_FS:
>
> - fsync(A) writes a node block to segment X, which is in the range.
> - resize moves the warm node log from segment X to segment Y.
> - fsync(B) writes a node block to segment Y and returns 0.
> - after a sudden power-off, recovery follows the chain in segment X,
> recovers A and stops there. B is lost.
>
> Checkpoint is blocked during the first GC pass of resize, so this lasts
> until the pass is done. f2fs_ioc_reserve_dev_alias() moves the logs in
> the same way.
>
> Set SBI_NEED_CP when the warm node log is moved, so that fsync writes a
> checkpoint instead of relying on the chain. The next checkpoint clears
> the flag and starts a new chain from the new segment. Such an fsync waits
> for the first GC pass of resize, since checkpoint is blocked until then.
>
> An fsync which has already passed need_do_checkpoint() can still write
> its node blocks after the log is moved. So check the flag again after
> the node blocks are written, and write a checkpoint in that case, too.
>
> Test: four tasks create and fsync files while F2FS_IOC_RESIZE_FS shrinks
> the filesystem, and the machine is rebooted by sysrq-b 1.5 seconds after
> the log is moved. Without this patch, all the files whose fsync returned
> after the move were lost (454 and 437 files in two runs). With this
> patch, no fsync returned in that window and no file with a returned
> fsync was lost. The second check was tested with a debug patch which
> delays an fsync between need_do_checkpoint() and its node writes.
>
> Fixes: b4b10061ef98 ("f2fs: refactor resize_fs to avoid meta updates in progress")
> Cc: stable@vger.kernel.org
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Daeho Jeong <daeho43@gmail.com>,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: Daeho Jeong <daehojeong@google.com>, stable@vger.kernel.org
Subject: Re: [f2fs-dev] [PATCH] f2fs: write a checkpoint in fsync after the warm node log is moved
Date: Tue, 1 Dec 2026 15:58:34 +0800 [thread overview]
Message-ID: <cbd46b3b-267b-49df-bd50-22bb52fe9204@kernel.org> (raw)
In-Reply-To: <20261115213540.2100311-1-daeho43@gmail.com>
On 11/16/26 05:35, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> Roll-forward recovery finds fsynced node blocks by following the chain in
> the warm node log. It starts from the next free block of the log recorded
> in the last checkpoint, and each node block has the address of the next
> one in its footer. f2fs_allocate_data_block() fills the footer after it
> moves the log to a new segment, so the chain is kept when a segment is
> full.
>
> f2fs_allocate_segment_for_resize() moves the log out of the range to be
> removed in the middle of a segment. No node block is allocated there, so
> the last node block in the old segment still points to the next block of
> the old segment, and nothing points to the new one. The node blocks
> written after that cannot be found by recovery until the next checkpoint.
>
> For example, with F2FS_IOC_RESIZE_FS:
>
> - fsync(A) writes a node block to segment X, which is in the range.
> - resize moves the warm node log from segment X to segment Y.
> - fsync(B) writes a node block to segment Y and returns 0.
> - after a sudden power-off, recovery follows the chain in segment X,
> recovers A and stops there. B is lost.
>
> Checkpoint is blocked during the first GC pass of resize, so this lasts
> until the pass is done. f2fs_ioc_reserve_dev_alias() moves the logs in
> the same way.
>
> Set SBI_NEED_CP when the warm node log is moved, so that fsync writes a
> checkpoint instead of relying on the chain. The next checkpoint clears
> the flag and starts a new chain from the new segment. Such an fsync waits
> for the first GC pass of resize, since checkpoint is blocked until then.
>
> An fsync which has already passed need_do_checkpoint() can still write
> its node blocks after the log is moved. So check the flag again after
> the node blocks are written, and write a checkpoint in that case, too.
>
> Test: four tasks create and fsync files while F2FS_IOC_RESIZE_FS shrinks
> the filesystem, and the machine is rebooted by sysrq-b 1.5 seconds after
> the log is moved. Without this patch, all the files whose fsync returned
> after the move were lost (454 and 437 files in two runs). With this
> patch, no fsync returned in that window and no file with a returned
> fsync was lost. The second check was tested with a debug patch which
> delays an fsync between need_do_checkpoint() and its node writes.
>
> Fixes: b4b10061ef98 ("f2fs: refactor resize_fs to avoid meta updates in progress")
> Cc: stable@vger.kernel.org
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2026-12-01 7:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 21:35 [PATCH] f2fs: write a checkpoint in fsync after the warm node log is moved Daeho Jeong
2026-11-15 21:35 ` [f2fs-dev] " Daeho Jeong
2026-12-01 7:58 ` Chao Yu [this message]
2026-12-01 7:58 ` Chao Yu via Linux-f2fs-devel
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=cbd46b3b-267b-49df-bd50-22bb52fe9204@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 \
--cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.