* [PATCH v2] f2fs: avoid setting SBI_NEED_FSCK on transient resize failure
@ 2026-08-20 16:43 Daeho Jeong
2026-08-20 23:52 ` [f2fs-dev] " Chao Yu
2026-08-21 15:50 ` patchwork-bot+f2fs
0 siblings, 2 replies; 3+ messages in thread
From: Daeho Jeong @ 2026-08-20 16:43 UTC (permalink / raw)
To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong, Sunmin Jeong
From: Daeho Jeong <daehojeong@google.com>
When free_segment_range() fails in f2fs_resize_fs(), no on-disk
superblock or filesystem metadata has been modified yet, and
free_segment_range() safely restores all in-memory counters before
returning.
However, the current error recovery path unconditionally sets the
SBI_NEED_FSCK flag and prints a scary error message on any error,
forcing an unnecessary and time-consuming fsck.f2fs repair on the
subsequent mount/reboot.
Fix this by separating the error recovery path with a dedicated
recover_user_blocks label to bypass setting SBI_NEED_FSCK on
free_segment_range() failures.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Sunmin Jeong <s_min.jeong@samsung.com>
---
v2: separate error recovery path to bypass SBI_NEED_FSCK on
free_segment_range() failure and add f2fs_bug_on() in recover_out.
---
fs/f2fs/gc.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index c4da2f31805b..3215630c353d 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -2440,7 +2440,7 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)
set_sbi_flag(sbi, SBI_IS_RESIZEFS);
err = free_segment_range(sbi, secs, false);
if (err)
- goto recover_out;
+ goto recover_user_blocks;
update_sb_metadata(sbi, -secs);
@@ -2462,11 +2462,14 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)
f2fs_commit_super(sbi, false);
}
recover_out:
- clear_sbi_flag(sbi, SBI_IS_RESIZEFS);
if (err) {
+ f2fs_bug_on(sbi, err == -EAGAIN);
set_sbi_flag(sbi, SBI_NEED_FSCK);
f2fs_err(sbi, "resize_fs failed, should run fsck to repair!");
-
+ }
+recover_user_blocks:
+ clear_sbi_flag(sbi, SBI_IS_RESIZEFS);
+ if (err) {
spin_lock(&sbi->stat_lock);
sbi->user_block_count += shrunk_blocks;
spin_unlock(&sbi->stat_lock);
--
2.55.0.737.g08866a6d13-goog
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [f2fs-dev] [PATCH v2] f2fs: avoid setting SBI_NEED_FSCK on transient resize failure
2026-08-20 16:43 [PATCH v2] f2fs: avoid setting SBI_NEED_FSCK on transient resize failure Daeho Jeong
@ 2026-08-20 23:52 ` Chao Yu
2026-08-21 15:50 ` patchwork-bot+f2fs
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2026-08-20 23:52 UTC (permalink / raw)
To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team
Cc: chao, Daeho Jeong
On 8/21/26 00:43, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> When free_segment_range() fails in f2fs_resize_fs(), no on-disk
> superblock or filesystem metadata has been modified yet, and
> free_segment_range() safely restores all in-memory counters before
> returning.
>
> However, the current error recovery path unconditionally sets the
> SBI_NEED_FSCK flag and prints a scary error message on any error,
> forcing an unnecessary and time-consuming fsck.f2fs repair on the
> subsequent mount/reboot.
>
> Fix this by separating the error recovery path with a dedicated
> recover_user_blocks label to bypass setting SBI_NEED_FSCK on
> free_segment_range() failures.
>
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
> Signed-off-by: Sunmin Jeong <s_min.jeong@samsung.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: avoid setting SBI_NEED_FSCK on transient resize failure
2026-08-20 16:43 [PATCH v2] f2fs: avoid setting SBI_NEED_FSCK on transient resize failure Daeho Jeong
2026-08-20 23:52 ` [f2fs-dev] " Chao Yu
@ 2026-08-21 15:50 ` patchwork-bot+f2fs
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs @ 2026-08-21 15:50 UTC (permalink / raw)
To: Daeho Jeong; +Cc: linux-kernel, linux-f2fs-devel, kernel-team, daehojeong
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Thu, 20 Aug 2026 09:43:40 -0700 you wrote:
> From: Daeho Jeong <daehojeong@google.com>
>
> When free_segment_range() fails in f2fs_resize_fs(), no on-disk
> superblock or filesystem metadata has been modified yet, and
> free_segment_range() safely restores all in-memory counters before
> returning.
>
> [...]
Here is the summary with links:
- [f2fs-dev,v2] f2fs: avoid setting SBI_NEED_FSCK on transient resize failure
https://git.kernel.org/jaegeuk/f2fs/c/258c95150c26
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-21 15:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-20 16:43 [PATCH v2] f2fs: avoid setting SBI_NEED_FSCK on transient resize failure Daeho Jeong
2026-08-20 23:52 ` [f2fs-dev] " Chao Yu
2026-08-21 15:50 ` patchwork-bot+f2fs
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®