From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH] fsck.f2fs: fix to avoid selecting current section in find_next_free_block
Date: Wed, 9 Sep 2026 13:06:34 +0800 [thread overview]
Message-ID: <20260909050634.3513267-1-chao@kernel.org> (raw)
From: Chao Yu <chao@kernel.org>
In find_next_free_block(), when searching for a free block or allocating a
new section, it checks:
if (!(get_sb(feature) & F2FS_FEATURE_RO) &&
IS_CUR_SEGNO(sbi, segno))
goto next_segment;
However, when large section is enabled (segs_per_sec > 1), checking only
IS_CUR_SEGNO(sbi, segno) is insufficient. If segment 0 of a section is
empty, but segment 1 is an active curseg (e.g. CURSEG_WARM_NODE),
IS_CUR_SEGNO(sbi, segno) evaluates to false.
Consequently, find_next_free_block() can treat the section as completely
free and call set_section_type(sbi, segno, want_type). This overwrites the
segment type of all segments in the section, clobbering active curseg
segments (e.g. from NODE to DATA) and leading to an assertion crash in
update_data_blkaddr():
[update_data_blkaddr:2527] NAT and SIT is inconsistent: ino: 4, nid: 23, blkaddr: 21925780, segtype: 1
[ASSERT] (update_data_blkaddr:2529) 0
Fix this by using IS_CUR_SECNO(sbi, GET_SEC_FROM_SEG(sbi, segno)) to ensure
that any segment belonging to an active current section is skipped.
Signed-off-by: Chao Yu <chao@kernel.org>
---
fsck/mount.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fsck/mount.c b/fsck/mount.c
index a202f3d..2fd8e1c 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -3149,7 +3149,7 @@ next_segment:
continue;
}
if (!(get_sb(feature) & F2FS_FEATURE_RO) &&
- IS_CUR_SEGNO(sbi, segno))
+ IS_CUR_SECNO(sbi, GET_SEC_FROM_SEG(sbi, segno)))
goto next_segment;
if (vblocks == 0 && not_enough)
goto next_segment;
--
2.49.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
reply other threads:[~2026-09-09 5:06 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=20260909050634.3513267-1-chao@kernel.org \
--to=linux-f2fs-devel@lists.sourceforge.net \
--cc=chao@kernel.org \
--cc=jaegeuk@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.