* [PATCH] f2fs: fix to bail out in get_new_segment()
@ 2025-04-22 11:56 Chao Yu
2025-04-28 22:40 ` [f2fs-dev] " patchwork-bot+f2fs
0 siblings, 1 reply; 2+ messages in thread
From: Chao Yu @ 2025-04-22 11:56 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu
------------[ cut here ]------------
WARNING: CPU: 3 PID: 579 at fs/f2fs/segment.c:2832 new_curseg+0x5e8/0x6dc
pc : new_curseg+0x5e8/0x6dc
Call trace:
new_curseg+0x5e8/0x6dc
f2fs_allocate_data_block+0xa54/0xe28
do_write_page+0x6c/0x194
f2fs_do_write_node_page+0x38/0x78
__write_node_page+0x248/0x6d4
f2fs_sync_node_pages+0x524/0x72c
f2fs_write_checkpoint+0x4bc/0x9b0
__checkpoint_and_complete_reqs+0x80/0x244
issue_checkpoint_thread+0x8c/0xec
kthread+0x114/0x1bc
ret_from_fork+0x10/0x20
get_new_segment() detects inconsistent status in between free_segmap
and free_secmap, let's record such error into super block, and bail
out get_new_segment() instead of continue using the segment.
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/segment.c | 6 +++++-
include/linux/f2fs_fs.h | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 34382447f717..037d06d58fda 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2842,7 +2842,11 @@ static int get_new_segment(struct f2fs_sb_info *sbi,
}
got_it:
/* set it as dirty segment in free segmap */
- f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap));
+ if (test_bit(segno, free_i->free_segmap)) {
+ ret = -EFSCORRUPTED;
+ f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_CORRUPTED_FREE_BITMAP);
+ goto out_unlock;
+ }
/* no free section in conventional device or conventional zone */
if (new_sec && pinning &&
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index c24f8bc01045..5206d63b3386 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -78,6 +78,7 @@ enum stop_cp_reason {
STOP_CP_REASON_UPDATE_INODE,
STOP_CP_REASON_FLUSH_FAIL,
STOP_CP_REASON_NO_SEGMENT,
+ STOP_CP_REASON_CORRUPTED_FREE_BITMAP,
STOP_CP_REASON_MAX,
};
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: fix to bail out in get_new_segment()
2025-04-22 11:56 [PATCH] f2fs: fix to bail out in get_new_segment() Chao Yu
@ 2025-04-28 22:40 ` patchwork-bot+f2fs
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+f2fs @ 2025-04-28 22:40 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, linux-kernel, linux-f2fs-devel
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Tue, 22 Apr 2025 19:56:38 +0800 you wrote:
> ------------[ cut here ]------------
> WARNING: CPU: 3 PID: 579 at fs/f2fs/segment.c:2832 new_curseg+0x5e8/0x6dc
> pc : new_curseg+0x5e8/0x6dc
> Call trace:
> new_curseg+0x5e8/0x6dc
> f2fs_allocate_data_block+0xa54/0xe28
> do_write_page+0x6c/0x194
> f2fs_do_write_node_page+0x38/0x78
> __write_node_page+0x248/0x6d4
> f2fs_sync_node_pages+0x524/0x72c
> f2fs_write_checkpoint+0x4bc/0x9b0
> __checkpoint_and_complete_reqs+0x80/0x244
> issue_checkpoint_thread+0x8c/0xec
> kthread+0x114/0x1bc
> ret_from_fork+0x10/0x20
>
> [...]
Here is the summary with links:
- [f2fs-dev] f2fs: fix to bail out in get_new_segment()
https://git.kernel.org/jaegeuk/f2fs/c/9cada264501c
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] 2+ messages in thread
end of thread, other threads:[~2025-04-28 22:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22 11:56 [PATCH] f2fs: fix to bail out in get_new_segment() Chao Yu
2025-04-28 22:40 ` [f2fs-dev] " 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