Commit ec325b52 authored by Jaegeuk Kim's avatar Jaegeuk Kim

f2fs: handle bug cases by letting fsck.f2fs initiate

This patch adds to handle corner buggy cases for fsck.f2fs.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 05796763
...@@ -317,6 +317,10 @@ static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, ...@@ -317,6 +317,10 @@ static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
struct seg_entry *sentry = get_seg_entry(sbi, segno); struct seg_entry *sentry = get_seg_entry(sbi, segno);
enum dirty_type t = sentry->type; enum dirty_type t = sentry->type;
if (unlikely(t >= DIRTY)) {
f2fs_bug_on(sbi, 1);
return;
}
if (!test_and_set_bit(segno, dirty_i->dirty_segmap[t])) if (!test_and_set_bit(segno, dirty_i->dirty_segmap[t]))
dirty_i->nr_dirty[t]++; dirty_i->nr_dirty[t]++;
} }
...@@ -1745,8 +1749,12 @@ static void init_dirty_segmap(struct f2fs_sb_info *sbi) ...@@ -1745,8 +1749,12 @@ static void init_dirty_segmap(struct f2fs_sb_info *sbi)
break; break;
offset = segno + 1; offset = segno + 1;
valid_blocks = get_valid_blocks(sbi, segno, 0); valid_blocks = get_valid_blocks(sbi, segno, 0);
if (valid_blocks >= sbi->blocks_per_seg || !valid_blocks) if (valid_blocks == sbi->blocks_per_seg || !valid_blocks)
continue; continue;
if (valid_blocks > sbi->blocks_per_seg) {
f2fs_bug_on(sbi, 1);
continue;
}
mutex_lock(&dirty_i->seglist_lock); mutex_lock(&dirty_i->seglist_lock);
__locate_dirty_segment(sbi, segno, DIRTY); __locate_dirty_segment(sbi, segno, DIRTY);
mutex_unlock(&dirty_i->seglist_lock); mutex_unlock(&dirty_i->seglist_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment