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: block checkpoint before moving cursegs for device aliasing
Date: Tue, 1 Dec 2026 12:32:05 +0800 [thread overview]
Message-ID: <bc777fc6-b6d1-4f57-b259-3cd336534c57@kernel.org> (raw)
In-Reply-To: <20261116000019.2299222-1-daeho43@gmail.com>
On 11/16/26 08:00, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> f2fs_ioc_reserve_dev_alias() moves the cursegs out of the range of the
> alias device with gc_lock only, before it takes f2fs_lock_op(). gc_lock
> does not keep every checkpoint away: f2fs_ioc_reserve_dev_alias() and
> f2fs_ioc_release_dev_alias() write the checkpoint at their end after they
> released gc_lock. So the cursegs can be moved while a checkpoint of
> another alias ioctl is in progress.
Oh, why we not cover f2fs_write_checkpoint() w/ gc_lock like we do for other
cases? should we fix this first?
Thanks,
>
> do_checkpoint() copies the positions of the cursegs into the checkpoint
> first and writes their summaries later. If a curseg is moved in between,
> the checkpoint does not match it. Commit b4b10061ef98 ("f2fs: refactor
> resize_fs to avoid meta updates in progress") fixed the same problem in
> f2fs_resize_fs() by taking f2fs_lock_op() before the cursegs are moved.
>
> Do the same here. Take f2fs_lock_op() first, and then move the cursegs.
>
> Test: two alias files, with a debug patch which makes do_checkpoint()
> of the release ioctl sleep after it copied the curseg positions. A
> reserve ioctl on the other alias file moved the warm data curseg during
> that sleep, and the checkpoint recorded the segment the curseg had left.
> With this patch, the curseg is moved after the checkpoint is done.
>
> Fixes: eae3faf210bd ("f2fs: support dynamic reserve/release for device aliasing")
> Cc: stable@vger.kernel.org
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
> ---
> fs/f2fs/file.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 05061254c3b2..75c51b3a4118 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -3905,13 +3905,7 @@ static int f2fs_ioc_reserve_dev_alias(struct file *filp)
> /* Reset the victim information to prevent GC from targeting the range */
> f2fs_reset_gc_victim_resource(sbi, start, end);
>
> - /* Move out cursegs from the target range */
> - for (type = CURSEG_HOT_DATA; type < NR_CURSEG_PERSIST_TYPE; type++) {
> - err = f2fs_allocate_segment_for_resize(sbi, type, start, end);
> - if (err)
> - goto out_gc_unlock;
> - }
> -
> + /* stop CP before moving cursegs, as f2fs_resize_fs() does */
> f2fs_lock_op(sbi, &lc);
>
> if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) {
> @@ -3920,6 +3914,15 @@ static int f2fs_ioc_reserve_dev_alias(struct file *filp)
> goto out_gc_unlock;
> }
>
> + /* Move out cursegs from the target range */
> + for (type = CURSEG_HOT_DATA; type < NR_CURSEG_PERSIST_TYPE; type++) {
> + err = f2fs_allocate_segment_for_resize(sbi, type, start, end);
> + if (err) {
> + f2fs_unlock_op(sbi, &lc);
> + goto out_gc_unlock;
> + }
> + }
> +
> /* do GC to move out valid blocks in the range all at once! */
> err = f2fs_gc_range(sbi, start, end, false, 0, false);
> if (err) {
prev parent reply other threads:[~2026-12-01 4:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 0:00 Daeho Jeong
2026-12-01 4:32 ` Chao Yu [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=bc777fc6-b6d1-4f57-b259-3cd336534c57@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 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®