1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _BCACHEFS_ERRCODE_H 3 #define _BCACHEFS_ERRCODE_H 4 5 #define BCH_ERRCODES() \ 6 x(ERANGE, ERANGE_option_too_small) \ 7 x(ERANGE, ERANGE_option_too_big) \ 8 x(EINVAL, mount_option) \ 9 x(BCH_ERR_mount_option, option_name) \ 10 x(BCH_ERR_mount_option, option_value) \ 11 x(BCH_ERR_mount_option, option_not_bool) \ 12 x(ENOMEM, ENOMEM_stripe_buf) \ 13 x(ENOMEM, ENOMEM_replicas_table) \ 14 x(ENOMEM, ENOMEM_cpu_replicas) \ 15 x(ENOMEM, ENOMEM_replicas_gc) \ 16 x(ENOMEM, ENOMEM_disk_groups_validate) \ 17 x(ENOMEM, ENOMEM_disk_groups_to_cpu) \ 18 x(ENOMEM, ENOMEM_mark_snapshot) \ 19 x(ENOMEM, ENOMEM_mark_stripe) \ 20 x(ENOMEM, ENOMEM_mark_stripe_ptr) \ 21 x(ENOMEM, ENOMEM_btree_key_cache_create) \ 22 x(ENOMEM, ENOMEM_btree_key_cache_fill) \ 23 x(ENOMEM, ENOMEM_btree_key_cache_insert) \ 24 x(ENOMEM, ENOMEM_trans_kmalloc) \ 25 x(ENOMEM, ENOMEM_trans_log_msg) \ 26 x(ENOMEM, ENOMEM_do_encrypt) \ 27 x(ENOMEM, ENOMEM_ec_read_extent) \ 28 x(ENOMEM, ENOMEM_ec_stripe_mem_alloc) \ 29 x(ENOMEM, ENOMEM_ec_new_stripe_alloc) \ 30 x(ENOMEM, ENOMEM_fs_btree_cache_init) \ 31 x(ENOMEM, ENOMEM_fs_btree_key_cache_init) \ 32 x(ENOMEM, ENOMEM_fs_counters_init) \ 33 x(ENOMEM, ENOMEM_fs_btree_write_buffer_init) \ 34 x(ENOMEM, ENOMEM_io_clock_init) \ 35 x(ENOMEM, ENOMEM_blacklist_table_init) \ 36 x(ENOMEM, ENOMEM_sb_realloc_injected) \ 37 x(ENOMEM, ENOMEM_sb_bio_realloc) \ 38 x(ENOMEM, ENOMEM_sb_buf_realloc) \ 39 x(ENOMEM, ENOMEM_sb_journal_validate) \ 40 x(ENOMEM, ENOMEM_sb_journal_v2_validate) \ 41 x(ENOMEM, ENOMEM_journal_entry_add) \ 42 x(ENOMEM, ENOMEM_journal_read_buf_realloc) \ 43 x(ENOMEM, ENOMEM_btree_interior_update_worker_init)\ 44 x(ENOMEM, ENOMEM_btree_interior_update_pool_init) \ 45 x(ENOMEM, ENOMEM_bio_read_init) \ 46 x(ENOMEM, ENOMEM_bio_read_split_init) \ 47 x(ENOMEM, ENOMEM_bio_write_init) \ 48 x(ENOMEM, ENOMEM_bio_bounce_pages_init) \ 49 x(ENOMEM, ENOMEM_writepage_bioset_init) \ 50 x(ENOMEM, ENOMEM_dio_read_bioset_init) \ 51 x(ENOMEM, ENOMEM_dio_write_bioset_init) \ 52 x(ENOMEM, ENOMEM_nocow_flush_bioset_init) \ 53 x(ENOMEM, ENOMEM_promote_table_init) \ 54 x(ENOMEM, ENOMEM_compression_bounce_read_init) \ 55 x(ENOMEM, ENOMEM_compression_bounce_write_init) \ 56 x(ENOMEM, ENOMEM_compression_workspace_init) \ 57 x(ENOMEM, ENOMEM_decompression_workspace_init) \ 58 x(ENOMEM, ENOMEM_bucket_gens) \ 59 x(ENOMEM, ENOMEM_buckets_nouse) \ 60 x(ENOMEM, ENOMEM_usage_init) \ 61 x(ENOMEM, ENOMEM_btree_node_read_all_replicas) \ 62 x(ENOMEM, ENOMEM_btree_node_reclaim) \ 63 x(ENOMEM, ENOMEM_btree_node_mem_alloc) \ 64 x(ENOMEM, ENOMEM_btree_cache_cannibalize_lock) \ 65 x(ENOMEM, ENOMEM_buckets_waiting_for_journal_init)\ 66 x(ENOMEM, ENOMEM_buckets_waiting_for_journal_set) \ 67 x(ENOMEM, ENOMEM_set_nr_journal_buckets) \ 68 x(ENOMEM, ENOMEM_dev_journal_init) \ 69 x(ENOMEM, ENOMEM_journal_pin_fifo) \ 70 x(ENOMEM, ENOMEM_journal_buf) \ 71 x(ENOMEM, ENOMEM_gc_start) \ 72 x(ENOMEM, ENOMEM_gc_alloc_start) \ 73 x(ENOMEM, ENOMEM_gc_reflink_start) \ 74 x(ENOMEM, ENOMEM_gc_gens) \ 75 x(ENOMEM, ENOMEM_gc_repair_key) \ 76 x(ENOMEM, ENOMEM_fsck_extent_ends_at) \ 77 x(ENOMEM, ENOMEM_fsck_add_nlink) \ 78 x(ENOMEM, ENOMEM_journal_key_insert) \ 79 x(ENOMEM, ENOMEM_journal_keys_sort) \ 80 x(ENOMEM, ENOMEM_read_superblock_clean) \ 81 x(ENOMEM, ENOMEM_fs_alloc) \ 82 x(ENOMEM, ENOMEM_fs_name_alloc) \ 83 x(ENOMEM, ENOMEM_fs_other_alloc) \ 84 x(ENOMEM, ENOMEM_dev_alloc) \ 85 x(ENOMEM, ENOMEM_disk_accounting) \ 86 x(ENOMEM, ENOMEM_stripe_head_alloc) \ 87 x(ENOMEM, ENOMEM_journal_read_bucket) \ 88 x(ENOSPC, ENOSPC_disk_reservation) \ 89 x(ENOSPC, ENOSPC_bucket_alloc) \ 90 x(ENOSPC, ENOSPC_disk_label_add) \ 91 x(ENOSPC, ENOSPC_stripe_create) \ 92 x(ENOSPC, ENOSPC_inode_create) \ 93 x(ENOSPC, ENOSPC_str_hash_create) \ 94 x(ENOSPC, ENOSPC_snapshot_create) \ 95 x(ENOSPC, ENOSPC_subvolume_create) \ 96 x(ENOSPC, ENOSPC_sb) \ 97 x(ENOSPC, ENOSPC_sb_journal) \ 98 x(ENOSPC, ENOSPC_sb_journal_seq_blacklist) \ 99 x(ENOSPC, ENOSPC_sb_quota) \ 100 x(ENOSPC, ENOSPC_sb_replicas) \ 101 x(ENOSPC, ENOSPC_sb_members) \ 102 x(ENOSPC, ENOSPC_sb_members_v2) \ 103 x(ENOSPC, ENOSPC_sb_crypt) \ 104 x(ENOSPC, ENOSPC_sb_downgrade) \ 105 x(ENOSPC, ENOSPC_btree_slot) \ 106 x(ENOSPC, ENOSPC_snapshot_tree) \ 107 x(ENOENT, ENOENT_bkey_type_mismatch) \ 108 x(ENOENT, ENOENT_str_hash_lookup) \ 109 x(ENOENT, ENOENT_str_hash_set_must_replace) \ 110 x(ENOENT, ENOENT_inode) \ 111 x(ENOENT, ENOENT_not_subvol) \ 112 x(ENOENT, ENOENT_not_directory) \ 113 x(ENOENT, ENOENT_directory_dead) \ 114 x(ENOENT, ENOENT_subvolume) \ 115 x(ENOENT, ENOENT_snapshot_tree) \ 116 x(ENOENT, ENOENT_dirent_doesnt_match_inode) \ 117 x(ENOENT, ENOENT_dev_not_found) \ 118 x(ENOENT, ENOENT_dev_idx_not_found) \ 119 x(ENOTEMPTY, ENOTEMPTY_dir_not_empty) \ 120 x(ENOTEMPTY, ENOTEMPTY_subvol_not_empty) \ 121 x(EEXIST, EEXIST_str_hash_set) \ 122 x(EEXIST, EEXIST_discard_in_flight_add) \ 123 x(EEXIST, EEXIST_subvolume_create) \ 124 x(ENOSPC, open_buckets_empty) \ 125 x(ENOSPC, freelist_empty) \ 126 x(BCH_ERR_freelist_empty, no_buckets_found) \ 127 x(0, transaction_restart) \ 128 x(BCH_ERR_transaction_restart, transaction_restart_fault_inject) \ 129 x(BCH_ERR_transaction_restart, transaction_restart_relock) \ 130 x(BCH_ERR_transaction_restart, transaction_restart_relock_path) \ 131 x(BCH_ERR_transaction_restart, transaction_restart_relock_path_intent) \ 132 x(BCH_ERR_transaction_restart, transaction_restart_relock_after_fill) \ 133 x(BCH_ERR_transaction_restart, transaction_restart_too_many_iters) \ 134 x(BCH_ERR_transaction_restart, transaction_restart_lock_node_reused) \ 135 x(BCH_ERR_transaction_restart, transaction_restart_fill_relock) \ 136 x(BCH_ERR_transaction_restart, transaction_restart_fill_mem_alloc_fail)\ 137 x(BCH_ERR_transaction_restart, transaction_restart_mem_realloced) \ 138 x(BCH_ERR_transaction_restart, transaction_restart_in_traverse_all) \ 139 x(BCH_ERR_transaction_restart, transaction_restart_would_deadlock) \ 140 x(BCH_ERR_transaction_restart, transaction_restart_would_deadlock_write)\ 141 x(BCH_ERR_transaction_restart, transaction_restart_deadlock_recursion_limit)\ 142 x(BCH_ERR_transaction_restart, transaction_restart_upgrade) \ 143 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_upgrade) \ 144 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_fill) \ 145 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_raced) \ 146 x(BCH_ERR_transaction_restart, transaction_restart_key_cache_realloced)\ 147 x(BCH_ERR_transaction_restart, transaction_restart_journal_preres_get) \ 148 x(BCH_ERR_transaction_restart, transaction_restart_split_race) \ 149 x(BCH_ERR_transaction_restart, transaction_restart_write_buffer_flush) \ 150 x(BCH_ERR_transaction_restart, transaction_restart_nested) \ 151 x(0, no_btree_node) \ 152 x(BCH_ERR_no_btree_node, no_btree_node_relock) \ 153 x(BCH_ERR_no_btree_node, no_btree_node_upgrade) \ 154 x(BCH_ERR_no_btree_node, no_btree_node_drop) \ 155 x(BCH_ERR_no_btree_node, no_btree_node_lock_root) \ 156 x(BCH_ERR_no_btree_node, no_btree_node_up) \ 157 x(BCH_ERR_no_btree_node, no_btree_node_down) \ 158 x(BCH_ERR_no_btree_node, no_btree_node_init) \ 159 x(BCH_ERR_no_btree_node, no_btree_node_cached) \ 160 x(BCH_ERR_no_btree_node, no_btree_node_srcu_reset) \ 161 x(0, btree_insert_fail) \ 162 x(BCH_ERR_btree_insert_fail, btree_insert_btree_node_full) \ 163 x(BCH_ERR_btree_insert_fail, btree_insert_need_mark_replicas) \ 164 x(BCH_ERR_btree_insert_fail, btree_insert_need_journal_res) \ 165 x(BCH_ERR_btree_insert_fail, btree_insert_need_journal_reclaim) \ 166 x(0, backpointer_to_overwritten_btree_node) \ 167 x(0, lock_fail_root_changed) \ 168 x(0, journal_reclaim_would_deadlock) \ 169 x(EINVAL, fsck) \ 170 x(BCH_ERR_fsck, fsck_fix) \ 171 x(BCH_ERR_fsck, fsck_delete_bkey) \ 172 x(BCH_ERR_fsck, fsck_ignore) \ 173 x(BCH_ERR_fsck, fsck_errors_not_fixed) \ 174 x(BCH_ERR_fsck, fsck_repair_unimplemented) \ 175 x(BCH_ERR_fsck, fsck_repair_impossible) \ 176 x(0, restart_recovery) \ 177 x(0, data_update_done) \ 178 x(EINVAL, device_state_not_allowed) \ 179 x(EINVAL, member_info_missing) \ 180 x(EINVAL, mismatched_block_size) \ 181 x(EINVAL, block_size_too_small) \ 182 x(EINVAL, bucket_size_too_small) \ 183 x(EINVAL, device_size_too_small) \ 184 x(EINVAL, device_size_too_big) \ 185 x(EINVAL, device_not_a_member_of_filesystem) \ 186 x(EINVAL, device_has_been_removed) \ 187 x(EINVAL, device_splitbrain) \ 188 x(EINVAL, device_already_online) \ 189 x(EINVAL, insufficient_devices_to_start) \ 190 x(EINVAL, invalid) \ 191 x(EINVAL, internal_fsck_err) \ 192 x(EINVAL, opt_parse_error) \ 193 x(EINVAL, remove_with_metadata_missing_unimplemented)\ 194 x(EINVAL, remove_would_lose_data) \ 195 x(EINVAL, btree_iter_with_journal_not_supported) \ 196 x(EROFS, erofs_trans_commit) \ 197 x(EROFS, erofs_no_writes) \ 198 x(EROFS, erofs_journal_err) \ 199 x(EROFS, erofs_sb_err) \ 200 x(EROFS, erofs_unfixed_errors) \ 201 x(EROFS, erofs_norecovery) \ 202 x(EROFS, erofs_nochanges) \ 203 x(EROFS, insufficient_devices) \ 204 x(0, operation_blocked) \ 205 x(BCH_ERR_operation_blocked, btree_cache_cannibalize_lock_blocked) \ 206 x(BCH_ERR_operation_blocked, journal_res_get_blocked) \ 207 x(BCH_ERR_operation_blocked, journal_preres_get_blocked) \ 208 x(BCH_ERR_operation_blocked, bucket_alloc_blocked) \ 209 x(BCH_ERR_operation_blocked, stripe_alloc_blocked) \ 210 x(BCH_ERR_invalid, invalid_sb) \ 211 x(BCH_ERR_invalid_sb, invalid_sb_magic) \ 212 x(BCH_ERR_invalid_sb, invalid_sb_version) \ 213 x(BCH_ERR_invalid_sb, invalid_sb_features) \ 214 x(BCH_ERR_invalid_sb, invalid_sb_too_big) \ 215 x(BCH_ERR_invalid_sb, invalid_sb_csum_type) \ 216 x(BCH_ERR_invalid_sb, invalid_sb_csum) \ 217 x(BCH_ERR_invalid_sb, invalid_sb_block_size) \ 218 x(BCH_ERR_invalid_sb, invalid_sb_uuid) \ 219 x(BCH_ERR_invalid_sb, invalid_sb_too_many_members) \ 220 x(BCH_ERR_invalid_sb, invalid_sb_dev_idx) \ 221 x(BCH_ERR_invalid_sb, invalid_sb_time_precision) \ 222 x(BCH_ERR_invalid_sb, invalid_sb_field_size) \ 223 x(BCH_ERR_invalid_sb, invalid_sb_layout) \ 224 x(BCH_ERR_invalid_sb_layout, invalid_sb_layout_type) \ 225 x(BCH_ERR_invalid_sb_layout, invalid_sb_layout_nr_superblocks) \ 226 x(BCH_ERR_invalid_sb_layout, invalid_sb_layout_superblocks_overlap) \ 227 x(BCH_ERR_invalid_sb_layout, invalid_sb_layout_sb_max_size_bits) \ 228 x(BCH_ERR_invalid_sb, invalid_sb_members_missing) \ 229 x(BCH_ERR_invalid_sb, invalid_sb_members) \ 230 x(BCH_ERR_invalid_sb, invalid_sb_disk_groups) \ 231 x(BCH_ERR_invalid_sb, invalid_sb_replicas) \ 232 x(BCH_ERR_invalid_sb, invalid_replicas_entry) \ 233 x(BCH_ERR_invalid_sb, invalid_sb_journal) \ 234 x(BCH_ERR_invalid_sb, invalid_sb_journal_seq_blacklist) \ 235 x(BCH_ERR_invalid_sb, invalid_sb_crypt) \ 236 x(BCH_ERR_invalid_sb, invalid_sb_clean) \ 237 x(BCH_ERR_invalid_sb, invalid_sb_quota) \ 238 x(BCH_ERR_invalid_sb, invalid_sb_errors) \ 239 x(BCH_ERR_invalid_sb, invalid_sb_opt_compression) \ 240 x(BCH_ERR_invalid_sb, invalid_sb_ext) \ 241 x(BCH_ERR_invalid_sb, invalid_sb_downgrade) \ 242 x(BCH_ERR_invalid, invalid_bkey) \ 243 x(BCH_ERR_operation_blocked, nocow_lock_blocked) \ 244 x(EIO, btree_node_read_err) \ 245 x(EIO, sb_not_downgraded) \ 246 x(EIO, btree_node_write_all_failed) \ 247 x(EIO, btree_node_read_error) \ 248 x(EIO, btree_node_read_validate_error) \ 249 x(EIO, btree_need_topology_repair) \ 250 x(EIO, bucket_ref_update) \ 251 x(EIO, trigger_pointer) \ 252 x(EIO, trigger_stripe_pointer) \ 253 x(EIO, metadata_bucket_inconsistency) \ 254 x(EIO, mark_stripe) \ 255 x(EIO, stripe_reconstruct) \ 256 x(EIO, key_type_error) \ 257 x(EIO, no_device_to_read_from) \ 258 x(EIO, missing_indirect_extent) \ 259 x(EIO, invalidate_stripe_to_dev) \ 260 x(BCH_ERR_btree_node_read_err, btree_node_read_err_fixable) \ 261 x(BCH_ERR_btree_node_read_err, btree_node_read_err_want_retry) \ 262 x(BCH_ERR_btree_node_read_err, btree_node_read_err_must_retry) \ 263 x(BCH_ERR_btree_node_read_err, btree_node_read_err_bad_node) \ 264 x(BCH_ERR_btree_node_read_err, btree_node_read_err_incompatible) \ 265 x(0, nopromote) \ 266 x(BCH_ERR_nopromote, nopromote_may_not) \ 267 x(BCH_ERR_nopromote, nopromote_already_promoted) \ 268 x(BCH_ERR_nopromote, nopromote_unwritten) \ 269 x(BCH_ERR_nopromote, nopromote_congested) \ 270 x(BCH_ERR_nopromote, nopromote_in_flight) \ 271 x(BCH_ERR_nopromote, nopromote_no_writes) \ 272 x(BCH_ERR_nopromote, nopromote_enomem) \ 273 x(0, invalid_snapshot_node) \ 274 x(0, option_needs_open_fs) \ 275 x(0, remove_disk_accounting_entry) 276 277 enum bch_errcode { 278 BCH_ERR_START = 2048, 279 #define x(class, err) BCH_ERR_##err, 280 BCH_ERRCODES() 281 #undef x 282 BCH_ERR_MAX 283 }; 284 285 const char *bch2_err_str(int); 286 bool __bch2_err_matches(int, int); 287 288 static inline bool _bch2_err_matches(int err, int class) 289 { 290 return err < 0 && __bch2_err_matches(err, class); 291 } 292 293 #define bch2_err_matches(_err, _class) \ 294 ({ \ 295 BUILD_BUG_ON(!__builtin_constant_p(_class)); \ 296 unlikely(_bch2_err_matches(_err, _class)); \ 297 }) 298 299 int __bch2_err_class(int); 300 301 static inline long bch2_err_class(long err) 302 { 303 return err < 0 ? __bch2_err_class(err) : err; 304 } 305 306 #define BLK_STS_REMOVED ((__force blk_status_t)128) 307 308 const char *bch2_blk_status_to_str(blk_status_t); 309 310 #endif /* _BCACHFES_ERRCODE_H */ 311