summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorYunlong Song <yunlong.song@huawei.com>2018-01-04 15:02:02 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2018-01-16 15:39:57 -0800
commit2c1905042c8c3da45ec347d5397d1133ff30fce4 (patch)
treed0decd9b42d414c7b1cd26c27f3492ed0cd60ac0 /fs/f2fs
parent1eca05aa9d4d107a6f9e434b5041a775327a8a4b (diff)
downloadlinux-2c1905042c8c3da45ec347d5397d1133ff30fce4.tar.bz2
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>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/segment.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index b03f65e5dfdc..f2842a8a1341 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2739,6 +2739,7 @@ void __f2fs_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
}
}
+ f2fs_bug_on(sbi, !IS_DATASEG(type));
curseg = CURSEG_I(sbi, type);
mutex_lock(&curseg->curseg_mutex);