Skip to content

Commit 2c19050

Browse files
Yunlong SongJaegeuk Kim
authored andcommitted
f2fs: check segment type in __f2fs_replace_block
In some case, the node blocks has wrong blkaddr whose segment type is NODE, e.g., recover inode has missing xattr flag and the blkaddr is in the xattr range. Since fsck.f2fs does not check the recovery nodes, this will cause __f2fs_replace_block change the curseg of node and do the update_sit_entry(sbi, new_blkaddr, 1) with no next_blkoff refresh, as a result, when recovery process write checkpoint and sync nodes, the next_blkoff of curseg is used in the segment bit map, then it will cause f2fs_bug_on. So let's check segment type in __f2fs_replace_block. Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 1eca05a commit 2c19050

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/f2fs/segment.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,6 +2739,7 @@ void __f2fs_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
27392739
}
27402740
}
27412741

2742+
f2fs_bug_on(sbi, !IS_DATASEG(type));
27422743
curseg = CURSEG_I(sbi, type);
27432744

27442745
mutex_lock(&curseg->curseg_mutex);

0 commit comments

Comments
 (0)