1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _BCACHEFS_SB_ERRORS_H 3 #define _BCACHEFS_SB_ERRORS_H 4 5 #include "sb-errors_types.h" 6 7 #define BCH_SB_ERRS() \ 8 x(clean_but_journal_not_empty, 0) \ 9 x(dirty_but_no_journal_entries, 1) \ 10 x(dirty_but_no_journal_entries_post_drop_nonflushes, 2) \ 11 x(sb_clean_journal_seq_mismatch, 3) \ 12 x(sb_clean_btree_root_mismatch, 4) \ 13 x(sb_clean_missing, 5) \ 14 x(jset_unsupported_version, 6) \ 15 x(jset_unknown_csum, 7) \ 16 x(jset_last_seq_newer_than_seq, 8) \ 17 x(jset_past_bucket_end, 9) \ 18 x(jset_seq_blacklisted, 10) \ 19 x(journal_entries_missing, 11) \ 20 x(journal_entry_replicas_not_marked, 12) \ 21 x(journal_entry_past_jset_end, 13) \ 22 x(journal_entry_replicas_data_mismatch, 14) \ 23 x(journal_entry_bkey_u64s_0, 15) \ 24 x(journal_entry_bkey_past_end, 16) \ 25 x(journal_entry_bkey_bad_format, 17) \ 26 x(journal_entry_bkey_invalid, 18) \ 27 x(journal_entry_btree_root_bad_size, 19) \ 28 x(journal_entry_blacklist_bad_size, 20) \ 29 x(journal_entry_blacklist_v2_bad_size, 21) \ 30 x(journal_entry_blacklist_v2_start_past_end, 22) \ 31 x(journal_entry_usage_bad_size, 23) \ 32 x(journal_entry_data_usage_bad_size, 24) \ 33 x(journal_entry_clock_bad_size, 25) \ 34 x(journal_entry_clock_bad_rw, 26) \ 35 x(journal_entry_dev_usage_bad_size, 27) \ 36 x(journal_entry_dev_usage_bad_dev, 28) \ 37 x(journal_entry_dev_usage_bad_pad, 29) \ 38 x(btree_node_unreadable, 30) \ 39 x(btree_node_fault_injected, 31) \ 40 x(btree_node_bad_magic, 32) \ 41 x(btree_node_bad_seq, 33) \ 42 x(btree_node_unsupported_version, 34) \ 43 x(btree_node_bset_older_than_sb_min, 35) \ 44 x(btree_node_bset_newer_than_sb, 36) \ 45 x(btree_node_data_missing, 37) \ 46 x(btree_node_bset_after_end, 38) \ 47 x(btree_node_replicas_sectors_written_mismatch, 39) \ 48 x(btree_node_replicas_data_mismatch, 40) \ 49 x(bset_unknown_csum, 41) \ 50 x(bset_bad_csum, 42) \ 51 x(bset_past_end_of_btree_node, 43) \ 52 x(bset_wrong_sector_offset, 44) \ 53 x(bset_empty, 45) \ 54 x(bset_bad_seq, 46) \ 55 x(bset_blacklisted_journal_seq, 47) \ 56 x(first_bset_blacklisted_journal_seq, 48) \ 57 x(btree_node_bad_btree, 49) \ 58 x(btree_node_bad_level, 50) \ 59 x(btree_node_bad_min_key, 51) \ 60 x(btree_node_bad_max_key, 52) \ 61 x(btree_node_bad_format, 53) \ 62 x(btree_node_bkey_past_bset_end, 54) \ 63 x(btree_node_bkey_bad_format, 55) \ 64 x(btree_node_bad_bkey, 56) \ 65 x(btree_node_bkey_out_of_order, 57) \ 66 x(btree_root_bkey_invalid, 58) \ 67 x(btree_root_read_error, 59) \ 68 x(btree_root_bad_min_key, 60) \ 69 x(btree_root_bad_max_key, 61) \ 70 x(btree_node_read_error, 62) \ 71 x(btree_node_topology_bad_min_key, 63) \ 72 x(btree_node_topology_bad_max_key, 64) \ 73 x(btree_node_topology_overwritten_by_prev_node, 65) \ 74 x(btree_node_topology_overwritten_by_next_node, 66) \ 75 x(btree_node_topology_interior_node_empty, 67) \ 76 x(fs_usage_hidden_wrong, 68) \ 77 x(fs_usage_btree_wrong, 69) \ 78 x(fs_usage_data_wrong, 70) \ 79 x(fs_usage_cached_wrong, 71) \ 80 x(fs_usage_reserved_wrong, 72) \ 81 x(fs_usage_persistent_reserved_wrong, 73) \ 82 x(fs_usage_nr_inodes_wrong, 74) \ 83 x(fs_usage_replicas_wrong, 75) \ 84 x(dev_usage_buckets_wrong, 76) \ 85 x(dev_usage_sectors_wrong, 77) \ 86 x(dev_usage_fragmented_wrong, 78) \ 87 x(dev_usage_buckets_ec_wrong, 79) \ 88 x(bkey_version_in_future, 80) \ 89 x(bkey_u64s_too_small, 81) \ 90 x(bkey_invalid_type_for_btree, 82) \ 91 x(bkey_extent_size_zero, 83) \ 92 x(bkey_extent_size_greater_than_offset, 84) \ 93 x(bkey_size_nonzero, 85) \ 94 x(bkey_snapshot_nonzero, 86) \ 95 x(bkey_snapshot_zero, 87) \ 96 x(bkey_at_pos_max, 88) \ 97 x(bkey_before_start_of_btree_node, 89) \ 98 x(bkey_after_end_of_btree_node, 90) \ 99 x(bkey_val_size_nonzero, 91) \ 100 x(bkey_val_size_too_small, 92) \ 101 x(alloc_v1_val_size_bad, 93) \ 102 x(alloc_v2_unpack_error, 94) \ 103 x(alloc_v3_unpack_error, 95) \ 104 x(alloc_v4_val_size_bad, 96) \ 105 x(alloc_v4_backpointers_start_bad, 97) \ 106 x(alloc_key_data_type_bad, 98) \ 107 x(alloc_key_empty_but_have_data, 99) \ 108 x(alloc_key_dirty_sectors_0, 100) \ 109 x(alloc_key_data_type_inconsistency, 101) \ 110 x(alloc_key_to_missing_dev_bucket, 102) \ 111 x(alloc_key_cached_inconsistency, 103) \ 112 x(alloc_key_cached_but_read_time_zero, 104) \ 113 x(alloc_key_to_missing_lru_entry, 105) \ 114 x(alloc_key_data_type_wrong, 106) \ 115 x(alloc_key_gen_wrong, 107) \ 116 x(alloc_key_dirty_sectors_wrong, 108) \ 117 x(alloc_key_cached_sectors_wrong, 109) \ 118 x(alloc_key_stripe_wrong, 110) \ 119 x(alloc_key_stripe_redundancy_wrong, 111) \ 120 x(bucket_sector_count_overflow, 112) \ 121 x(bucket_metadata_type_mismatch, 113) \ 122 x(need_discard_key_wrong, 114) \ 123 x(freespace_key_wrong, 115) \ 124 x(freespace_hole_missing, 116) \ 125 x(bucket_gens_val_size_bad, 117) \ 126 x(bucket_gens_key_wrong, 118) \ 127 x(bucket_gens_hole_wrong, 119) \ 128 x(bucket_gens_to_invalid_dev, 120) \ 129 x(bucket_gens_to_invalid_buckets, 121) \ 130 x(bucket_gens_nonzero_for_invalid_buckets, 122) \ 131 x(need_discard_freespace_key_to_invalid_dev_bucket, 123) \ 132 x(need_discard_freespace_key_bad, 124) \ 133 x(backpointer_pos_wrong, 125) \ 134 x(backpointer_to_missing_device, 126) \ 135 x(backpointer_to_missing_alloc, 127) \ 136 x(backpointer_to_missing_ptr, 128) \ 137 x(lru_entry_at_time_0, 129) \ 138 x(lru_entry_to_invalid_bucket, 130) \ 139 x(lru_entry_bad, 131) \ 140 x(btree_ptr_val_too_big, 132) \ 141 x(btree_ptr_v2_val_too_big, 133) \ 142 x(btree_ptr_has_non_ptr, 134) \ 143 x(extent_ptrs_invalid_entry, 135) \ 144 x(extent_ptrs_no_ptrs, 136) \ 145 x(extent_ptrs_too_many_ptrs, 137) \ 146 x(extent_ptrs_redundant_crc, 138) \ 147 x(extent_ptrs_redundant_stripe, 139) \ 148 x(extent_ptrs_unwritten, 140) \ 149 x(extent_ptrs_written_and_unwritten, 141) \ 150 x(ptr_to_invalid_device, 142) \ 151 x(ptr_to_duplicate_device, 143) \ 152 x(ptr_after_last_bucket, 144) \ 153 x(ptr_before_first_bucket, 145) \ 154 x(ptr_spans_multiple_buckets, 146) \ 155 x(ptr_to_missing_backpointer, 147) \ 156 x(ptr_to_missing_alloc_key, 148) \ 157 x(ptr_to_missing_replicas_entry, 149) \ 158 x(ptr_to_missing_stripe, 150) \ 159 x(ptr_to_incorrect_stripe, 151) \ 160 x(ptr_gen_newer_than_bucket_gen, 152) \ 161 x(ptr_too_stale, 153) \ 162 x(stale_dirty_ptr, 154) \ 163 x(ptr_bucket_data_type_mismatch, 155) \ 164 x(ptr_cached_and_erasure_coded, 156) \ 165 x(ptr_crc_uncompressed_size_too_small, 157) \ 166 x(ptr_crc_csum_type_unknown, 158) \ 167 x(ptr_crc_compression_type_unknown, 159) \ 168 x(ptr_crc_redundant, 160) \ 169 x(ptr_crc_uncompressed_size_too_big, 161) \ 170 x(ptr_crc_nonce_mismatch, 162) \ 171 x(ptr_stripe_redundant, 163) \ 172 x(reservation_key_nr_replicas_invalid, 164) \ 173 x(reflink_v_refcount_wrong, 165) \ 174 x(reflink_p_to_missing_reflink_v, 166) \ 175 x(stripe_pos_bad, 167) \ 176 x(stripe_val_size_bad, 168) \ 177 x(stripe_sector_count_wrong, 169) \ 178 x(snapshot_tree_pos_bad, 170) \ 179 x(snapshot_tree_to_missing_snapshot, 171) \ 180 x(snapshot_tree_to_missing_subvol, 172) \ 181 x(snapshot_tree_to_wrong_subvol, 173) \ 182 x(snapshot_tree_to_snapshot_subvol, 174) \ 183 x(snapshot_pos_bad, 175) \ 184 x(snapshot_parent_bad, 176) \ 185 x(snapshot_children_not_normalized, 177) \ 186 x(snapshot_child_duplicate, 178) \ 187 x(snapshot_child_bad, 179) \ 188 x(snapshot_skiplist_not_normalized, 180) \ 189 x(snapshot_skiplist_bad, 181) \ 190 x(snapshot_should_not_have_subvol, 182) \ 191 x(snapshot_to_bad_snapshot_tree, 183) \ 192 x(snapshot_bad_depth, 184) \ 193 x(snapshot_bad_skiplist, 185) \ 194 x(subvol_pos_bad, 186) \ 195 x(subvol_not_master_and_not_snapshot, 187) \ 196 x(subvol_to_missing_root, 188) \ 197 x(subvol_root_wrong_bi_subvol, 189) \ 198 x(bkey_in_missing_snapshot, 190) \ 199 x(inode_pos_inode_nonzero, 191) \ 200 x(inode_pos_blockdev_range, 192) \ 201 x(inode_unpack_error, 193) \ 202 x(inode_str_hash_invalid, 194) \ 203 x(inode_v3_fields_start_bad, 195) \ 204 x(inode_snapshot_mismatch, 196) \ 205 x(inode_unlinked_but_clean, 197) \ 206 x(inode_unlinked_but_nlink_nonzero, 198) \ 207 x(inode_checksum_type_invalid, 199) \ 208 x(inode_compression_type_invalid, 200) \ 209 x(inode_subvol_root_but_not_dir, 201) \ 210 x(inode_i_size_dirty_but_clean, 202) \ 211 x(inode_i_sectors_dirty_but_clean, 203) \ 212 x(inode_i_sectors_wrong, 204) \ 213 x(inode_dir_wrong_nlink, 205) \ 214 x(inode_dir_multiple_links, 206) \ 215 x(inode_multiple_links_but_nlink_0, 207) \ 216 x(inode_wrong_backpointer, 208) \ 217 x(inode_wrong_nlink, 209) \ 218 x(inode_unreachable, 210) \ 219 x(deleted_inode_but_clean, 211) \ 220 x(deleted_inode_missing, 212) \ 221 x(deleted_inode_is_dir, 213) \ 222 x(deleted_inode_not_unlinked, 214) \ 223 x(extent_overlapping, 215) \ 224 x(extent_in_missing_inode, 216) \ 225 x(extent_in_non_reg_inode, 217) \ 226 x(extent_past_end_of_inode, 218) \ 227 x(dirent_empty_name, 219) \ 228 x(dirent_val_too_big, 220) \ 229 x(dirent_name_too_long, 221) \ 230 x(dirent_name_embedded_nul, 222) \ 231 x(dirent_name_dot_or_dotdot, 223) \ 232 x(dirent_name_has_slash, 224) \ 233 x(dirent_d_type_wrong, 225) \ 234 x(dirent_d_parent_subvol_wrong, 226) \ 235 x(dirent_in_missing_dir_inode, 227) \ 236 x(dirent_in_non_dir_inode, 228) \ 237 x(dirent_to_missing_inode, 229) \ 238 x(dirent_to_missing_subvol, 230) \ 239 x(dirent_to_itself, 231) \ 240 x(quota_type_invalid, 232) \ 241 x(xattr_val_size_too_small, 233) \ 242 x(xattr_val_size_too_big, 234) \ 243 x(xattr_invalid_type, 235) \ 244 x(xattr_name_invalid_chars, 236) \ 245 x(xattr_in_missing_inode, 237) \ 246 x(root_subvol_missing, 238) \ 247 x(root_dir_missing, 239) \ 248 x(root_inode_not_dir, 240) \ 249 x(dir_loop, 241) \ 250 x(hash_table_key_duplicate, 242) \ 251 x(hash_table_key_wrong_offset, 243) 252 253 enum bch_sb_error_id { 254 #define x(t, n) BCH_FSCK_ERR_##t = n, 255 BCH_SB_ERRS() 256 #undef x 257 BCH_SB_ERR_MAX 258 }; 259 260 extern const struct bch_sb_field_ops bch_sb_field_ops_errors; 261 262 void bch2_sb_error_count(struct bch_fs *, enum bch_sb_error_id); 263 264 void bch2_sb_errors_from_cpu(struct bch_fs *); 265 266 void bch2_fs_sb_errors_exit(struct bch_fs *); 267 void bch2_fs_sb_errors_init_early(struct bch_fs *); 268 int bch2_fs_sb_errors_init(struct bch_fs *); 269 270 #endif /* _BCACHEFS_SB_ERRORS_H */ 271