1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _BCACHEFS_SB_ERRORS_FORMAT_H 3 #define _BCACHEFS_SB_ERRORS_FORMAT_H 4 5 enum bch_fsck_flags { 6 FSCK_CAN_FIX = 1 << 0, 7 FSCK_CAN_IGNORE = 1 << 1, 8 FSCK_NEED_FSCK = 1 << 2, 9 FSCK_NO_RATELIMIT = 1 << 3, 10 FSCK_AUTOFIX = 1 << 4, 11 }; 12 13 #define BCH_SB_ERRS() \ 14 x(clean_but_journal_not_empty, 0, 0) \ 15 x(dirty_but_no_journal_entries, 1, 0) \ 16 x(dirty_but_no_journal_entries_post_drop_nonflushes, 2, 0) \ 17 x(sb_clean_journal_seq_mismatch, 3, 0) \ 18 x(sb_clean_btree_root_mismatch, 4, 0) \ 19 x(sb_clean_missing, 5, 0) \ 20 x(jset_unsupported_version, 6, 0) \ 21 x(jset_unknown_csum, 7, 0) \ 22 x(jset_last_seq_newer_than_seq, 8, 0) \ 23 x(jset_past_bucket_end, 9, 0) \ 24 x(jset_seq_blacklisted, 10, 0) \ 25 x(journal_entries_missing, 11, 0) \ 26 x(journal_entry_replicas_not_marked, 12, FSCK_AUTOFIX) \ 27 x(journal_entry_past_jset_end, 13, 0) \ 28 x(journal_entry_replicas_data_mismatch, 14, 0) \ 29 x(journal_entry_bkey_u64s_0, 15, 0) \ 30 x(journal_entry_bkey_past_end, 16, 0) \ 31 x(journal_entry_bkey_bad_format, 17, 0) \ 32 x(journal_entry_bkey_invalid, 18, 0) \ 33 x(journal_entry_btree_root_bad_size, 19, 0) \ 34 x(journal_entry_blacklist_bad_size, 20, 0) \ 35 x(journal_entry_blacklist_v2_bad_size, 21, 0) \ 36 x(journal_entry_blacklist_v2_start_past_end, 22, 0) \ 37 x(journal_entry_usage_bad_size, 23, 0) \ 38 x(journal_entry_data_usage_bad_size, 24, 0) \ 39 x(journal_entry_clock_bad_size, 25, 0) \ 40 x(journal_entry_clock_bad_rw, 26, 0) \ 41 x(journal_entry_dev_usage_bad_size, 27, 0) \ 42 x(journal_entry_dev_usage_bad_dev, 28, 0) \ 43 x(journal_entry_dev_usage_bad_pad, 29, 0) \ 44 x(btree_node_unreadable, 30, 0) \ 45 x(btree_node_fault_injected, 31, 0) \ 46 x(btree_node_bad_magic, 32, 0) \ 47 x(btree_node_bad_seq, 33, 0) \ 48 x(btree_node_unsupported_version, 34, 0) \ 49 x(btree_node_bset_older_than_sb_min, 35, 0) \ 50 x(btree_node_bset_newer_than_sb, 36, 0) \ 51 x(btree_node_data_missing, 37, 0) \ 52 x(btree_node_bset_after_end, 38, 0) \ 53 x(btree_node_replicas_sectors_written_mismatch, 39, 0) \ 54 x(btree_node_replicas_data_mismatch, 40, 0) \ 55 x(bset_unknown_csum, 41, 0) \ 56 x(bset_bad_csum, 42, 0) \ 57 x(bset_past_end_of_btree_node, 43, 0) \ 58 x(bset_wrong_sector_offset, 44, 0) \ 59 x(bset_empty, 45, 0) \ 60 x(bset_bad_seq, 46, 0) \ 61 x(bset_blacklisted_journal_seq, 47, 0) \ 62 x(first_bset_blacklisted_journal_seq, 48, 0) \ 63 x(btree_node_bad_btree, 49, 0) \ 64 x(btree_node_bad_level, 50, 0) \ 65 x(btree_node_bad_min_key, 51, 0) \ 66 x(btree_node_bad_max_key, 52, 0) \ 67 x(btree_node_bad_format, 53, 0) \ 68 x(btree_node_bkey_past_bset_end, 54, 0) \ 69 x(btree_node_bkey_bad_format, 55, 0) \ 70 x(btree_node_bad_bkey, 56, 0) \ 71 x(btree_node_bkey_out_of_order, 57, 0) \ 72 x(btree_root_bkey_invalid, 58, 0) \ 73 x(btree_root_read_error, 59, 0) \ 74 x(btree_root_bad_min_key, 60, 0) \ 75 x(btree_root_bad_max_key, 61, 0) \ 76 x(btree_node_read_error, 62, 0) \ 77 x(btree_node_topology_bad_min_key, 63, 0) \ 78 x(btree_node_topology_bad_max_key, 64, 0) \ 79 x(btree_node_topology_overwritten_by_prev_node, 65, 0) \ 80 x(btree_node_topology_overwritten_by_next_node, 66, 0) \ 81 x(btree_node_topology_interior_node_empty, 67, 0) \ 82 x(fs_usage_hidden_wrong, 68, FSCK_AUTOFIX) \ 83 x(fs_usage_btree_wrong, 69, FSCK_AUTOFIX) \ 84 x(fs_usage_data_wrong, 70, FSCK_AUTOFIX) \ 85 x(fs_usage_cached_wrong, 71, FSCK_AUTOFIX) \ 86 x(fs_usage_reserved_wrong, 72, FSCK_AUTOFIX) \ 87 x(fs_usage_persistent_reserved_wrong, 73, FSCK_AUTOFIX) \ 88 x(fs_usage_nr_inodes_wrong, 74, FSCK_AUTOFIX) \ 89 x(fs_usage_replicas_wrong, 75, FSCK_AUTOFIX) \ 90 x(dev_usage_buckets_wrong, 76, FSCK_AUTOFIX) \ 91 x(dev_usage_sectors_wrong, 77, FSCK_AUTOFIX) \ 92 x(dev_usage_fragmented_wrong, 78, FSCK_AUTOFIX) \ 93 x(dev_usage_buckets_ec_wrong, 79, FSCK_AUTOFIX) \ 94 x(bkey_version_in_future, 80, 0) \ 95 x(bkey_u64s_too_small, 81, 0) \ 96 x(bkey_invalid_type_for_btree, 82, 0) \ 97 x(bkey_extent_size_zero, 83, 0) \ 98 x(bkey_extent_size_greater_than_offset, 84, 0) \ 99 x(bkey_size_nonzero, 85, 0) \ 100 x(bkey_snapshot_nonzero, 86, 0) \ 101 x(bkey_snapshot_zero, 87, 0) \ 102 x(bkey_at_pos_max, 88, 0) \ 103 x(bkey_before_start_of_btree_node, 89, 0) \ 104 x(bkey_after_end_of_btree_node, 90, 0) \ 105 x(bkey_val_size_nonzero, 91, 0) \ 106 x(bkey_val_size_too_small, 92, 0) \ 107 x(alloc_v1_val_size_bad, 93, 0) \ 108 x(alloc_v2_unpack_error, 94, 0) \ 109 x(alloc_v3_unpack_error, 95, 0) \ 110 x(alloc_v4_val_size_bad, 96, 0) \ 111 x(alloc_v4_backpointers_start_bad, 97, 0) \ 112 x(alloc_key_data_type_bad, 98, 0) \ 113 x(alloc_key_empty_but_have_data, 99, 0) \ 114 x(alloc_key_dirty_sectors_0, 100, 0) \ 115 x(alloc_key_data_type_inconsistency, 101, 0) \ 116 x(alloc_key_to_missing_dev_bucket, 102, 0) \ 117 x(alloc_key_cached_inconsistency, 103, 0) \ 118 x(alloc_key_cached_but_read_time_zero, 104, FSCK_AUTOFIX) \ 119 x(alloc_key_to_missing_lru_entry, 105, FSCK_AUTOFIX) \ 120 x(alloc_key_data_type_wrong, 106, FSCK_AUTOFIX) \ 121 x(alloc_key_gen_wrong, 107, FSCK_AUTOFIX) \ 122 x(alloc_key_dirty_sectors_wrong, 108, FSCK_AUTOFIX) \ 123 x(alloc_key_cached_sectors_wrong, 109, FSCK_AUTOFIX) \ 124 x(alloc_key_stripe_wrong, 110, FSCK_AUTOFIX) \ 125 x(alloc_key_stripe_redundancy_wrong, 111, FSCK_AUTOFIX) \ 126 x(bucket_sector_count_overflow, 112, 0) \ 127 x(bucket_metadata_type_mismatch, 113, 0) \ 128 x(need_discard_key_wrong, 114, 0) \ 129 x(freespace_key_wrong, 115, 0) \ 130 x(freespace_hole_missing, 116, 0) \ 131 x(bucket_gens_val_size_bad, 117, 0) \ 132 x(bucket_gens_key_wrong, 118, FSCK_AUTOFIX) \ 133 x(bucket_gens_hole_wrong, 119, FSCK_AUTOFIX) \ 134 x(bucket_gens_to_invalid_dev, 120, FSCK_AUTOFIX) \ 135 x(bucket_gens_to_invalid_buckets, 121, FSCK_AUTOFIX) \ 136 x(bucket_gens_nonzero_for_invalid_buckets, 122, FSCK_AUTOFIX) \ 137 x(need_discard_freespace_key_to_invalid_dev_bucket, 123, 0) \ 138 x(need_discard_freespace_key_bad, 124, 0) \ 139 x(discarding_bucket_not_in_need_discard_btree, 291, 0) \ 140 x(backpointer_bucket_offset_wrong, 125, 0) \ 141 x(backpointer_level_bad, 294, 0) \ 142 x(backpointer_to_missing_device, 126, 0) \ 143 x(backpointer_to_missing_alloc, 127, 0) \ 144 x(backpointer_to_missing_ptr, 128, 0) \ 145 x(lru_entry_at_time_0, 129, FSCK_AUTOFIX) \ 146 x(lru_entry_to_invalid_bucket, 130, FSCK_AUTOFIX) \ 147 x(lru_entry_bad, 131, FSCK_AUTOFIX) \ 148 x(btree_ptr_val_too_big, 132, 0) \ 149 x(btree_ptr_v2_val_too_big, 133, 0) \ 150 x(btree_ptr_has_non_ptr, 134, 0) \ 151 x(extent_ptrs_invalid_entry, 135, 0) \ 152 x(extent_ptrs_no_ptrs, 136, 0) \ 153 x(extent_ptrs_too_many_ptrs, 137, 0) \ 154 x(extent_ptrs_redundant_crc, 138, 0) \ 155 x(extent_ptrs_redundant_stripe, 139, 0) \ 156 x(extent_ptrs_unwritten, 140, 0) \ 157 x(extent_ptrs_written_and_unwritten, 141, 0) \ 158 x(ptr_to_invalid_device, 142, 0) \ 159 x(ptr_to_duplicate_device, 143, 0) \ 160 x(ptr_after_last_bucket, 144, 0) \ 161 x(ptr_before_first_bucket, 145, 0) \ 162 x(ptr_spans_multiple_buckets, 146, 0) \ 163 x(ptr_to_missing_backpointer, 147, FSCK_AUTOFIX) \ 164 x(ptr_to_missing_alloc_key, 148, FSCK_AUTOFIX) \ 165 x(ptr_to_missing_replicas_entry, 149, FSCK_AUTOFIX) \ 166 x(ptr_to_missing_stripe, 150, 0) \ 167 x(ptr_to_incorrect_stripe, 151, 0) \ 168 x(ptr_gen_newer_than_bucket_gen, 152, 0) \ 169 x(ptr_too_stale, 153, 0) \ 170 x(stale_dirty_ptr, 154, 0) \ 171 x(ptr_bucket_data_type_mismatch, 155, 0) \ 172 x(ptr_cached_and_erasure_coded, 156, 0) \ 173 x(ptr_crc_uncompressed_size_too_small, 157, 0) \ 174 x(ptr_crc_csum_type_unknown, 158, 0) \ 175 x(ptr_crc_compression_type_unknown, 159, 0) \ 176 x(ptr_crc_redundant, 160, 0) \ 177 x(ptr_crc_uncompressed_size_too_big, 161, 0) \ 178 x(ptr_crc_nonce_mismatch, 162, 0) \ 179 x(ptr_stripe_redundant, 163, 0) \ 180 x(reservation_key_nr_replicas_invalid, 164, 0) \ 181 x(reflink_v_refcount_wrong, 165, 0) \ 182 x(reflink_v_pos_bad, 292, 0) \ 183 x(reflink_p_to_missing_reflink_v, 166, 0) \ 184 x(reflink_refcount_underflow, 293, 0) \ 185 x(stripe_pos_bad, 167, 0) \ 186 x(stripe_val_size_bad, 168, 0) \ 187 x(stripe_csum_granularity_bad, 290, 0) \ 188 x(stripe_sector_count_wrong, 169, 0) \ 189 x(snapshot_tree_pos_bad, 170, 0) \ 190 x(snapshot_tree_to_missing_snapshot, 171, 0) \ 191 x(snapshot_tree_to_missing_subvol, 172, 0) \ 192 x(snapshot_tree_to_wrong_subvol, 173, 0) \ 193 x(snapshot_tree_to_snapshot_subvol, 174, 0) \ 194 x(snapshot_pos_bad, 175, 0) \ 195 x(snapshot_parent_bad, 176, 0) \ 196 x(snapshot_children_not_normalized, 177, 0) \ 197 x(snapshot_child_duplicate, 178, 0) \ 198 x(snapshot_child_bad, 179, 0) \ 199 x(snapshot_skiplist_not_normalized, 180, 0) \ 200 x(snapshot_skiplist_bad, 181, 0) \ 201 x(snapshot_should_not_have_subvol, 182, 0) \ 202 x(snapshot_to_bad_snapshot_tree, 183, FSCK_AUTOFIX) \ 203 x(snapshot_bad_depth, 184, 0) \ 204 x(snapshot_bad_skiplist, 185, 0) \ 205 x(subvol_pos_bad, 186, 0) \ 206 x(subvol_not_master_and_not_snapshot, 187, 0) \ 207 x(subvol_to_missing_root, 188, 0) \ 208 x(subvol_root_wrong_bi_subvol, 189, 0) \ 209 x(bkey_in_missing_snapshot, 190, 0) \ 210 x(inode_pos_inode_nonzero, 191, 0) \ 211 x(inode_pos_blockdev_range, 192, 0) \ 212 x(inode_unpack_error, 193, 0) \ 213 x(inode_str_hash_invalid, 194, 0) \ 214 x(inode_v3_fields_start_bad, 195, 0) \ 215 x(inode_snapshot_mismatch, 196, 0) \ 216 x(inode_unlinked_but_clean, 197, 0) \ 217 x(inode_unlinked_but_nlink_nonzero, 198, 0) \ 218 x(inode_unlinked_and_not_open, 281, 0) \ 219 x(inode_unlinked_but_has_dirent, 285, 0) \ 220 x(inode_checksum_type_invalid, 199, 0) \ 221 x(inode_compression_type_invalid, 200, 0) \ 222 x(inode_subvol_root_but_not_dir, 201, 0) \ 223 x(inode_i_size_dirty_but_clean, 202, FSCK_AUTOFIX) \ 224 x(inode_i_sectors_dirty_but_clean, 203, FSCK_AUTOFIX) \ 225 x(inode_i_sectors_wrong, 204, FSCK_AUTOFIX) \ 226 x(inode_dir_wrong_nlink, 205, FSCK_AUTOFIX) \ 227 x(inode_dir_multiple_links, 206, FSCK_AUTOFIX) \ 228 x(inode_dir_missing_backpointer, 284, FSCK_AUTOFIX) \ 229 x(inode_dir_unlinked_but_not_empty, 286, FSCK_AUTOFIX) \ 230 x(inode_multiple_links_but_nlink_0, 207, FSCK_AUTOFIX) \ 231 x(inode_wrong_backpointer, 208, FSCK_AUTOFIX) \ 232 x(inode_wrong_nlink, 209, FSCK_AUTOFIX) \ 233 x(inode_has_child_snapshots_wrong, 287, 0) \ 234 x(inode_unreachable, 210, FSCK_AUTOFIX) \ 235 x(deleted_inode_but_clean, 211, FSCK_AUTOFIX) \ 236 x(deleted_inode_missing, 212, FSCK_AUTOFIX) \ 237 x(deleted_inode_is_dir, 213, FSCK_AUTOFIX) \ 238 x(deleted_inode_not_unlinked, 214, FSCK_AUTOFIX) \ 239 x(deleted_inode_has_child_snapshots, 288, FSCK_AUTOFIX) \ 240 x(extent_overlapping, 215, 0) \ 241 x(key_in_missing_inode, 216, 0) \ 242 x(key_in_wrong_inode_type, 217, 0) \ 243 x(extent_past_end_of_inode, 218, 0) \ 244 x(dirent_empty_name, 219, 0) \ 245 x(dirent_val_too_big, 220, 0) \ 246 x(dirent_name_too_long, 221, 0) \ 247 x(dirent_name_embedded_nul, 222, 0) \ 248 x(dirent_name_dot_or_dotdot, 223, 0) \ 249 x(dirent_name_has_slash, 224, 0) \ 250 x(dirent_d_type_wrong, 225, 0) \ 251 x(inode_bi_parent_wrong, 226, 0) \ 252 x(dirent_in_missing_dir_inode, 227, 0) \ 253 x(dirent_in_non_dir_inode, 228, 0) \ 254 x(dirent_to_missing_inode, 229, 0) \ 255 x(dirent_to_missing_subvol, 230, 0) \ 256 x(dirent_to_itself, 231, 0) \ 257 x(quota_type_invalid, 232, 0) \ 258 x(xattr_val_size_too_small, 233, 0) \ 259 x(xattr_val_size_too_big, 234, 0) \ 260 x(xattr_invalid_type, 235, 0) \ 261 x(xattr_name_invalid_chars, 236, 0) \ 262 x(xattr_in_missing_inode, 237, 0) \ 263 x(root_subvol_missing, 238, 0) \ 264 x(root_dir_missing, 239, 0) \ 265 x(root_inode_not_dir, 240, 0) \ 266 x(dir_loop, 241, 0) \ 267 x(hash_table_key_duplicate, 242, 0) \ 268 x(hash_table_key_wrong_offset, 243, 0) \ 269 x(unlinked_inode_not_on_deleted_list, 244, FSCK_AUTOFIX) \ 270 x(reflink_p_front_pad_bad, 245, 0) \ 271 x(journal_entry_dup_same_device, 246, 0) \ 272 x(inode_bi_subvol_missing, 247, 0) \ 273 x(inode_bi_subvol_wrong, 248, 0) \ 274 x(inode_points_to_missing_dirent, 249, FSCK_AUTOFIX) \ 275 x(inode_points_to_wrong_dirent, 250, FSCK_AUTOFIX) \ 276 x(inode_bi_parent_nonzero, 251, 0) \ 277 x(dirent_to_missing_parent_subvol, 252, 0) \ 278 x(dirent_not_visible_in_parent_subvol, 253, 0) \ 279 x(subvol_fs_path_parent_wrong, 254, 0) \ 280 x(subvol_root_fs_path_parent_nonzero, 255, 0) \ 281 x(subvol_children_not_set, 256, 0) \ 282 x(subvol_children_bad, 257, 0) \ 283 x(subvol_loop, 258, 0) \ 284 x(subvol_unreachable, 259, FSCK_AUTOFIX) \ 285 x(btree_node_bkey_bad_u64s, 260, 0) \ 286 x(btree_node_topology_empty_interior_node, 261, 0) \ 287 x(btree_ptr_v2_min_key_bad, 262, 0) \ 288 x(btree_root_unreadable_and_scan_found_nothing, 263, 0) \ 289 x(snapshot_node_missing, 264, 0) \ 290 x(dup_backpointer_to_bad_csum_extent, 265, 0) \ 291 x(btree_bitmap_not_marked, 266, 0) \ 292 x(sb_clean_entry_overrun, 267, 0) \ 293 x(btree_ptr_v2_written_0, 268, 0) \ 294 x(subvol_snapshot_bad, 269, 0) \ 295 x(subvol_inode_bad, 270, 0) \ 296 x(alloc_key_stripe_sectors_wrong, 271, FSCK_AUTOFIX) \ 297 x(accounting_mismatch, 272, FSCK_AUTOFIX) \ 298 x(accounting_replicas_not_marked, 273, 0) \ 299 x(accounting_to_invalid_device, 289, 0) \ 300 x(invalid_btree_id, 274, 0) \ 301 x(alloc_key_io_time_bad, 275, 0) \ 302 x(alloc_key_fragmentation_lru_wrong, 276, FSCK_AUTOFIX) \ 303 x(accounting_key_junk_at_end, 277, FSCK_AUTOFIX) \ 304 x(accounting_key_replicas_nr_devs_0, 278, FSCK_AUTOFIX) \ 305 x(accounting_key_replicas_nr_required_bad, 279, FSCK_AUTOFIX) \ 306 x(accounting_key_replicas_devs_unsorted, 280, FSCK_AUTOFIX) \ 307 x(accounting_key_version_0, 282, FSCK_AUTOFIX) \ 308 x(logged_op_but_clean, 283, FSCK_AUTOFIX) \ 309 x(MAX, 295, 0) 310 311 enum bch_sb_error_id { 312 #define x(t, n, ...) BCH_FSCK_ERR_##t = n, 313 BCH_SB_ERRS() 314 #undef x 315 }; 316 317 struct bch_sb_field_errors { 318 struct bch_sb_field field; 319 struct bch_sb_field_error_entry { 320 __le64 v; 321 __le64 last_error_time; 322 } entries[]; 323 }; 324 325 LE64_BITMASK(BCH_SB_ERROR_ENTRY_ID, struct bch_sb_field_error_entry, v, 0, 16); 326 LE64_BITMASK(BCH_SB_ERROR_ENTRY_NR, struct bch_sb_field_error_entry, v, 16, 64); 327 328 #endif /* _BCACHEFS_SB_ERRORS_FORMAT_H */ 329