]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/f2fs/segment.h
fs/proc/kcore.c: use __pa_symbol() for KCORE_TEXT list entries
[mirror_ubuntu-bionic-kernel.git] / fs / f2fs / segment.h
index d1d394cdf61dd9ffbde608a941463c98b4d4f0b2..71a2aaa286dffcd8dc35629e5d79a58b1a3585f9 100644 (file)
@@ -655,7 +655,7 @@ static inline void verify_block_addr(struct f2fs_sb_info *sbi, block_t blk_addr)
 /*
  * Summary block is always treated as an invalid block
  */
-static inline void check_block_count(struct f2fs_sb_info *sbi,
+static inline int check_block_count(struct f2fs_sb_info *sbi,
                int segno, struct f2fs_sit_entry *raw_sit)
 {
 #ifdef CONFIG_F2FS_CHECK_FS
@@ -677,11 +677,25 @@ static inline void check_block_count(struct f2fs_sb_info *sbi,
                cur_pos = next_pos;
                is_valid = !is_valid;
        } while (cur_pos < sbi->blocks_per_seg);
-       BUG_ON(GET_SIT_VBLOCKS(raw_sit) != valid_blocks);
+
+       if (unlikely(GET_SIT_VBLOCKS(raw_sit) != valid_blocks)) {
+               f2fs_msg(sbi->sb, KERN_ERR,
+                               "Mismatch valid blocks %d vs. %d",
+                                       GET_SIT_VBLOCKS(raw_sit), valid_blocks);
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
+               return -EINVAL;
+       }
 #endif
        /* check segment usage, and check boundary of a given segment number */
-       f2fs_bug_on(sbi, GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg
-                                       || segno > TOTAL_SEGS(sbi) - 1);
+       if (unlikely(GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg
+                                       || segno > TOTAL_SEGS(sbi) - 1)) {
+               f2fs_msg(sbi->sb, KERN_ERR,
+                               "Wrong valid blocks %d or segno %u",
+                                       GET_SIT_VBLOCKS(raw_sit), segno);
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
+               return -EINVAL;
+       }
+       return 0;
 }
 
 static inline pgoff_t current_sit_addr(struct f2fs_sb_info *sbi,