From: Daeho Jeong <daeho43@gmail.com>
To: 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: [PATCH] f2fs: block checkpoint before moving cursegs for device aliasing
Date: Sun, 15 Nov 2026 16:00:19 -0800 [thread overview]
Message-ID: <20261116000019.2299222-1-daeho43@gmail.com> (raw)
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.
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) {
--
2.56.0.611.g1030f0b940-goog
reply other threads:[~2026-11-16 0:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261116000019.2299222-1-daeho43@gmail.com \
--to=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®