Commit ec325b5270cd3ba01bce299d1ede1616f31813ea
1 parent
05796763b8
f2fs: handle bug cases by letting fsck.f2fs initiate
This patch adds to handle corner buggy cases for fsck.f2fs. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Showing 1 changed file with 9 additions and 1 deletions Side-by-side Diff
fs/f2fs/segment.c
... | ... | @@ -317,6 +317,10 @@ |
317 | 317 | struct seg_entry *sentry = get_seg_entry(sbi, segno); |
318 | 318 | enum dirty_type t = sentry->type; |
319 | 319 | |
320 | + if (unlikely(t >= DIRTY)) { | |
321 | + f2fs_bug_on(sbi, 1); | |
322 | + return; | |
323 | + } | |
320 | 324 | if (!test_and_set_bit(segno, dirty_i->dirty_segmap[t])) |
321 | 325 | dirty_i->nr_dirty[t]++; |
322 | 326 | } |
323 | 327 | |
... | ... | @@ -1745,8 +1749,12 @@ |
1745 | 1749 | break; |
1746 | 1750 | offset = segno + 1; |
1747 | 1751 | valid_blocks = get_valid_blocks(sbi, segno, 0); |
1748 | - if (valid_blocks >= sbi->blocks_per_seg || !valid_blocks) | |
1752 | + if (valid_blocks == sbi->blocks_per_seg || !valid_blocks) | |
1749 | 1753 | continue; |
1754 | + if (valid_blocks > sbi->blocks_per_seg) { | |
1755 | + f2fs_bug_on(sbi, 1); | |
1756 | + continue; | |
1757 | + } | |
1750 | 1758 | mutex_lock(&dirty_i->seglist_lock); |
1751 | 1759 | __locate_dirty_segment(sbi, segno, DIRTY); |
1752 | 1760 | mutex_unlock(&dirty_i->seglist_lock); |