Skip to content

Commit e9cdd30

Browse files
Yunlei HeJaegeuk Kim
authored andcommitted
f2fs: fix a mount fail for wrong next_scan_nid
-write_checkpoint -do_checkpoint -next_free_nid <--- something wrong with next free nid -f2fs_fill_super -build_node_manager -build_free_nids -get_current_nat_page -__get_meta_page <--- attempt to access beyond end of device Signed-off-by: Yunlei He <heyunlei@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent baaabbb commit e9cdd30

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎fs/f2fs/node.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,9 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
19551955
int i = 0;
19561956
nid_t nid = nm_i->next_scan_nid;
19571957

1958+
if (unlikely(nid >= nm_i->max_nid))
1959+
nid = 0;
1960+
19581961
/* Enough entries */
19591962
if (nm_i->nid_cnt[FREE_NID_LIST] >= NAT_ENTRY_PER_BLOCK)
19601963
return;

0 commit comments

Comments
 (0)